diff --git a/examples/OpenGL/OpenGLImmediateModeSupport.cpp b/examples/OpenGL/OpenGLImmediateModeSupport.cpp index d5d2d820..be795260 100644 --- a/examples/OpenGL/OpenGLImmediateModeSupport.cpp +++ b/examples/OpenGL/OpenGLImmediateModeSupport.cpp @@ -5,7 +5,7 @@ using namespace PolyVox; using namespace std; -void renderRegion(PolyVox::IndexedSurfacePatch& isp) +void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp) { const vector& vecVertices = isp.getVertices(); const vector& vecIndices = isp.getIndices(); diff --git a/examples/OpenGL/OpenGLImmediateModeSupport.h b/examples/OpenGL/OpenGLImmediateModeSupport.h index bd60a3e0..8dc0e56e 100644 --- a/examples/OpenGL/OpenGLImmediateModeSupport.h +++ b/examples/OpenGL/OpenGLImmediateModeSupport.h @@ -5,6 +5,6 @@ #include "glew/glew.h" -void renderRegion(PolyVox::IndexedSurfacePatch& isp); +void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp); #endif //__OpenGLExample_OpenGLImmediateModeSupport_H__ diff --git a/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp b/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp index 56af1818..d3099e96 100644 --- a/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp +++ b/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp @@ -95,4 +95,24 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(IndexedSurfacePatch& isp) glUnmapBuffer(GL_ARRAY_BUFFER); return result; +} + +void renderRegionVertexBufferObject(const OpenGLSurfacePatch& openGLSurfacePatch) +{ + glBindBuffer(GL_ARRAY_BUFFER, openGLSurfacePatch.vertexBuffer); + glVertexPointer(3, GL_FLOAT, 36, 0); + glNormalPointer(GL_FLOAT, 36, (GLvoid*)12); + glColorPointer(3, GL_FLOAT, 36, (GLvoid*)24); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, openGLSurfacePatch.indexBuffer); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + + glDrawElements(GL_TRIANGLES, openGLSurfacePatch.noOfIndices, GL_UNSIGNED_INT, 0); + + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); } \ No newline at end of file diff --git a/examples/OpenGL/OpenGLVertexBufferObjectSupport.h b/examples/OpenGL/OpenGLVertexBufferObjectSupport.h index 9d3d9a67..8a46523a 100644 --- a/examples/OpenGL/OpenGLVertexBufferObjectSupport.h +++ b/examples/OpenGL/OpenGLVertexBufferObjectSupport.h @@ -13,5 +13,6 @@ struct OpenGLSurfacePatch }; OpenGLSurfacePatch BuildOpenGLSurfacePatch(PolyVox::IndexedSurfacePatch& isp); +void renderRegionVertexBufferObject(const OpenGLSurfacePatch& openGLSurfacePatch); #endif //__OpenGLExample_OpenGLVertexBufferObjectSupport_H__ diff --git a/examples/OpenGL/main.cpp b/examples/OpenGL/main.cpp index fefbf2e6..919de584 100644 --- a/examples/OpenGL/main.cpp +++ b/examples/OpenGL/main.cpp @@ -97,27 +97,12 @@ void display ( void ) // Create The Display Function { if(g_bUseOpenGLVertexBufferObjects) { - glBindBuffer(GL_ARRAY_BUFFER, g_openGLSurfacePatches[uRegionX][uRegionY][uRegionZ].vertexBuffer); - glVertexPointer(3, GL_FLOAT, 36, 0); - glNormalPointer(GL_FLOAT, 36, (GLvoid*)12); - glColorPointer(3, GL_FLOAT, 36, (GLvoid*)24); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_openGLSurfacePatches[uRegionX][uRegionY][uRegionZ].indexBuffer); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - - glDrawElements(GL_TRIANGLES, g_openGLSurfacePatches[uRegionX][uRegionY][uRegionZ].noOfIndices, GL_UNSIGNED_INT, 0); - - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); + renderRegionVertexBufferObject(g_openGLSurfacePatches[uRegionX][uRegionY][uRegionZ]); } else { IndexedSurfacePatch* ispCurrent = g_indexedSurfacePatches[uRegionX][uRegionY][uRegionZ]; - renderRegion(*ispCurrent); + renderRegionImmediateMode(*ispCurrent); } } @@ -198,7 +183,7 @@ default: void main ( int argc, char** argv ) // Create Main Function For Bringing It All Together { - g_bUseOpenGLVertexBufferObjects = true; + g_bUseOpenGLVertexBufferObjects = false; glutInit ( &argc, argv ); // Erm Just Write It =) glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE ); // Display Mode glutInitWindowSize ( 500, 500 ); // If glutFullScreen wasn't called this is the window size