From: Ralf Jung Date: Sun, 31 Mar 2013 14:00:21 +0000 (+0200) Subject: add profiler state for clearing the buffer X-Git-Url: https://git.ralfj.de/gltest.git/commitdiff_plain/a6ec94bcb6af26bc9b6483b89a8b2397a9c8bef9?ds=sidebyside;hp=21689b45f8d7e28bd6be565758bec0205abb8416 add profiler state for clearing the buffer --- 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