#development
1 messages · Page 185 of 1
inline inlines your code to whoever calls it
it's good for one-liner functions
that serves as an alias to call another function
so if they were to call push_back normally it'd just inline the insert code into the file they called it in?
mhm

It tells the compiler "hey, whoever is calling this function, instead of calling it, what you're really doing is insert(length, element), so just call that instead"
The compiler can choose to ignore you whenever it wants though
Inline is good for returning private variables that you want to have get-only access
Okay so I need to
- Resize the vector to be able to take in a new element
- Insert said element
class A {
private:
int m_Member;
public
// Caller doesn't have direct access to m_Member, so encapsulation is preserved
// But no precious stack space is wasted by doing a function call
inline int GetMember() const { return m_Member; }
}
no you cannot
m_Member is still memory allocated, the compiler cannot guess what it is ahead of time
let me test
I know
pub const fn get_thing(&self) -> Thing {
self.thing
}
``` is legal in Rust so
why not
grr see this is why I am not motivated, I am trying to think of how to approach this push_back method but I don't even know where to start
this entire code is using const functions lol https://github.com/null8626/decancer/blob/main/core/src/codepoints.rs
My first thought is to resize the array so it can take in a new element, which seems to be correct
but idk how to resize it by, initially I thought to take the current length and plus 1 it
theoretically you can, though i recommend ```cpp
while (length < capacity) {
length *= 2;
}
doubling the capacity of the array is generally an acceptable solution
I already have a resize_to_fit function
Can cause problems with large amounts of elements but for your case that's not a problem at all
might as well use that
Don't
Why?
wait if length is zero then set it to 1
Because ideally you should only have a resize() function
The resize_to_fit function was made specifically for your previous insert method
Which is flawed because you shouldn't ever be "resizing to fit some index"
Well wouldn't I essentially do the same thing?
I need to change the capacity and make a new array and move the elements to that array
It's the same concept but you should get rid of that function altogether because you should not be resizing to an index like that
The capacity should be controlled/changed ONLY when you run out of space in your array; every element should be contiguous
Yes
Length and capacity only
capacity: size of the array in memory
length: the amount of populated members in said array
Okay so when should I technically call this new method?
capacity must always be equal or greater than length
Whenever length >= capacity
Should I check to see if the array can take in a new member and if not then call it?
Oh right duh I am so fucking dumb

So could I still use the skeleton of my resize_to_fit method but just remove its reliance on an index?
or would it be different code?
to me it seems it'd be roughly the same
but instead just make it check on length and capcity instead of capacity and index
Roughly the same yes
Try to think about what it does though
If you double your capacity, you have to allocate a new block of memory. Then, you have to copy those elements over to the new allocated block of memory. Then you must delete the old memory, and set your array pointer to the new block of memory
yea
You can copy elements with a traditional for loop, or you can copy over elements with memcpy
yea
They work fundamentally the same and I'm sure the compiler would end up optimizing them to be the same exact code
void resize() {
int newCapacity = capacity;
while (newCapacity <= length) {
newCapacity *= 2;
}
T* temp = new T[newCapacity];
memcpy(temp, array, sizeof(T) * capacity);
capacity = newCapacity;
delete[] array;
array = temp;
}
this is what I currently have
is this remotely correct?
Yes that's perfect
then say I wanted to use it i'd do
void push_back(T element) {
if(length >= capacity) {
resize();
}
// Rest of code here
}
Yup
Also just a quick note on the differences between delete and delete[]
delete is used for when the pointer only points to one object in memory
delete[] is used for when the pointer points to the first object in an array of objects that need to be deleted

The allocator tracks this data in the underlying implementation, but just make sure you use the right type of delete operator, otherwise you may cause a memory leak
first object in an array of objects?
Yes
Not quite sure I follow
If you allocate with new only, you must use delete, if you allocate with new Something[Size], you must use delete[]
Well yea I follow that
I am not quite sure I follow your explanation
How is array in this case in an array of other objects?
When you do ```cpp
int* a = new int[5];
a is just the memory address of the first integer in this array
a is basically the memory address to the entire array
Yes and no
it just defaults to the first element
a points to the first element
But the elements are laid out continuously in memory
| first | second | third | fourth | fifth
^^ a points here
*a; // element 0
*(a + sizeof(int)); // element 1
*(a + (2 * sizeof(int)); // element 2
*(a + (3 * sizeof(int)); // element 3
Then when you do a[1] what it's really doing is
| first | second | third | fourth | fifth
^^ next element
Array indexing is just pointer arithmetic behind the scenes
or
a[0]; // element 0
a[1]; // element 1
a[2]; // element 2
a[3]; // element 3
same thing
The compiler hides it from you because it's slightly counterintuitive and annoying to write
pointer arithmetic ftw tho 
rust unsafe enjoyer
like seriously all of my Rust projects have a github issue saying that i used too much unsafe
@wheat mesa
Ideally you should be avoiding unsafe altogether
I don’t get what you’d be using it for unless you’re doing something inherently unsafe like embedded dev or smth
I mean I understand how it works
but your wording confused me
delete[] is used for when the pointer points to the first object in an array of objects that need to be deleted
this wording confuses me because to me it sounds like you are sayingarrayis in an array in memory and its the first element
nope my C self won't let it
array is a pointer
i also add SAFETY commands alongside unsafe calls tho
It points to the first element
okay but technically its not deleting just the first element no?
nope
You’re correct
it deletes the entire array
its deleting everything at that address which is the entire array
ok
The address is not the entire array
When you use delete[] it tells the allocator that the pointer you’re deleting points to an array, and it does the necessary work to delete it
okay so basically it is pointing to an array just not the entire array
Yes
but delete[] knows to not just delete the first element but rather delete everything in the array the first element is in
The allocator knows how much memory that the pointer owns and so when you call delete[] it releases that memory
yes thats for the operating system to know
I am understanding now
Hey I think I got it!
void push_back(T element) {
if (length >= capacity) resize();
array[length] = element;
length++;
}
There ya go
anything I could be missing?
Not sure what that negative number is there though
me neither
Make sure your length starts with 0
aha
that was the issue
I set it to 1
How would I grab a reference to a value in an array so I can delete it then return it? Cause if I just delete the value then the variable containing the value would be empty as well no?
you dont
try this```cpp
if (index >= length) throw le_error();
T value = pointer[index];
std::memcpy(&pointer[index], &pointer[index + 1], (length - index + 1) * sizeof(T));
length--;
return value;
Well you see I am not doing this based off an index
I am just removing the last element
but I thought it'd be nice to get what that last element was
oh right
try this```cpp
if (length == 0) throw le_error();
T value = pointer[length - 1];
length--;
return value;
yuhh
no
it doesnt decrease the size of the array in memory
it just marks the array as having less members

and it works
i guess you can decrease the array size but thats just adding another overhead
*the capacity stays the same
yea
I know what you meant
dw
Doesn't matter if the capacity is the same or not tbh
I wonder why it removes the element tho 
I mean I guess it kind of has to so that way it doesn't break
but like
thats the point of pop_back()
well yes null I know
I am wondering why decreasing the length just removes the last element.

you can technically decrease the size with another new and delete[]
but it's adding unnecessary overhead imo
Okay so like, I know its capacity stays the same null, but its length is no longer the same
yes
I think you are confusing what I am saying
yes i am
im tired

lol i always confuse what you say and you always confuse what waffle says
What I was saying was doing length-- removes the last element from the array but I know now its capacity still stays the same
yes, it just decrements the length int
I was wondering why doing such will cause c++ to remove the last element, though I have a theory its because now its length is less so it has to do something so that its in compliance to what the length should be, which is remove the last element
nooooo

okay well its still confusing
cause all I am doing is decrementing the length
so I don't see how that causes this behavior

well your Vector methods depend on the length property
so it affects all of your methods
C:\Dev\cpp-classes\Vector.h(45): error C2561: 'Vector<int>::pop_back': function must return a value
C:\Dev\cpp-classes\Vector.h(44): note: see declaration of 'Vector<int>::pop_back'
C:\Dev\cpp-classes\Vector.h(44): note: while compiling class template member function 'T Vector<T>::pop_back(void)'
with
[
T=int
]
C:\Dev\cpp-classes\main.cpp(12): note: see the first reference to 'Vector<int>::pop_back' in 'main'
C:\Dev\cpp-classes\main.cpp(6): note: see reference to class template instantiation 'Vector<int>' being compiled
ninja: build stopped: subcommand failed.
wtf is happening
T pop_back() {
if (length == 0) return;
T back = array[length - 1];
length--;
return back;
}
I am clearly returning something
what about the first line?
me when throw
me when I’m too tired to care anymore 
anyone who is familiar with react or nextjs, i'm building my first react/next.js project and i'm encountering a weird bug.
i am trying to markdown and format timestamps.
while on initial input it works.
if you follow these steps you get undefined for non relative timestamps:
- enter a relative and non relative timestamp
- wait for relative to update
- tab out of and back into the page
- the non relative timestamp becomed invalid.
My code: https://pastebin.com/Yf2hBe0S
anyone who could help me solve it and educate me as to what was wrong would be greatly appreciated :)
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
^ here's a video to better demonstrate the issue and make up for my poor explanation skills
how can i stop the middle text (a tag) going over into the text on the right?
overflow-ellipsis does nothing 😔 i hate css man
try gap-1 or so for the flex container
already using gap-2, anything higher pushes the number out of the container
line-clamp cuts off the word but doesnt add an ellipsis
@wheat mesa can you explain something for me? Null was too tired last night to explain properly
gimme 15-20 mins then I can
Aight what’s up
Can you explain to me how this works?
T pop_back() {
if (length == 0) return;
T back = array[length - 1];
length--;
return back;
}
It's behaviour is that it does indeed seem to remove the last element in the array, but I am still not sure I am understanding what null said because I don't get how its happening when im just decrementing the length. Now I know its capacity stays the same but its length is no longer the same in memeory right?
The memory layout doesn’t change
You’re just essentially marking the data as free space you can overwrite
yes
That T is still in memory unless you write over it or you deallocate the array
no?
wait, imma just bring up my paint
You're just saying "Okay so I still have this capacity, I'm just going to say there's only 4 elements instead of 5 elements in there now"
You're not deallocating anything
You're just essentially "marking" the space as unused so that when you call push_back again, something will overwrite at that spot
@sharp geyser see, the element is still there, the len is just 3 now
If you actually deallocated that T then the person getting the value from pop_back would get an invalid pointer
although actually you're copying here so that wouldn't happen
So essentially there is still technically 5 items, its just one is an empty spot that still exists in memory, it just can be overwritten?
if you add something to the end of the vector array list whatever you call them these days, it'll just replace whatever was at the black circle
it's not empty
it contains the value of T
until you overwrite it
let's say that accesing it now will be undefined behaviour
It's like how when you delete something on a physical hard drive, it often isn't ACTUALLY deleted, just the space it took up is marked as "free" and can be overwritten
hm
Okay so, I get that its marked as free, but there is no physical value there right?
there is something there
the value is there
Like say I set 3 to be at the back, then I pop it off, im not going to see 3 anymore
3 is still going to be there
That's true but the 3 might still be in the memory
It actually will be in the memory if you haven't done anything else to it with your current implementation
it's going to stay there because that memory is allocated to the vector, and if you don't do anything to it then it's going to stay there
When you print it, it only goes up to length elements though
👀 what lang are we talking about?
Ahhhh
Gotcha
So it still exists, but since my methods rely on the length it wont print it
don't access out of bounds data ^^
Change your method to print to capacity and see what happens
If I was to try and print beyond the length id still see it I assume
You'll probably get whatever you last popped and then a bunch of garbage data past that
yeah, and then you'll get either a lot of garbage or an immediate segfault
just use vim
NOPE
if you're writing c++
not using vim, I tried that and I hated it
nvim is pretty nice it's just a big learning curve and I'm too lazy
Neovim requires a license?
no lol
no
Neovim is a fork of the keyboard-based text editor Vim. It is focused on extensibility and integrates the Lua programming language for easier scripting.
#programming #vim #100SecondsOfCode
💬 Chat with Me on Discord
🔗 Resources
Neovim Docs https://neovim.io/
Vim in 100 Seconds https://youtu.be/-txKSRn0qeA
Lua in ...
I don't want to use neovim
it's too much work to type commands into my text editor, I just want single keypressses that do stuff.
I used vim for years
but using it for larger projects is just painful. and yeah people who say "but there are plugins for this and that"...
I don't want to spend weeks tracking down plugins and tinkering with my editor
my editor is a tool I want to work out of the box,.not a toy

If you still have your high school one you can just photoshop the year
They won’t question a thing
I got rid of a lot of my hs stuff
clion is ass. just saying. phpstorm though now that's nice
clion has weird ideas about vcpkg workflow
Clion is good to me 
CLion is awesome
Just don’t use windows for C++
Duh
I might dual boot linux sometime
CMake is so much easier to work with on Linux
I wonder if I can just put linux on a spare ssd that I have and be able to boot from that

CMake is ass
iirc clion still tries to use vcpkg on Linux,.yeah it works there.... sorta. but why use it when libs are in apt or whatever?
yes you can do that
why couldn't you?
cause idk anything about boot loaders
I didn't know if it all had to be on the same drive

that has nothing to do with boot loaders tho
listen weeb you severely underestimate how stupid I am when it comes to operating systems.
cmake is ok. a lot of cmake based projects are NOT based, and are ass
what do you prefer as alternative?
I know how to build a pc, I know how to use one
but idk a damn thing about the os itself or how it works
Cargo
lul
are you one of these pure make masochists?
make
yes
I am one of those
If C++ had a centralized dependency manager then everything would be a billion times easier
enjoy lol, make is portable as an anvil
make one
You can’t just make one

The language has been out for like 40 years
mainly because of the ton of non standard gnu make extensions
vcpkg was Microsoft’s attempt at solving it, even that sucks compared to something like cargo
no don't encourage him we got like 50 "standard Package managers" already

yeah that's a no no
at least c++ doesn't have npm.
The internet wasn’t a huge thing like it is now when C++ was first released, I don’t think many people thought about the notion of a “package manager”
npm is like a lighter on a fireman's uniform.
pnpm is amazing /s
can't argue havent tried it
its not
js developers use 3 million deps for every tiny project
pnpm sucks as well
npm ecosystem in one word: is_even.
is_true
is_number
The dependencies take up more space than the projects themselves take 99.99999% of the time
is_odd
is-odd is a funny one because it depends on is-even
is_odd. depends on is_number and is_even 
ok pnpm just manages a global node_modules instead of having one per project, that actually sounds nice, although it just symlinks packages to the local node_modules
Any articles or videos you guys recommend?
js was literally created in a week, that's pretty impressive
I dont wanna fuck my shit up
don't
I'm still surprised sun never sued them for trademark infringement when they renamed it to JavaScript from livescript
why not
just use vs for right now
you're going to lose motivation by worrying more about your environment than your actual projects
they're not even related!
I know! lol
ima just use vs code
I told you
don't overcomplicate it
the people that named it knew too they were just riding on it's coat tails
misty you're not even to the point that you need dependencies yet
you shouldn't be worrying about your IDE like that
what are you making in c++?
overall vim is much much more powerful than say vscode but takes a lot of learning and configuration
but I hate visual studio!!!!!
he's making some data structures for practice
I can't even uncomment shit thats commented
I have to manually go through and remove the //
maybe I'm a zoomer but I just like VS and CLion because you don't have to set a billion things up, it's plug and play
vim is an editor for tinkerers, the sort that run arch btw. I don't have time to play I have real work to do 😁
it is powerful if you spend tons of time playing with it's configs
there's these things called uh, plugins, have you tried them? 
Theres a plugin that lets you uncomment and comment things 💀
that should be a thing by default
this
there are those who produce stuff and those that just play with settings all day
even if I had a super familiar vim setup, I wouldn't be able to think fast enough to make it worth it lol
Also I have no fucking clue on how to access the settings menu
yeah don't put me in the "those who produce stuff" category so quickly lol
I probably have one or two "flagship" projects that I've actually finished
when I go in vim I have about 10 or so things I do, including regex search and replace, delete to line, jump to line... not much else tbh
then there's those that produce stuff and on their free time tinker with the tools they love
One being a java game engine, the other being a basic treewalk interpreter in rust
exports.run = async (client, message, args) => {
if(!message.member.hasPermission('message.guild.ownerID')) {
return message.channel.send('❌ You need to own the server to load the backup in this server.');
} anyone know how I can make this code make it so only the author that created the backup can use the command?
Right now I'm working on a proper opengl engine with C++ though, it's revived my love for low level
use a code block please
I ain't reading that without one
there is no level
mkay
exports.run = async (client, message, args) => {
if(!message.member.hasPermission('message.guild.ownerID')) {
return message.channel.send(':x: You need to own the server to load the backup in this server.');
}```
yeah there is there are two. newbs that play rust, the game and those who don't
I wasted so much time playing video games when I was like 12-15/16
could've been a programming god
Honestly same
I wasted so much time on gaming I never focused much on programming

I purposely bring out that emoji when people talk rust tbh, because it winds people up more than 
when creating the backup, store the id of the person that created it in a database, and then when restoring the backup check if the id of the person running the command matches that of the person that created the backup, idk if that's what you're looking for, honestly that's what I got from your question lol @frigid leaf
tbf though it was probably worth the memories made in the process
:norust: is blasphemy
I found out how to comment and uncomment things
why its CTRL + K + C I have no idea
any idea how to do that i use discord-backup library so im not sure how to store it automatically

I don't have a nocpp, anyone got one?
that's on you then, I don't even know what the discord-backup library is, but are js devs now just creating discord bot features as packages 💀
Lmao, true i guess i could just rewrite it so it just stores it in a postgresql db


(lambdas)

coroutines
yeah, but you can still use the lib you're using, just store the id when creating the backup and store something to identify the backup, and when restoring it just check if ids match and that's pretty much it
oh god
I'm gonna have to learn coroutines for a game engine aren't I
either way I'm sure it'll be an interesting process
not likely
next up on the list is figuring out texturing batching with layers
most game engines are stuck in 2001 with shitty entity component systems that are too much OOP
oh
coroutines are c++20
I was going to make an ECS
entity component systems are super powerful as long as you actually think about the data and not the structure of classes
ECS is standard way to do game engines but don't be tempted to OOP everything, that's like using only the hammer in your toolbox, c++ has many tools
Rust definitely helps with orienting your brain to think about it data-wise
yeah think data
composition over inheritance
vtables are performance killers
vtable lookups are performance killers*
lots of inheritance -> lots of vtable lookups
with a good block allocator it's ok, and you won't notice the difference in performance unless you're calculating rocket trajectories for spacex
a good block allocator will keep related stuff nearer to each other so good for cache
Yeah cache locality helps a lot
Inheritance being very bad for it because everything lives everywhere
also, use vectors where you can and std::array
I planned to use pretty much all std::array
not unordered map or map, and never std::list
alongside std::bitset
if speed is what you want
yeah
it's easy to turn array or vector into a simple hash table
linkedlist bad for caching and random access, map and unordered map incurring a cost for random access as well
So for my clear method I simply set the internal array to a new array of type T, and set the length back to 0, is this fine?
unordered map is O(1) for access, access is fast but it murders cache
also unordered map doesn't free when items are removed,.it just grows forever
hashing still has a cost
Should be fine but just be aware that if the user stores pointers within your vector, it will not deallocate them
insertion costs 1000x more as it has allocations
Your vector is just responsible for managing the chunk of memory that the T* array points to
and we "rehash" them periodically, like a GC step, we allocate a completely new unordered map and copy the contained items to the new one then delete the old one
this keeps it's rampant memory usage in check
that's actually quite a neat trick
at the expense of some CPU cycles and a lock
is dpp multithreaded?
yes
dayum
and thread safe
I barely touch threading with a 10 foot pole in Java, much less C++
Java makes it relatively easy for doing things like not locking a UI thread by usage of thread pools, but making data structures thread safe and such is a different story
It's bittersweet that my time with Java has come to a temporary end
you can lock a shared mutex as a reader or writer.
a reader can claim the lock so long as there are no writers
a writer can only claim the lock if there are no other readers or writers
Wth is begin() and end()
makes things like monitoring a queue really nice
begin() is a pointer to right before the first element of a container, end() is a pointer to after the last element of a container
like vector has vector::begin
they're iterators
begin is pointer TO first element
end is pointer to AFTER the last (not valid)
thought you had to increment before dereferencing
Since I see the for (auto it = s.begin(); it != s.end(); ++it) pattern a lot
maybe not right now, I'd start to think about insertion and deletion at particular array indexes
iterators can be a little tricky to think about
btw if you want to iterate a container don't use iterators
old way:
for (auto iter= container.begin(); iter != container.end(); ++container)
new way:
for (const auto & item : container)
❤️
new way is far nicer
and never EVER remove an item from a container you're iterating without taking special steps to avoid UB
idk if that's an issue in rust too
I think it's usually just a bad idea to be modifying a container you're iterating over in the first place
Regardless of language
Unless you really know what you're doing
you can modify the things your container has in it
but adding or removing from it while iterating is recipe for pain
adding is usually "non fatal" bug, it will iterate at least one item twice
removing is source of horrible heap or stack corruptions
Java treats this as a complete catastrophe and throws if you attempt to do this whilst iterating within a foreach
ConcurrentModificationException
neither are wise but the first can go unnoticed in code for years
lol, that's not a bad idea
iirc the reason is because the iterators are invalidated after you add or remove since the GC can shuffle memory around how it deems fit
in dpp you'll see this pattern a lot:
lock mutex
copy container
unlock mutex
long looped thing on copy of container
delete copy
You can still do it in a traditional for loop but not while using iterators
copying the container being tons faster than iteration to do "x"
and when you lock some mutex you want it locked as least time as possible
I'd imagine copying is pretty cheap in contiguous memory since memcpy is super cheap
yup
so things like processing lists of http requests
processing a queue can take literal minutes
if it's big or you're near rate lokitn
but copying the queue vector takes microseconds
man I love low level
so much to think about and the more you know the faster your code gets
you should contribute to dpp lol I did everything from scratch
modern C++ scares me
custom websocket client and http client
the socket stuff dives deep into C
lots of pointers and raw buffers
could have used libuv but where's the fun in that and I hate dependencies
I'm trying to modernize my C++ knowledge by writing my engine with "Modern" c++
aka using more than "throw this pointer around, who cares"
maybe a unique_ptr or shared_ptr in there somewhere and a little bit of optional when I start writing the ECS
one hint id give is if you feel you're typing too much boiler plate you're probably doing it a bad way
and if you find yourself typing long type names over and over remember auto and "using"
most of the boilerplate I'm writing is just trying to modularize opengl stuff
people who complain c++ is too verbose are usually trying to emulate java
I wrote a lot of different classes (this is my first time using opengl) following videos from TheCherno's opengl series, just to realize that I can stuff all of it into a renderer class and it would be better anyways
if you want an example of how not to write c++ look at libmysqlclient++ (the official mysql c++ lib).. it's a horrific mess that tries to emulate jdbc
anyone know any API that is useful for my discord bot, I want it to fetch automatic lyrics while the song plays
but like I want to stay on the cheap side or even like free side X)
For example here's part of my renderer constructor lmao ```cpp
m_QuadBuffer = new Vertex[s_MaxVertexCount];
m_QuadBufferPointer = m_QuadBuffer;
// VertexBuffer
glGenBuffers(1, &m_VertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
glBufferData(GL_ARRAY_BUFFER, s_MaxVertexCount * sizeof(Vertex), nullptr, GL_DYNAMIC_DRAW);
// VertexArray
glGenVertexArrays(1, &m_VertexArray);
glBindVertexArray(m_VertexArray);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glEnableVertexAttribArray(3);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 10 * sizeof(float), (const void *) 0);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 10 * sizeof(float), (const void *) (3 * sizeof(float)));
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 10 * sizeof(float), (const void *) (7 * sizeof(float)));
glVertexAttribPointer(3, 1, GL_FLOAT, GL_FALSE, 10 * sizeof(float), (const void *) (9 * sizeof(float)));
I could replace the VertexArray stuff with a nice little layout manager, but then I remembered that it's pointless because this engine is specifically for me
what are the vertexes for
And I do not plan on needing more than a position, color, uv, and layer
shouldn't that be from a model file or something?
ah is it your display plane?
Everything will be rendered as a rectangle
And this is just for telling the GPU how the data looks in vram
id be tempted to display just one quad with a texture on it and update the texture lol
position 0 is 3 floats that represent position, 1 is 4 floats that represent color, etc
but last time I did 2d, I did software rendering
this is similar to what I'm doing
I wrote a textureatlas class that manages stuffing multiple textures into one and just sampling from different parts of it
(thanks to stb_rect_pack for doing the hard work)
The next thing on my todo list is to make it so I can access multiple texture units instead of just one
that way I can reduce draw calls even more
those images are programmatically packed into the black rectangle
hey guys, i finally made some time to put my api online. So as stated before i have an api running on my vps and my own site on my other hosting platform. I currently do fetch requests to the api and eventually also redirect customers back to the site etc. How would i possibly connect my api to my site?
Like setting a subdomain
such that i can fetch my api using domain/subdomain.com
my site is also running on https
so i recently tried using fetch to my express api which would not work as https -> http was not allowed by cors
is the window with hello world imgui?
yea
first make sure the API is accessible on port 443
point subdomain at it via dns
and use certbot and letsencrypt to get free ssl
after that you could use cloudflare to obscure the real IP
i see obvs https has a 443 port.
can i instead also create an a record pointing to my ip?
yes
idk it's handled by my hosting
i can't even access cloudfare i think
i can only add dns records manually but that's about it
what did I miss here
@wheat mesa pinging you cause I know you know how to help but if anyone reads this and can help please do so
so for my insert method I can think of a problem i'd have to face.
What if they are trying to put something at an index that already has a value. My initial thought was to just shift everything after that index down one and then add in the element at that index but idk how i'd do that unless this could work
void insert(int index, T element){
if(index >= length) return;
if(array[index]){
// If there is already something there
for(int i = 0; i < index - 1; i++){
// will likely need to change what i or my comparison is but I can't think right now lol
array[i] = array[i + 1] // this seems wrong as well but again my brain no think properly
}
array[index] = element
}
length++;
}
There might be some other problems but im not too sure rn of any others i'd face.
Your intuition of shifting is correct, but backwards. Shift everything to the right, not the left
Or maybe I misinterpreted and that’s exactly what you meant
well
I want to shift everything after the index down one
so that way the element can take over that index
this is in case they are wanting to insert something at an index that is already taken
hm, how exactly should I be shifting? I feel like I should be using the index in some way shape or form since that is what I am basing the shift off of
but all my testing gives me some odd behavior where negative numbers take over the spots
or it just fills most of the indexes with the last element

Here was my next thought but it doesn't produce an appropriate result:
void insert(int index, T element) {
if (index >= capacity) resize();
if (index >= length) {
length = index + 1;
} else {
length++;
}
for (int i = length - 1; i > index; --i) {
array[i] = array[i - 1];
}
for (int i = 0; i < length; i++) {
std::cout << "Here is the elements after inserting: "
<< "\n" << array[i] << std::endl;
}
}
I thought using the length of the array for i and then seeing if i is greater than the index would work. I was thinking of starting backwards and shifting the elements down until it reaches the index like that
Why not start from where you want to insert the index?
Something like ```c++
for (int i = index + 1; i <= length; i++) {
array[i + 1] = array[i]
}
length++
arr[index] = element
that would delete the existing contents of i+1
I think this shld be ok
Well basically you would be shifting elements to the right, I'm sleepy so I think my brain isn't functioning correctly. Once you shift the elements, place the element you want in the index then increment length
I mean I am a beginner game dev
What question do you have, I might be able to help
Ah mmm im more like trying to figure out how to balance abilities
I have a discord rpg game
But it’s currently failing cause it’s not good enough
Need some game dev knowledge to fix and balance things
Okay, what are you currently doing?
Would be great if you can help me out
Mmm do like the rpg game has many abilities
Ofc
a lot of rpg games have some kind of abilities that players can have.
You should maybe look at izzi bot XD you’ll get an idea of what’s happening
So the abilities are on cards that players can collect
not exactly but there are some abilities that players don’t use at all
Cause they useless or under powered
is what they’re saying
Feedback from players
Hm, well. You can either find a way to rework the abilities so they are good, but not game breaking, or remove them and replace them with some other ones.
If you haven't already i'd also attach a rarity/drop chance to them if thats how your game is styled
You don't want people just getting these abilities for free, they have to work for em.
mm that’s the thing I need help with like talking to someone to rework them it would be great to talk to game dev as they would know better
Yeah
There’s rarity and stuff
Well, its hard to tell you much without knowing your game's plot/theme.
I can't make any judgements
Some games have abilities that make sense for them, while other abilities don't make sense for that plot/theme
I can take a look
great,
ping me when you join here, i
i'll fill you in with the details
Question, why does your bot require the ban and kick members perm?
you do have to play a bit at first tho, to understand the logic
You dont advertise any mod commands
it doesnt you can remove it
I'd recommend updating your invite link then 
ever wonder if the police use onetime passwords? /j 
What’s a one time password 
a password that u remember one time and use for every website
Oh I have plenty of those
https://cdn.hamoodihajjiri.com/9lr6F4CyVb
Same URL however different website? 👀
One leads to notion.so and other leads to notion.apps-pg.com (ad)?
Main question is, how does Google consider both websites same URL?
Notice the top one says sponsored? Thats the difference. It is the same website but ones a paid advertisement
However, it's not the same website; the top one leads to notion.apps-pg.com, which is a scam website, while the bottom one leads to notion.so, which is the real website?
Oh that’s weird asf
Oops, sorry. I just saw this (a month late to replying), it was a prototype that espouses Tolerance; since that was the theme of the competition.
google is good at scam ads
espouses tolerance?
Yeah, just a prototype of an app that promotes Tolerance.
nice
Yeah, anyhow, the contract is now terminated; now that the program is finally over.
^ You had to learn swift, do assignments, pass Apple's exam, & graduate. We did all.
fuck this took a bit
noice
what are you using for the browse thumbnails
ive just finished developing a resurrect feature for seven spells... the idea is that you can respawn near to your place of death once per hour, if you dont have a resurrect you have to wait or do what you always had to do before - start from the start
so ive basically added an optional non-hardcore option
of course premium users get to resurrect more often... 😉
and if you die and have no resurrect, it says this, basically "did you know premium users can res more often, if you were premium you'd be back in the land of the living rn"
😄
help tje ai logged into my google account
it knows what's best for you, don't resist this will all be over soon
if you're still interested, https://www.techradar.com/pro/security/google-ads-are-being-hijacked-to-serve-up-dangerous-malware
yo question
":white_check_mark:・ufo-verification",
{
type: "text",
permissionOverwrites: [
{
id: interaction.guild.id,
allow: [
"VIEW_CHANNEL",
"SEND_MESSAGES",
"READ_MESSAGE_HISTORY",
],
},
{
id: interaction.guild.roles.everyone,
deny: ["SEND_MESSAGES"],
},
{
id: client.user.id,
allow: ["VIEW_CHANNEL", "SEND_MESSAGES"],
},
],
}
);
await channel.send({
embeds: [embed],
components: [row],
});
await interaction.editReply({
content: "Setup Complete!",
ephemeral: true,
});```
what does this need perms other then Manage_Channels & Embed_Links?
its sometimes failing for some users not sure why
i have a checker only for those 2
Manage roles if you want them to be able to manage channel perms. Also if you set the need to have 2FA enabled in the server to do any mod actions then type person will need 2FA enabled to manage the channel
It’s a discord security feature
zamn
could have base gifs and then tint and manipulate and combine the images depending on conditions
i just resulted to using videos ngl
webp if its an option
so wtf is a bitset, is it just something that stores booleans as 1 bit?
yes and no
Basically it treats integers as "sets" of bits
it can only store 1's and 0's no?
booleans are inherently inefficient because they use 1 byte of storage (sometimes more) but only NEED 1 bit to function
But using bitwise operations you can stuff multiple booleans into one integer
hm
So how does it take something that normally takes 1 byte, and slims it down to 1 bit

does it just force its bit size? (if thats even possible)
Instead of 8 booleans with 1 byte each, you can use a 1 byte number and treat each individual bit as a boolean
You can make this dynamic to handle more than that though, which is essentially what a bitset does
sizeof(T)
C moment
not necesarily
If you have multiple booleans it reduces the overall size when compared to a boolean array
There is no benefit if you just have one boolean
hm
bool a[8];
cout << "Size of a: " << sizeof(a) << "\n";
std::bitset<8> set;
cout << "Size of set: " << sizeof(set) << "\n";
Size of a: 8
Size of set: 4
Yes
neat
Btw waffle
what is a good lib/framework to use to make desktop apps with c++
dang I was hoping it'd be simple like electron 
not at all
welp that squashes my project idea then
lmao nope
you're not building desktop apps with html/css/js
@sharp geyser try GTK, GLFW, SFML, or Imgui
I'd recommend learning more c++ first
like which part of C++?
memory management and stuff
what do you recommend I do then
graphics programming is very hard
I have no idea where to start to even learn memory management
makes sense
ownership
with that being said, you should do projects that keep you interested in learning
SDL is relatively easy as a graphics framework, but just don't go into it expecting quick results
this aint rust
i mean that goes the same for every new project using big frameworks
ownership is still a concept in C++
it just isn't enforced
ya see idk what projects to do. I am just starting out learning C++ again so I am going with a fresh slate.
i suggest attempting GUI ig
just dont go for the big frameworks first
start with the simpler ones
Ima work through that list slowly. It should teach me what I want to know ;p
geeksforgeeks is an awful site
beware their "tutorials"
sometimes they're even worse than chatgpt
basically the article writers don't have any real experience, they just parrot what they know and there is no peer review of what they write
it might be aweful but it gives me some ideas

Man you can't use floats in enums 
you can
no?
how?
because enums in C++ can't accept floats or doubles or anything not integral
no
why would you want floats in enums tho?
I was making a grade enum and assigning values to the letter grade.
going based off a 4.0 grading scale with a max letter grade of A
you can make the enum Grade { A, B, C, D, E, F } but process the floats yourself
like a helper function
only percentage-based grades


Well you can still turn a percent into a letter
if you go based off typical grading standards that accept +/- with a max letter grade of A
95-100 A
90-94 A-
87-89 B+
83-86 B
79-82 B-
77-79 C+
73-76 C
69-72 C-
67-69 D+
63-66 D
59-62 D-
0-58 F
idk if these are the same everywhere
but out of all the grading systems i've seen in a lot of parts of the world this seems to be the closest to universal
Though I think Asia is more strict 
Yup asia strict jeez
I mean I get it
America and UK are very lax imo
America Especially
and yet americans complain about their education system 😩
you could be as dumb as a box of rocks and still get your diploma
I complain that it is too ez
I passed high school with a 2.7gpa

I should not of passed
someone's lurking
what's the minimum
I didn't apply myself in high school and I suffered for it
tbh idrk
I've seen people with a 2.0 pass
I think the only requirement is to too just good enough to get the credit
and thats it
once you get all your credits you are no longer their problem
my high school average is a near 91% (not including last semester) 
they send you on your way with a diploma
I think my grad year though almost everyone had a 2.7 or higher
dang
I knew a number of kids who had a perfect 4.0
quite honestly I probably could of been one of those kids, I just slacked off majorly in freshman and sophmore year
I didn't start trying until junior year but by then my gpa already tanked
which subjects are you good at?
Science and History
nice
I liked history but know nothing about science

failed almost all physics, biology, and chemistry exams
I want to learn physics but I didnt take the chance to
Eh you’re not missing out on much
Physics is cool but it’s not a necessary class to have
grade point average
It depends where this data comes from. If it's from the database/cache, it probably doesn't matter much
But every minute is still too fast in my opinion because no one will sit and check how many servers you have every minute. Even if you set it every 30 minutes, these values would not differ much from each other
1 minute will be potential API abuse if your bot grows larger
it only sends to my server is that good?
i mean, your bot will process and send more messages, no?
Realistically discords unlikely to care, you're unlikely to hit the global ratelimit because of this. It just means your bot in your server will have 1 less message edit per minute. Which is the only one you'll potentially hit as your bot edits other messages in the server.
To me its more of a question of why 1 minute?
Its very unlikely anyone(including you) will see much change by checking that channel. It could be hours, or a day and it wouldn't degrade the experience much(most wont notice)
i mean regardless i'd probably check every minute and only update if it differs
I don’t think you need live stats like that either lol
Highly doubt your bot will join a new server every minute, best to update every 15/30 minutes instead
that's true, it's not necessary. Can just fetch it with a /stats command
Real analytics are way more fun anyway ^-^
Or you can just make a website for it
i think he was trying to display his bot's real-time stats in his support server
Yeah i figured so
Plus, why not just get the user count via guildMemberAdd/Remove and guildCreate events, store it in memory, and save that to a database every now and then
Sure it wouldn’t be accurate 100% of the time but it saves a lot of bandwidth overall
You’d only really have to fetch all of the information at once from the discord API if you have significant downtime
Thing is it isn't using a database
It pulls from the bots cache
I only created it bc I got bored
Wouldn't it be better to do something actually useful?
My ideas for my bot randomly come and go so I never really have something useful to do
Im not here to talk
Wrong dbl
Thank you guys
Your welcome
@bitter granite pertemuan sigma 🗿 https://youtu.be/rkgUtEuAHmc
u stopped playing right? u haven't logged in in almost 80 days
Havent for a while
But verry nice
Althou why #development
LOL
||Nevermind charater development ||
i forgot why im here ngl
because the usual people were here talking for some reason, so i thought im in general
How can I create a subcommand with discord.py?
an Argument with the type subcommand probably works too. not sure why they have both Argument and AppCommandGroup when u could set the type for both
Can you give me an example please?
question
i made a command that should have notified ppl with these roles
but it doesn’t actually notify them in the command.. is that normal?
Its been awhile since I've done bot development.
But I think bots are required to enable a mention when they send a message.
Lemme look into it real quick.
Also, how is it going mo? ^-^ getting comfortable with dev?
Can I see the send(...) code?
It’s actually going pretty good! I’m learning so much from @deft wolf !! I’ve gotten about 22 slash commands so far that all function how I need/want them to
yes 1 moment
awesome!
Intresting 👀
it was embedded at first, but i thought that was why it wasn’t notifying anyone, so i reverted it to plain text and it still isn’t notifying those roles 😭
It doesnt feel like you've done anything wrong here. Have you done other commands that mention people and it works?
let me try
it looks like it will notify users by their @mention, just not roles
my bot has admin/all perms toggled on
You might need to use allowed mentions.
^ take a look, if you need help ping me
npnp
hm
so basically
i would replace ${notifyUsers} with allowedMentions
@solemn latch correct?
well the entire line of course
You shouldn't need to modify any of the message variable
You just need to edit this line await interaction.reply(message);
ah ok i see
I've not used djs in so long, tbh I'm not entirely sure how this works.
ok i’m going to try it
ok so i’m seeing that notifying tagged roles in slash commands are limited on discord
that might be why lol
@solemn latch are you still awake? haha
I don't sleep ^-^
lol ok so I have a question, and if it’s going to be too much to help with i completely understand
so everything that I’ve been doing to create my bot and run it has been done on my macbook pro
so i took the same folder, uploaded it to google drive, and downloaded it on my windows PC. I know the paths are going to be different, but I remember you helped me correct the path when I first started this project
would you be able to walk me through it again? i can’t remember what you had me do
or is it a lot more complex than that? @solemn latch
It can require modifying paths sometimes when going between windows and mac(or Linux).
Sadly I can't help with that tonight
ok i gotcha, no worries! i had a feeling it was more complex than what i was thinking lol
Not something you need to worry about, but in the development world we have a program called docker.
It's the best worst thing ever, but it means when you write programs it can run on any system and act like they run on a specific OS.
Really neat for making sure whatever you're developing can be developed from any machine. Useful when working with multiple developers, or you want to be able to swap between your windows and mac machine.
Ah ok I gotcha, I’ll have to look into Docker
I’d look into using path.sep in some way shape or form
if this is nodejs
yes it’s nodejs
path.sep will give you the operating system specific file path separator
ok i can look into it
If you have any questions I can also help

Actually I lied, use path.join, path.sep gives you the platform specific separator, but its easier to just use join as it uses path.sep anyway.
ok i will research it a bit
i am extremely new to this by the way
like just started learning all of this 2 days ago
const path = path.join("whatever", "something") // /whatever/something unix or \whatever\something windows
All good
everyone starts somewhere
One place to never be afraid to ask for help in is top.gg
most of the people here are experienced and if not there are plenty of other people who are new just like you.
i've always used slash and they work just fine on both windows/linux
well
i wonder where it wouldn't work
they typically do work on windows, but sometimes it can cause issues
I've had cases where i'd use require statements and it'd not find the file/folder I was looking for because I was using slashes
i do have a question 😅
Go ahead and ask.
So I’m coding my bot with javascript with slashcommandbuilder in visual studio code





