- refactor

Mon, 10 Mar 2014 14:12:28 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 10 Mar 2014 14:12:28 +0200
changeset 698
16e6d7d87982
parent 697
2766f7b037ad
child 699
aca63a3cce36

- refactor

src/GLCompiler.cc file | annotate | diff | comparison | revisions
src/GLCompiler.h file | annotate | diff | comparison | revisions
src/GLShared.h file | annotate | diff | comparison | revisions
src/Macros.h file | annotate | diff | comparison | revisions
--- a/src/GLCompiler.cc	Mon Mar 10 13:26:02 2014 +0200
+++ b/src/GLCompiler.cc	Mon Mar 10 14:12:28 2014 +0200
@@ -46,9 +46,9 @@
 #define DEBUG_PRINT(...) fprint (stdout, __VA_ARGS__)
 
 extern_cfg (Bool, gl_blackedges);
-static QList<short>		gWarnedColors;
-static const QColor		gBFCFrontColor (40, 192, 40);
-static const QColor		gBFCBackColor (224, 40, 40);
+static QList<short>		g_warnedColors;
+static const QColor		g_BFCFrontColor (40, 192, 40);
+static const QColor		g_BFCBackColor (224, 40, 40);
 
 // =============================================================================
 //
@@ -77,14 +77,14 @@
 GLCompiler::GLCompiler()
 {
 	needMerge();
-	memset (mVBOSizes, 0, sizeof mVBOSizes);
+	memset (m_VBOSizes, 0, sizeof m_VBOSizes);
 }
 
 // =============================================================================
 //
 void GLCompiler::initialize()
 {
-	glGenBuffers (gNumVBOs, &mVBOs[0]);
+	glGenBuffers (g_numVBOs, &mVBOs[0]);
 	checkGLError();
 }
 
@@ -92,7 +92,7 @@
 //
 GLCompiler::~GLCompiler()
 {
-	glDeleteBuffers (gNumVBOs, &mVBOs[0]);
+	glDeleteBuffers (g_numVBOs, &mVBOs[0]);
 	checkGLError();
 }
 
@@ -150,18 +150,18 @@
 	{
 		// The color was unknown. Use main color to make the poly.object at least
 		// not appear pitch-black.
-		if (poly.color != edgecolor)
+		if (poly.num != 2 && poly.num != 5)
 			qcol = GLRenderer::getMainColor();
 		else
 			qcol = Qt::black;
 
 		// Warn about the unknown color, but only once.
-		for (short i : gWarnedColors)
-			if (poly.color == i)
-				return qcol;
+		if (g_warnedColors.contains (poly.color) == false)
+		{
+			print ("Unknown color %1!\n", poly.color);
+			g_warnedColors << poly.color;
+		}
 
-		print ("%1: Unknown color %2!\n", __func__, poly.color);
-		gWarnedColors << poly.color;
 		return qcol;
 	}
 
@@ -181,10 +181,8 @@
 //
 void GLCompiler::needMerge()
 {
-	// Set all of mChanged to true
-	// memset (mChanged, 0xFF, sizeof mChanged);
-	for (int i = 0; i < ((int) (sizeof mChanged / sizeof *mChanged)); ++i)
-		mChanged[i] = true;
+	for (int i = 0; i < countof (m_vboChanged); ++i)
+		m_vboChanged[i] = true;
 }
 
 // =============================================================================
@@ -223,7 +221,7 @@
 	// Compile anything that still awaits it
 	compileStaged();
 
-	if (mChanged[vbonum] == false)
+	if (m_vboChanged[vbonum] == false)
 		return;
 
 	QVector<GLfloat> vbodata;
@@ -238,8 +236,8 @@
 	glBufferData (GL_ARRAY_BUFFER, vbodata.size() * sizeof(GLfloat), vbodata.constData(), GL_DYNAMIC_DRAW);
 	glBindBuffer (GL_ARRAY_BUFFER, 0);
 	checkGLError();
-	mChanged[vbonum] = false;
-	mVBOSizes[vbonum] = vbodata.size();
+	m_vboChanged[vbonum] = false;
+	m_VBOSizes[vbonum] = vbodata.size();
 }
 
 // =============================================================================
@@ -321,13 +319,13 @@
 
 				case vboBFCFrontColors:
 				{
-					writeColor (vbodata, gBFCFrontColor);
+					writeColor (vbodata, g_BFCFrontColor);
 					break;
 				}
 
 				case vboBFCBackColors:
 				{
-					writeColor (vbodata, gBFCBackColor);
+					writeColor (vbodata, g_BFCBackColor);
 					break;
 				}
 
--- a/src/GLCompiler.h	Mon Mar 10 13:26:02 2014 +0200
+++ b/src/GLCompiler.h	Mon Mar 10 14:12:28 2014 +0200
@@ -31,7 +31,7 @@
 	public:
 		struct ObjectVBOInfo
 		{
-			QVector<GLfloat> data[gNumVBOs];
+			QVector<GLfloat> data[g_numVBOs];
 		};
 
 		GLCompiler();
@@ -59,7 +59,7 @@
 
 		inline int			getVBOCount (int vbonum) const
 		{
-			return mVBOSizes[vbonum] / 3;
+			return m_VBOSizes[vbonum] / 3;
 		}
 
 	private:
@@ -71,9 +71,9 @@
 
 		QMap<LDObject*, ObjectVBOInfo>		mObjectInfo;
 		LDObjectList						mStaged; // Objects that need to be compiled
-		GLuint								mVBOs[gNumVBOs];
-		bool								mChanged[gNumVBOs];
-		int									mVBOSizes[gNumVBOs];
+		GLuint								mVBOs[g_numVBOs];
+		bool								m_vboChanged[g_numVBOs];
+		int									m_VBOSizes[g_numVBOs];
 };
 
 #define checkGLError() { checkGLError_private (__FILE__, __LINE__); }
--- a/src/GLShared.h	Mon Mar 10 13:26:02 2014 +0200
+++ b/src/GLShared.h	Mon Mar 10 14:12:28 2014 +0200
@@ -65,6 +65,6 @@
 void glBufferData (GLuint, GLuint, void*, GLuint);
 #endif
 
-static const int gNumVBOs = vboNumSurfaces * vboNumComplements;
+static const int g_numVBOs = vboNumSurfaces * vboNumComplements;
 
 #endif // LDFORGE_GLSHARED_H
\ No newline at end of file
--- a/src/Macros.h	Mon Mar 10 13:26:02 2014 +0200
+++ b/src/Macros.h	Mon Mar 10 14:12:28 2014 +0200
@@ -22,6 +22,8 @@
 # define __attribute__(X)
 #endif
 
+#define countof(A) ((int) (sizeof A / sizeof *A))
+
 // =============================================================================
 //
 #define PROPERTY(ACCESS, TYPE, READ, WRITE, WRITETYPE)			\

mercurial