Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dopeflow

OpenGL Few questions on opengl's vertex arrays

This topic is 5532 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

1. Is there a limit to how many arrays you can make/use? I have a mesh manager so memory is optimized in a way already, but say I have 100 different mesh type each with its own array that will be fine? 2. Im using md2 for mesh format. So I will need to store each animation frame info into the array as well. Is it possible to pass the beginning index of the frame to glDrawElements (ie if frame 3 begins at index 600 of my array i would pass that and pass m_nbVertices long since all animation have the same vertices count. 3. What does glLockArrays and glUnlockArrays do exactly? is it useful to use them? 4. How do I use multiple array? I mean how to I pass from one array to the other. I did a quick test just now and my computer completely crashed, must have not loaded the array correctly. First mesh to render(terrain) ================================ glLockArraysEXT(0, vertXRes*vertYRes); glVertexPointer(3, GL_FLOAT, 0, posVB); glEnableClientState(GL_VERTEX_ARRAY); glDrawElements.... glUnlockArraysEXT; Second mesh to render ======================== glLockArraysEXT(0, m_numVertices); glVertexPointer(3, GL_FLOAT, 0, posVB); glEnableClientState(GL_VERTEX_ARRAY); glDrawElements(GL_TRIANGLES, m_numVertices, GL_UNSIGNED_INT, posVB); glUnlockArraysEXT; This will help me a lot if I figure these out, thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
First, try to use the normal vertex array function, not the compiled vertex array extension, and see if it works.

The size of the array shouldn''t matter, only that, of course, the more vertices, the more tiem to render them.

quote:

3. What does glLockArrays and glUnlockArrays do exactly? is it useful to use them?


They might speed up the things a little bit, but you can''t modify the content of those arrays if you do that.

Height Map Editor | Eternal Lands | Fast User Directory

Share this post


Link to post
Share on other sites
My application currently work if I only use 1 vertex array(ie only render the terrain) but if I try using multiple arrays (1 for the terrain and also render the meshes with an array) it crashes.

Dont need to modify the array ever. They will always be the same.

Thanks for your help, still need some answers though

Share this post


Link to post
Share on other sites
No, my terrain is an object and my mesh is another object, posVB is just the member variable to hold the array.

Share this post


Link to post
Share on other sites
Alright I dont crash now using glDrawArrays....but holy shit check that out lol

http://pages.infinit.net/mnok/wtf.jpg

Must be with the ways im building my array....although i think its fine.

Are you sure this is okay, I mean the order in which I call them and all?


glVertexPointer(3, GL_FLOAT, 0, posVB);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_TRIANGLES, 0, 3*m_numTriangles);
glDisableClientState(GL_VERTEX_ARRAY);

Share this post


Link to post
Share on other sites
Well thing is im loading my array with the same data I used before to render my mesh vertex per vertex (it works perfect that way), so the data is obviously good.

the data in vertexListPtr is good im certain of it.

posVB= new float[3*m_numVertices];

for(int i= 0; i < m_numVertices; i++)
{
posVB[3*i+0]= vertexListPtr[i ].x;
posVB[3*i+1]= vertexListPtr[i ].y;
posVB[3*i+2]= vertexListPtr[i ].z;
}

edit by ze: fixed code. Please people, don't use i as a loop counter when posting code.

[edited by - zealouselixir on April 30, 2003 12:02:17 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!