Make OpenGL debugging optional

pull/593/head
AnyOldName3 4 years ago
parent 441c09578a
commit 3f61ff3a44

@ -516,7 +516,8 @@ void OMW::Engine::createWindow(Settings::Manager& settings)
checkSDLError(SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8));
checkSDLError(SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0));
checkSDLError(SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24));
checkSDLError(SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG));
if (Debug::shouldDebugOpenGL())
checkSDLError(SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG));
if (antialiasing > 0)
{
@ -577,7 +578,8 @@ void OMW::Engine::createWindow(Settings::Manager& settings)
camera->setGraphicsContext(graphicsWindow);
camera->setViewport(0, 0, traits->width, traits->height);
mViewer->setRealizeOperation(new Debug::EnableGLDebugOperation());
if (Debug::shouldDebugOpenGL())
mViewer->setRealizeOperation(new Debug::EnableGLDebugOperation());
mViewer->realize();

@ -31,6 +31,8 @@ either expressed or implied, of the FreeBSD Project.
#include "gldebug.hpp"
#include <cstdlib>
#include <components/debug/debuglog.hpp>
// OpenGL constants not provided by OSG:
@ -144,3 +146,15 @@ void Debug::EnableGLDebugOperation::operator()(osg::GraphicsContext* graphicsCon
unsigned int contextID = graphicsContext->getState()->getContextID();
enableGLDebugExtension(contextID);
}
bool Debug::shouldDebugOpenGL()
{
const char* env = std::getenv("OPENMW_DEBUG_OPENGL");
if (!env)
return false;
std::string str(env);
if (str.length() == 0)
return true;
return str.find("OFF") == std::string::npos && str.find("0") == std::string::npos && str.find("NO") == std::string::npos;
}

@ -15,5 +15,7 @@ namespace Debug
private:
OpenThreads::Mutex mMutex;
};
bool shouldDebugOpenGL();
}
#endif

Loading…
Cancel
Save