# HG changeset patch # User Teemu Piippo # Date 1488793725 -7200 # Node ID a3455a81c5c9f65fcf67efa17d678a3a36eca62c # Parent 64d0a379266f61d3aaf515b8b1f8e848c363dd51 Simplified GLCompiler vbo interface diff -r 64d0a379266f -r a3455a81c5c9 src/glcompiler.cpp --- a/src/glcompiler.cpp Mon Mar 06 01:17:15 2017 +0200 +++ b/src/glcompiler.cpp Mon Mar 06 11:48:45 2017 +0200 @@ -432,21 +432,23 @@ } } -int GLCompiler::vboNumber (VboClass surface, VboSubclass complement) +int GLCompiler::vboNumber(VboClass surface, VboSubclass complement) { return (static_cast(surface) * EnumLimits::Count) + static_cast(complement); } - -GLuint GLCompiler::vbo (int vbonum) const +GLuint GLCompiler::vbo(VboClass surface, VboSubclass complement) { - return m_vbo[vbonum]; + int index = vboNumber(surface, complement); + prepareVBO(index); + return m_vbo[index]; } -int GLCompiler::vboSize (int vbonum) const +int GLCompiler::vboSize(VboClass surface) const { - return m_vboSizes[vbonum]; + int index = vboNumber(surface, VboSubclass::Surfaces); + return m_vboSizes[index] / 3; } /* diff -r 64d0a379266f -r a3455a81c5c9 src/glcompiler.h --- a/src/glcompiler.h Mon Mar 06 01:17:15 2017 +0200 +++ b/src/glcompiler.h Mon Mar 06 11:48:45 2017 +0200 @@ -34,12 +34,9 @@ GLCompiler (GLRenderer* renderer); ~GLCompiler(); - void initialize(); - void prepareVBO (int vbonum); - GLuint vbo (int vbonum) const; - int vboSize (int vbonum) const; - - static int vboNumber (VboClass surface, VboSubclass complement); + Q_SLOT void initialize(); + GLuint vbo (VboClass surface, VboSubclass complement); + int vboSize (VboClass surface) const; private: struct ObjectVboData @@ -57,8 +54,11 @@ void dropObjectInfo (LDObject* obj); Q_SLOT void forgetObject(LDObject* object); void stageForCompilation (LDObject* obj); + void prepareVBO (int vbonum); void unstage (LDObject* obj); + static int vboNumber (VboClass surface, VboSubclass complement); + QMap m_objectInfo; QSet m_staged; // Objects that need to be compiled GLuint m_vbo[NumVbos]; diff -r 64d0a379266f -r a3455a81c5c9 src/glrenderer.cpp --- a/src/glrenderer.cpp Mon Mar 06 01:17:15 2017 +0200 +++ b/src/glrenderer.cpp Mon Mar 06 11:48:45 2017 +0200 @@ -499,16 +499,10 @@ break; } - int surfaceVboNumber = m_compiler->vboNumber(surface, VboSubclass::Surfaces); - int colorVboNumber = m_compiler->vboNumber(surface, colors); - int normalVboNumber = m_compiler->vboNumber(surface, VboSubclass::Normals); - m_compiler->prepareVBO(surfaceVboNumber); - m_compiler->prepareVBO(colorVboNumber); - m_compiler->prepareVBO(normalVboNumber); - GLuint surfaceVbo = m_compiler->vbo(surfaceVboNumber); - GLuint colorVbo = m_compiler->vbo(colorVboNumber); - GLuint normalVbo = m_compiler->vbo(normalVboNumber); - GLsizei count = m_compiler->vboSize(surfaceVboNumber) / 3; + GLuint surfaceVbo = m_compiler->vbo(surface, VboSubclass::Surfaces); + GLuint colorVbo = m_compiler->vbo(surface, colors); + GLuint normalVbo = m_compiler->vbo(surface, VboSubclass::Normals); + GLsizei count = m_compiler->vboSize(surface); if (count > 0) {