Simplified GLCompiler vbo interface

Mon, 06 Mar 2017 11:48:45 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 06 Mar 2017 11:48:45 +0200
changeset 1201
a3455a81c5c9
parent 1200
64d0a379266f
child 1202
f2d1f2975340

Simplified GLCompiler vbo interface

src/glcompiler.cpp file | annotate | diff | comparison | revisions
src/glcompiler.h file | annotate | diff | comparison | revisions
src/glrenderer.cpp file | annotate | diff | comparison | revisions
--- 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<int>(surface) * EnumLimits<VboSubclass>::Count) + static_cast<int>(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;
 }
 
 /*
--- 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<LDObject*, ObjectVboData>	m_objectInfo;
 	QSet<LDObject*> m_staged; // Objects that need to be compiled
 	GLuint m_vbo[NumVbos];
--- 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)
 	{

mercurial