=== modified file 'mesh.cpp'
@@ -21,7 +21,6 @@
Mesh::~Mesh()
{
delete [] mVertex;
- glDeleteLists(1, mBuildList);
//deleteArray
}
@@ -130,48 +129,22 @@
}
}
-void Mesh::render()
-{
- glBegin(mMode);
- glColor3f(1.0f, 0.0f, 0.0f);
- for(unsigned i = 0; i < mVertexQty; i++)
- {
- glNormal3f(mVertex[i].n.x, mVertex[i].n.y, mVertex[i].n.z);
- glTexCoord2f(mVertex[i].t.u, mVertex[i].t.v);
- glVertex3f(mVertex[i].v.x, mVertex[i].v.y, mVertex[i].v.z);
- }
- glEnd();
-}
-
void Mesh::render_array()
{
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &mVertex[0].v.x);
glNormalPointer(GL_FLOAT, sizeof(Vertex), &mVertex[0].n.x);
+ glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &mVertex[0].t.u);
glDrawArrays(mMode, 0, mVertexQty);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
}
-void Mesh::build_list()
-{
-#ifdef _DEBUG
- printf("Building list for mesh... ");
-#endif
-
- mBuildList = glGenLists(1);
- glNewList(mBuildList, GL_COMPILE);
- render();
- glEndList();
-
-#ifdef _DEBUG
- printf("[ Done ]\n");
-#endif
-}
-
void Mesh::build_vbo()
{
#ifdef _DEBUG
@@ -225,16 +198,20 @@
{
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBONormals);
glNormalPointer(GL_FLOAT, 0, 0);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOVertices);
glVertexPointer(3, GL_FLOAT, 0, 0);
+ glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVBOTexCoords);
+ glTexCoordPointer(2, GL_FLOAT, 0, 0);
glDrawArrays(GL_TRIANGLES, 0, mVertexQty);
glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
=== modified file 'mesh.h'
@@ -34,20 +34,16 @@
GLenum mMode; // Polygon mode, eg GL_QUADS, GL_TRIANGLES etc...
Vertex *mVertex; // Storage for the verticies
- GLuint mBuildList; // Build list name
-
- GLuint mVBOVertices; // Vertex VBO name
- GLuint mVBONormals; // Texture coordinate VBO name
- GLuint mVBOTexCoords; // Texture coordinate VBO name
+ GLuint mVBOVertices; // Vertex VBO name
+ GLuint mVBONormals; // Texture coordinate VBO name
+ GLuint mVBOTexCoords; // Texture coordinate VBO name
Mesh(); // Default Constructor, should set pointers to null
~Mesh();
void make_cube();
void make_torus();
- void render();
void render_array();
- void build_list();
void build_vbo();
void render_vbo();
};
=== modified file 'scenebuild.cpp'
@@ -10,14 +10,13 @@
model.calculate_normals();
model.convert_to_mesh(&mMesh);
- mMesh.build_list();
mMesh.build_vbo();
mRotationSpeed = 36.0f;
mRunning = false;
- mPartsQty = 4;
+ mPartsQty = 2;
mPartDuration = new double[mPartsQty];
mAverageFPS = new unsigned[mPartsQty];
mScoreScale = new float[mPartsQty];
@@ -72,16 +71,9 @@
switch(mCurrentPart)
{
case 0:
- printf("Precompilation\n");
- printf(" No Precompilation FPS: %u\n", mAverageFPS[mCurrentPart]);
+ printf(" Vertex array FPS: %u\n", mAverageFPS[mCurrentPart]);
break;
case 1:
- printf(" Build list FPS: %u\n", mAverageFPS[mCurrentPart]);
- break;
- case 2:
- printf(" Vertex array FPS: %u\n", mAverageFPS[mCurrentPart]);
- break;
- case 3:
printf(" Vertex buffer object FPS: %u\n", mAverageFPS[mCurrentPart]);
break;
}
@@ -106,14 +98,9 @@
switch(mCurrentPart)
{
case 0:
- mMesh.render();
+ mMesh.render_array();
break;
case 1:
- glCallList(mMesh.mBuildList);
- case 2:
- mMesh.render_array();
- break;
- case 3:
mMesh.render_vbo();
break;
}
=== modified file 'scenetexture.cpp'
@@ -18,7 +18,7 @@
model.calculate_normals();
model.convert_to_mesh(&mCubeMesh);
- mCubeMesh.build_list();
+ mCubeMesh.build_vbo();
mRotationSpeed = Vector3f(36.0f, 36.0f, 36.0f);
@@ -114,14 +114,14 @@
{
case 0:
glBindTexture(GL_TEXTURE_2D, mTexture[0]);
- glCallList(mCubeMesh.mBuildList);
+ mCubeMesh.render_vbo();
break;
case 1:
glBindTexture(GL_TEXTURE_2D, mTexture[1]);
- glCallList(mCubeMesh.mBuildList);
+ mCubeMesh.render_vbo();
case 2:
glBindTexture(GL_TEXTURE_2D, mTexture[2]);
- glCallList(mCubeMesh.mBuildList);
+ mCubeMesh.render_vbo();
break;
}
}