add profiler state for clearing the buffer
authorRalf Jung <post@ralfj.de>
Sun, 31 Mar 2013 14:00:21 +0000 (16:00 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 31 Mar 2013 14:00:21 +0000 (16:00 +0200)
gltest.cpp

index 0cae93287a6f021270c0f739a3f9a1a3ad519f9a..ff413afbd20a5c9665400f8ba12806d20b94d0b7 100644 (file)
@@ -34,8 +34,8 @@ static const GLfloat boxWidth = 0.045f;
 static const GLfloat boxSpeed = 1.25f; // per second
 
 // profiler
 static const GLfloat boxSpeed = 1.25f; // per second
 
 // profiler
-enum ProfilerState { statePreRender, stateDraw, statePresent, statePostRender, stateOutsideRender, numProfilerStates };
-static const char *profilerStateNames[numProfilerStates] = { "Pre-Render", "Drawing", "Presenting", "Post-Render", "Outside renderer"};
+enum ProfilerState { statePreRender, stateClear, stateDraw, statePresent, statePostRender, stateOutsideRender, numProfilerStates };
+static const char *profilerStateNames[numProfilerStates] = { "Pre-Render", "Clearing", "Drawing", "Presenting", "Post-Render", "Outside renderer"};
 
 // utility functions
 static double getTime()
 
 // utility functions
 static double getTime()
@@ -132,17 +132,20 @@ protected:
                }
                lastFrame = time;
                //////////////////////////////////////////////
                }
                lastFrame = time;
                //////////////////////////////////////////////
-               profilerTick(stateDraw);
+               profilerTick(stateClear);
                if (overdraw) {
                if (overdraw) {
-                       glBegin(GL_QUADS);
                        // clear manually
                        // clear manually
+                       glBegin(GL_QUADS);
                        glColor3f(0.0f, 0.0f, 0.0f);
                        drawRect(0, 0, 1, 1);
                        glColor3f(0.0f, 0.0f, 0.0f);
                        drawRect(0, 0, 1, 1);
+                       glEnd();
                }
                else {
                        glClear(GL_COLOR_BUFFER_BIT);
                }
                else {
                        glClear(GL_COLOR_BUFFER_BIT);
-                       glBegin(GL_QUADS);
                }
                }
+               //////////////////////////////////////////////
+               profilerTick(stateDraw);
+               glBegin(GL_QUADS);
                glColor3f(0.8f, 1.0f, 0.75f);
                drawRect(boxPos, 0, boxPos+boxWidth, 1);
                glEnd();
                glColor3f(0.8f, 1.0f, 0.75f);
                drawRect(boxPos, 0, boxPos+boxWidth, 1);
                glEnd();
@@ -183,8 +186,6 @@ private:
        double stateTime[numProfilerStates];
 };
 
        double stateTime[numProfilerStates];
 };
 
-
-
 int main(int argc, char ** argv)
 {
        // program options handling
 int main(int argc, char ** argv)
 {
        // program options handling