I added a routine that automatically compiles GLLists, the same kind of thing Blitz3D does. Any command that changes a mesh also pokes a value of 1 to DEIMOS_ENTITY_CHANGED. If the rendering routine finds this value, it recompiles the mesh and pokes a value of 0, so that it doesn't get recompiled again.
From deimos\camera.bb:
Now it looks like GL vertex arrays are just pointers to vertex lists stored in order. That's easy, and they can be changed without recompiling the mesh.
What is the difference between GLDrawElements and GLDrawArrays?
From deimos\camera.bb:
Function RenderMesh(entity) list=PeekInt(entity,DEIMOS_ENTITY_GLLIST) ;If mesh has changed, recompile list If PeekInt(entity,DEIMOS_ENTITY_CHANGED) PokeInt entity,DEIMOS_ENTITY_CHANGED,0 ;delete old list If list glDeleteLists list,1 ;start new list list=glGenLists(1) glNewList list,GL_COMPILE bank=CreateBank(4) PokeInt bank,0,0 glGetIntegerv(GL_LIST_INDEX,bank) FreeBank bank PokeInt entity,DEIMOS_ENTITY_GLLIST,list ;Add all drawing commands to the list glBegin GL_TRIANGLES For t=1 To CountTriangles(entity) For c=1 To 3 geometryvertex=TriangleVertex(entity,t,c,0) colorvertex=TriangleVertex(entity,t,c,1) normalvertex=TriangleVertex(entity,t,c,2) x#=VertexX(entity,geometryvertex) y#=VertexY(entity,geometryvertex) z#=VertexZ(entity,geometryvertex) vr#=VertexX(entity,colorvertex,1)/255.0 vg#=VertexY(entity,colorvertex,1)/255.0 vb#=VertexZ(entity,colorvertex,1)/255.0 glColor3f vr,vg,vb glVertex3f x,y,z Next Next glEnd glEndList EndIf ;Call gllist (actual drawing) glPushMatrix BuildCoordinateSystem(entity) glCallList list glPopMatrix
Now it looks like GL vertex arrays are just pointers to vertex lists stored in order. That's easy, and they can be changed without recompiling the mesh.
What is the difference between GLDrawElements and GLDrawArrays?