Good good...
I had to actaully switch to glDrawElements from glDrawArrays because I was having some kind of issues with accessing the Array Pointers.
Anyways, here's my surface render snippet in C using glDrawElements:
[The code thats rem'd out is actaully a successfull test that I did for doing vertex alpha.]
If I remmeber right, my problem with glDrawArrays is that I had to construct a "sequence" of primitives to use it for mesh building. ie: in blitz-like psuedo code:
I wasn't able to just use four vertices and two triangles like I can with glDrawElements. With glDrawElements, I can construct any way I want to just like using the blitz mesh building commands. ie: for a quad:
About glLists. I would only use them for static meshs. Rebuilding a glList mesh like that whenever you change it's data, ie: vertex deformation, I would think causes a performance hit( even though I hadn't first handly tested what kind a performance hit it would cause ).
With glDrawElements, you can change any data of your mesh on the fly without "rebuilding" the whole mesh.
--------
About Alpha Polys: We're going to need some kind of "second list of surfaces" for a second render pass for any vertex, surface or whole mesh that contains alpha in them. A common opengl example of rendering alpha polys is to render all solid polys first, disable the zbuffer write, then render all alpha polys. I hadn't yet gotten this far in my dll library, but that's how I'm going to approach it. I can't remmeber off the top of my head if an alpha poly z-sorting routine is needed in this case or not.
I had to actaully switch to glDrawElements from glDrawArrays because I was having some kind of issues with accessing the Array Pointers.
Anyways, here's my surface render snippet in C using glDrawElements:
if(ThisSurface->texID[0]>0) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,ThisSurface->texID[0]); } else { glDisable(GL_TEXTURE_2D); } //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); //glEnable(GL_BLEND); // Turn Blending On //glDisable(GL_DEPTH_TEST); // Turn Depth Testing Off glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_NORMAL_ARRAY ); glEnableClientState( GL_COLOR_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glVertexPointer( 3, GL_FLOAT, sizeof(SurfaceVertex), &ThisSurface->thisVertex[0]); glNormalPointer( GL_FLOAT, sizeof(SurfaceVertexNormal), &ThisSurface->thisVertexNormal[0]); glColorPointer( 4, GL_FLOAT, sizeof(SurfaceVertexColor), &ThisSurface->thisVertexColor[0]); glTexCoordPointer( 2, GL_FLOAT, sizeof(SurfaceVertexTexCoord0), &ThisSurface->thisVertexTexCoord0[0]); glDrawElements ( GL_TRIANGLES, ThisSurface->thisTriIndices.size()*3, GL_UNSIGNED_INT, &ThisSurface->thisTriIndices[0] ); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); glDisableClientState( GL_COLOR_ARRAY ); glDisableClientState( GL_NORMAL_ARRAY ); glDisableClientState( GL_VERTEX_ARRAY ); //glDisable(GL_BLEND); // Turn Blending Off //glEnable(GL_DEPTH_TEST); // Turn Depth Testing On if(ThisSurface->texID[0]>0) { glDisable(GL_TEXTURE_2D); }
[The code thats rem'd out is actaully a successfull test that I did for doing vertex alpha.]
If I remmeber right, my problem with glDrawArrays is that I had to construct a "sequence" of primitives to use it for mesh building. ie: in blitz-like psuedo code:
v0=addvertex(thisSurface,x#,y#,z#) v1=addvertex(thisSurface,x#,y#,z#) v2=addvertex(thisSurface,x#,y#,z#) v3=addvertex(thisSurface,x#,y#,z#) v4=addvertex(thisSurface,x#,y#,z#) v5=addvertex(thisSurface,x#,y#,z#) addtriangle(v0,v1,v2) addtriangle(v3,v4,v5)
I wasn't able to just use four vertices and two triangles like I can with glDrawElements. With glDrawElements, I can construct any way I want to just like using the blitz mesh building commands. ie: for a quad:
v0=addvertex(thisSurface,x#,y#,z#) v1=addvertex(thisSurface,x#,y#,z#) v2=addvertex(thisSurface,x#,y#,z#) v3=addvertex(thisSurface,x#,y#,z#) addtriangle(v2,v0,v1) addtriangle(v2,v1,v3)
About glLists. I would only use them for static meshs. Rebuilding a glList mesh like that whenever you change it's data, ie: vertex deformation, I would think causes a performance hit( even though I hadn't first handly tested what kind a performance hit it would cause ).
With glDrawElements, you can change any data of your mesh on the fly without "rebuilding" the whole mesh.
--------
About Alpha Polys: We're going to need some kind of "second list of surfaces" for a second render pass for any vertex, surface or whole mesh that contains alpha in them. A common opengl example of rendering alpha polys is to render all solid polys first, disable the zbuffer write, then render all alpha polys. I hadn't yet gotten this far in my dll library, but that's how I'm going to approach it. I can't remmeber off the top of my head if an alpha poly z-sorting routine is needed in this case or not.