Dinamic array question

BlitzMax Forums/BlitzMax Programming/Dinamic array question

Sanctus(Posted 2009) [#1]
I see in minib3d that is uses something like this
vert_col=vert_col[..vas*4]

this somehow resizes the array.

Might be a bit off topic but does anyone know how can one do this in c++?
I'm trying to implement a surface class in c++.(actually a full engine) and I'm sneak peaking at minib3d to see how it works :)


Gabriel(Posted 2009) [#2]
If you want more information on it in BlitzMax, look up "slicing" in the documentation.

In C++, when you want dynamic arrays, you would normally use std::vector.


Sanctus(Posted 2009) [#3]
isn't that slower than this?
int *vertices = new vertices[256]

I guess the best way would be to have a update method that takes elements from a list and puts them to a array.


Gabriel(Posted 2009) [#4]
I haven't tested, I would certainly imagine that allocating a new c array is faster than dynamically resizing a vector, but they're doing completely different things. You asked how to resize an existing array.


Sanctus(Posted 2009) [#5]
The thing is that it's more practical since if I'd use a vector then every time I'd draw something it will go trough the vector and that's slower.
If i create a new array when I call UpdateSurface then that would only be done then. And it's not like you add vertexes to a mesh each frame right?


Sanctus(Posted 2009) [#6]
The thing is that it's more practical since if I'd use a vector then every time I'd draw something it will go trough the vector and that's slower.
If i create a new array when I call UpdateSurface then that would only be done then. And it's not like you add vertexes to a mesh each frame right?