diff --git a/include/shadertoy/RenderContext.hpp b/include/shadertoy/RenderContext.hpp index 92e889cbf2b68789d280bba86e223187f07c3f25..2afcfc1e23438812825f9b6fcd9675a21d8e6862 100644 --- a/include/shadertoy/RenderContext.hpp +++ b/include/shadertoy/RenderContext.hpp @@ -240,6 +240,14 @@ public: */ void RenderScreenQuad(); + /** + * @brief Render a screen quad using the current context + * + * @param timerQuery Query object to use for measuring the runtime of the + * draw call. + */ + void RenderScreenQuad(OpenGL::Query &timerQuery); + /** * @brief Binds the texture containing the shadertoy result as well as * a program which renders this texture to the viewport. Useful diff --git a/src/RenderContext.cpp b/src/RenderContext.cpp index 9099fffce769e6b79d1d76e55a7035dbedfc66d7..84748a453f8253709bb44ab0398d384478e5ac0c 100644 --- a/src/RenderContext.cpp +++ b/src/RenderContext.cpp @@ -382,6 +382,17 @@ void RenderContext::RenderScreenQuad() glCall(glDrawElements, GL_TRIANGLES, 3 * 2, GL_UNSIGNED_INT, nullptr); } +void RenderContext::RenderScreenQuad(OpenGL::Query &timerQuery) +{ + screenQuadCorners.Bind(GL_ARRAY_BUFFER); + + timerQuery.Begin(GL_TIME_ELAPSED); + + glCall(glDrawElements, GL_TRIANGLES, 3 * 2, GL_UNSIGNED_INT, nullptr); + + timerQuery.End(GL_TIME_ELAPSED); +} + void RenderContext::BindResult() { // Prepare prog and texture diff --git a/src/ToyBuffer.cpp b/src/ToyBuffer.cpp index 1f38d0ce498266d849eecb96154e566fdd941a1e..1a222c8da75caffd084bdfaffd3a4bed5e0c77a0 100644 --- a/src/ToyBuffer.cpp +++ b/src/ToyBuffer.cpp @@ -161,14 +161,8 @@ void ToyBuffer::Render() for (auto &inputs : boundInputs) inputs->Apply(); - // Start query measurement - timeDeltaQuery.Begin(GL_TIME_ELAPSED); - // Render the program - context.RenderScreenQuad(); - - // End query measurement - timeDeltaQuery.End(GL_TIME_ELAPSED); + context.RenderScreenQuad(timeDeltaQuery); // Swap texture object pointers swap(sourceTex, targetTex);