From e786bcdc61657e4b2e2cae4bf6f44bb70a14587a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 7 Apr 2014 12:01:47 +0300 Subject: Add support for OpenGL extension GL_GREMEDY_frame_terminator. It allow show to debugger where is frame termination. --- src/graphicsmanager.cpp | 6 ++++++ src/localconsts.h | 3 +++ src/render/mgl.cpp | 1 + src/render/mgl.h | 2 ++ src/render/mobileopenglgraphics.cpp | 6 ++++++ src/render/normalopenglgraphics.cpp | 6 ++++++ src/render/safeopenglgraphics.cpp | 6 ++++++ 7 files changed, 30 insertions(+) diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index b40f8df57..d158527e1 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -816,6 +816,12 @@ void GraphicsManager::initOpenGLFunctions() mSupportDebug = 0; } + if (supportExtension("GL_GREMEDY_frame_terminator")) + { + logger->log1("found GL_GREMEDY_frame_terminator"); + assignFunction(glFrameTerminator, "glFrameTerminatorGREMEDY"); + } + #ifdef WIN32 assignFunction(wglGetExtensionsString, "wglGetExtensionsStringARB"); #endif diff --git a/src/localconsts.h b/src/localconsts.h index d71126c11..05d3909e4 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -112,6 +112,9 @@ // use file access fuzzer // #define USE_FUZZER 1 +// use OpenGL debug features +#define DEBUG_OPENGL 1 + #ifdef DYECMD #undef USE_FUZZER #endif diff --git a/src/render/mgl.cpp b/src/render/mgl.cpp index 54845b944..bd67c2f0e 100644 --- a/src/render/mgl.cpp +++ b/src/render/mgl.cpp @@ -42,6 +42,7 @@ defName(glBindSampler); defName(glSamplerParameteri); defName(glDebugMessageControl); defName(glDebugMessageCallback); +defName(glFrameTerminator); #ifdef WIN32 defName(wglGetExtensionsString); diff --git a/src/render/mgl.h b/src/render/mgl.h index a47a70218..e2e710029 100644 --- a/src/render/mgl.h +++ b/src/render/mgl.h @@ -99,6 +99,7 @@ typedef void (APIENTRY *glSamplerParameteri_t) (GLuint sampler, GLenum pname, GLint param); typedef void (APIENTRY *glDebugMessageControl_t) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); +typedef void (APIENTRY *glFrameTerminator_t) (void); // callback typedef void (APIENTRY *GLDEBUGPROC_t) (GLenum source, GLenum type, GLuint id, @@ -123,6 +124,7 @@ defNameE(glBindSampler); defNameE(glSamplerParameteri); defNameE(glDebugMessageControl); defNameE(glDebugMessageCallback); +defNameE(glFrameTerminator); #ifdef WIN32 typedef const char* (APIENTRY * wglGetExtensionsString_t) (HDC hdc); diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index 0ad5bfeb7..ede89f115 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -31,6 +31,8 @@ #include "graphicsvertexes.h" #include "logger.h" +#include "render/mgl.h" + #include "resources/image.h" #include "resources/openglimagehelper.h" @@ -834,6 +836,10 @@ void MobileOpenGLGraphics::updateScreen() #else SDL_GL_SwapBuffers(); #endif +#ifdef DEBUG_OPENGL + if (mglFrameTerminator) + mglFrameTerminator(); +#endif // may be need clear? // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); BLOCK_END("Graphics::updateScreen") diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index 72fbd8a99..8f3659936 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -30,6 +30,8 @@ #include "graphicsvertexes.h" #include "logger.h" +#include "render/mgl.h" + #include "resources/image.h" #include "resources/openglimagehelper.h" @@ -1095,6 +1097,10 @@ void NormalOpenGLGraphics::updateScreen() #else SDL_GL_SwapBuffers(); #endif +#ifdef DEBUG_OPENGL + if (mglFrameTerminator) + mglFrameTerminator(); +#endif // may be need clear? // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); BLOCK_END("Graphics::updateScreen") diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index a191142b5..177cfecb5 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -28,6 +28,8 @@ #include "configuration.h" #include "graphicsmanager.h" +#include "render/mgl.h" + #include "resources/image.h" #include "resources/openglimagehelper.h" @@ -420,6 +422,10 @@ void SafeOpenGLGraphics::updateScreen() SDL_GL_SwapWindow(mWindow); #else SDL_GL_SwapBuffers(); +#endif +#ifdef DEBUG_OPENGL + if (mglFrameTerminator) + mglFrameTerminator(); #endif BLOCK_END("Graphics::updateScreen") } -- cgit v1.2.3-60-g2f50