Skip to main content
gamedev.net
🔒 Locked

Vertex Array Question

Started by Kris2456 Oct 16, 2004 at 6:53 AM 2 replies 600+ views
Original Post
Kris2456
Kris2456
Hello, i am working on a .OBJ file loader so i get the hang of model loading. I plan to use vertex arrays in my model loader so that things are drawn faster, but theres one thing i dont understand. Heres my problem: I have two functions, one for loading the file, and one for drawing. The one that loads packs the data into a vertex array, and the one that draws, well... draws it. To enable arrays i have to use glEnableClientState(). So in my load function i want to have:

//in load function
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

...Pack stuff into array....

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);



//In draw function
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

...Draw stuff from array....

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

Its just that im not sure if disabling the client state before drawing will work. I've never used arrays before. So is it possible?
------------ "Here lies a toppled God,His fall was not a small one,We but built his pedastle,A narrow, and a tall one" Frank Herbert (Dune:Messiah)
CRACK123
CRACK123
You should do the rendering totaly in render/draw function in my opinion.

void Draw(){    glEnableClientState(GL_VERTEX_ARRAY);    glVertexPointer(...);    glEnableClientState(GL_NORMAL_ARRAY);    glNormalPointer(...);    glEnableClientState(GL_TEXTURE_COORD_ARRAY);    glTexCoordPointer(...);    glDrawElements(....);        glDisableClientState(GL_VERTEX_ARRAY);    glDisableClientState(GL_NORMAL_ARRAY);    glDisableClientState(GL_TEXTURE_COORD_ARRAY);}


In load function just build the vertices/normals/textures etc. No need to call glEnableClientState or glDisableClientState.




The more applications I write, more I find out how less I know
Kris2456
Kris2456
Wouldnt that be a lot more proccessing?
------------ "Here lies a toppled God,His fall was not a small one,We but built his pedastle,A narrow, and a tall one" Frank Herbert (Dune:Messiah)
zedzeek
zedzeek
these commands //in load function
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

...Pack stuff into array....

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

only make a difference if youre drawing something thus dont stick them in the loading code

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.