Whatis your typical Vertex Range?

Started by
10 comments, last by Paradigm Shifter 17 years, 1 month ago
Hi, Im currently coding a game engine and i've come to Object code.. Anyway becase Devcpp can't handle unlimited arrays ( The Memory runs into eachother (with big arrays) and causes the exe to crash ) i have had to set a Vertex Limit for each object. Im Not rrly sure what i should set the limit to be.... What would you say is the suggested Maximum Vertex Number? Its Really annoying That i have to set a limit, because this means the objects are runnign inneficiently because it uses the memory space no matter what :( anyone know how to get around this in Devcpp then that would be even better !! oh and finaly does anyone know any (or where to see these )algorthms to load in common 3D files like .x etc... (into opengl) im not really sure as to the structure of these files. My Code is working,but i have to define the Vertex.. and a game engine where you can't laod in a 3d file would be a bit boring :P Thanks, BEN
Advertisement
so how big are these arrays that crash devc++?
if the elements are more than a 10 bytes you may want to create a array of pointers to elements.
Im not entirely sure what your asking in the rest of your question, mabey if you could provide some more detail.
basicaly i have a class for vertex's
each vertex contains x,y,z co-ordinates

the object class coinaints vertec so ist a bit like

class OBject
{
public:
vertex[];
};

when i do that itusualy crashes if i load with vertex > than say 20. However if i do :


class OBject
{
public:
vertex[0xFFF];
};

then i can have ip to 0xFFF vertex and it wont crash.. but as you can see its inneficient, because the ememory is wasted really....


and i meant like opening the file and knowing where the different stuff is stored like Vertex data in each file etc... so i can load this into OpenGl with glvertex() etc..
-BEN
in c++ arrays arnt automatically created unless you specify a starting size or resized, if you write to a uninitialized array you just writing to a random point in memory
this dosent seem to be correct c++ syntax so its still hard to understand, i also dont understand why your using hex in it

// a 20 element array
int a[20];

//a uninitialized array
int b[];
//same
int *b;

//this write to a random point in memeory and will crash your app
b[5]=45;

//so does this
a[25]=5555;

//this is fine
a[14]=4;

//this is how you do it
//create 60 element array
b= new int[60];
//now this is ok
b[59]=56;

//hex gets treated as a normal number
//4095 long array
int d[0xFFF];
I used hex because writing 0xFFFF was easier than writing 65535 lol.
Yeah i know thats why i have used a massive array meaning thatonly 65535 vertexs can be lioaded. What i meant is, i was alking to my teacher about this and he sed theres a godo way to egtaround it, but he couldnt remember how to do it. He sed it was like destroyign and recreating the array each time or something liek that . Not Much help really :P.

-BEN
He was probably talking about dynamically creating arrays, which is what Kaze was demostrating in the last portion of his code.

Basically, you get a pointer to whatever datatype you want:
int arraySize = 1000;int * someArray = NULL; 

Then you set it to a block of memory using the new operator
someArray = new int[arraySize];

Now you can use the variable someArray just like you would any array, but you didn't have to hard code in the size.
Destroying the array is as simple as calling delete on the pointer.
delete someArray;



EDIT:: How do you use the quote tags? =/

[size=1]Visit my website, rawrrawr.com

thanks.

Hmmm hwo would i use that with the classes though??
say i have these classes

class Vertex
{
public:
float x,y,z;
}

class OB
{
public:
Vertex Vertex[0xFF]
}

because the way he said it worked, is that when the end of the array si reached it destroys the array and recreates it with +1 size.

Thanks,
BEN

ps Don't Know :p
I also use Devc++, and asked a similar question years ago to get no responce. I dynamically allocate, and get the same problem.
_______________ Play my Game at neonswarm.com
yeah its a bit of a bitch, im not too btohered really im sure ill find a solution to the problem eventually but for now i just want to know what si the typuical range of vertex in models... but no one has answered that 1 yet :P although i would be happy to knwo how to do the destrucion and restruction of arrays though :P but mainly i justwanna know what a goo maximum value is
Quote:Original post by BENOJ
yeah its a bit of a bitch, im not too btohered really im sure ill find a solution to the problem eventually but for now i just want to know what si the typuical range of vertex in models... but no one has answered that 1 yet :P although i would be happy to knwo how to do the destrucion and restruction of arrays though :P but mainly i justwanna know what a goo maximum value is

just a hint, spell check and proof reading might give you more relevant replies

This topic is closed to new replies.

Advertisement