From fbe2896460a0fc7c1e52c4523fcf417264508f25 Mon Sep 17 00:00:00 2001 From: vlj Date: Tue, 9 Sep 2014 16:57:46 +0200 Subject: [PATCH] Use non debug gl ctx in non debug build --- .../source/Irrlicht/CIrrDeviceLinux.cpp | 35 ++++++++++--- .../source/Irrlicht/COpenGLDriver.cpp | 51 ++++++++++++++++--- src/graphics/glwrap.cpp | 6 +++ 3 files changed, 78 insertions(+), 14 deletions(-) diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp index b5423ca57..00353a264 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp @@ -3,6 +3,8 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h +extern bool GLContextDebugBit; + #include "CIrrDeviceLinux.h" #ifdef _IRR_COMPILE_WITH_X11_DEVICE_ @@ -497,7 +499,7 @@ void IrrPrintXGrabError(int grabResult, const c8 * grabCommand ) static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig) { GLXContext Context; - int compat33ctx[] = + int compat33ctxdebug[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 3, @@ -505,7 +507,14 @@ static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig) GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, None }; - int core33ctx[] = + int compat33ctx[] = + { + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 3, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + None + }; + int core33ctxdebug[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 3, @@ -513,12 +522,26 @@ static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig) GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, None }; + int core33ctx[] = + { + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 3, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, + None + }; + int core31ctxdebug[] = + { + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 1, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, + None + }; int core31ctx[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 1, GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, None }; int legacyctx[] = @@ -532,19 +555,19 @@ static GLXContext getMeAGLContext(Display *display, GLXFBConfig glxFBConfig) glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" ); // create compat 3.3 context (for proprietary drivers) - Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, compat33ctx); + Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, GLContextDebugBit ? compat33ctxdebug : compat33ctx); if (!XErrorSignaled) return Context; XErrorSignaled = false; // create core 3.3 context (for mesa) - Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, core33ctx); + Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, GLContextDebugBit ? core33ctxdebug : core33ctx); if (!XErrorSignaled) return Context; XErrorSignaled = false; // create core 3.1 context (for older mesa) - Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, core31ctx); + Context = glXCreateContextAttribsARB(display, glxFBConfig, 0, True, GLContextDebugBit ? core31ctxdebug : core31ctx); if (!XErrorSignaled) return Context; diff --git a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp index 0c07edcc4..451cd60af 100644 --- a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp +++ b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp @@ -2,6 +2,9 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h + +extern bool GLContextDebugBit; + #include "COpenGLDriver.h" // needed here also because of the create methods' parameters #include "CNullDriver.h" @@ -89,7 +92,7 @@ static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB; static HGLRC getMeAGLContext(HDC HDc) { HGLRC hrc = 0; - int ctx44[] = + int ctx44debug[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 4, WGL_CONTEXT_MINOR_VERSION_ARB, 3, @@ -98,11 +101,19 @@ static HGLRC getMeAGLContext(HDC HDc) 0 }; - hrc = wglCreateContextAttribs_ARB(HDc, 0, ctx44); + int ctx44[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 4, + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + 0 + }; + + hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx44debug : ctx44); if (hrc) return hrc; - int ctx40[] = + int ctx40debug[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 4, WGL_CONTEXT_MINOR_VERSION_ARB, 0, @@ -111,11 +122,19 @@ static HGLRC getMeAGLContext(HDC HDc) 0 }; - hrc = wglCreateContextAttribs_ARB(HDc, 0, ctx40); + int ctx40[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 4, + WGL_CONTEXT_MINOR_VERSION_ARB, 0, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + 0 + }; + + hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx40debug : ctx40); if (hrc) return hrc; - int ctx33[] = + int ctx33debug[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MINOR_VERSION_ARB, 3, @@ -124,11 +143,19 @@ static HGLRC getMeAGLContext(HDC HDc) 0 }; - hrc = wglCreateContextAttribs_ARB(HDc, 0, ctx33); + int ctx33[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + 0 + }; + + hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx33debug : ctx33); if (hrc) return hrc; - int ctx31[] = + int ctx31debug[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MINOR_VERSION_ARB, 1, @@ -136,7 +163,15 @@ static HGLRC getMeAGLContext(HDC HDc) WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0 }; - hrc = wglCreateContextAttribs_ARB(HDc, 0, ctx31); + + int ctx31[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 1, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + 0 + }; + hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx31debug : ctx31); if (hrc) return hrc; diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index f20d4eb5d..81b4456ab 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -11,6 +11,12 @@ static bool is_gl_init = false; +#if DEBUG +bool GLContextDebugBit = true; +#else +bool GLContextDebugBit = false; +#endif + #ifdef DEBUG #if !defined(__APPLE__) #define ARB_DEBUG_OUTPUT