From a6ec94bcb6af26bc9b6483b89a8b2397a9c8bef9 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 31 Mar 2013 16:00:21 +0200 Subject: [PATCH] add profiler state for clearing the buffer --- gltest.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gltest.cpp b/gltest.cpp index 0cae932..ff413af 100644 --- a/gltest.cpp +++ b/gltest.cpp @@ -34,8 +34,8 @@ static const GLfloat boxWidth = 0.045f; 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() @@ -132,17 +132,20 @@ protected: } lastFrame = time; ////////////////////////////////////////////// - profilerTick(stateDraw); + profilerTick(stateClear); if (overdraw) { - glBegin(GL_QUADS); // clear manually + glBegin(GL_QUADS); glColor3f(0.0f, 0.0f, 0.0f); drawRect(0, 0, 1, 1); + glEnd(); } 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(); @@ -183,8 +186,6 @@ private: double stateTime[numProfilerStates]; }; - - int main(int argc, char ** argv) { // program options handling -- 2.30.2