Few questions on opengl's vertex arrays

Started by
11 comments, last by dopeflow 20 years, 11 months ago
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!
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
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
You should use glDrawArrays instead...
Anyway, you are aware that both your meshes point to posVB , right?

Height Map Editor | Eternal Lands | Fast User Directory
No, my terrain is an object and my mesh is another object, posVB is just the member variable to hold the array.
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);
Try them in this order:

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

Height Map Editor | Eternal Lands | Fast User Directory
Ok, no didnt change anything, so I guess Im not setting the array correctly.
Yep, you did something wrong.
Try to put a cube, or something simple, in that array.

Height Map Editor | Eternal Lands | Fast User Directory
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.x;<br>posVB[3*i+1]= vertexListPtr.y;<br>posVB[3*i+2]= vertexListPtr.z;<br>}<br><br><b>edit</b> by ze: fixed code. Please people, don't use i as a loop counter when posting code.<br><br><SPAN CLASS=editedby>[edited by - zealouselixir &#111;n April 30, 2003 12:02:17 AM]</SPAN>

This topic is closed to new replies.

Advertisement