mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-25 16:43:33 +00:00
Make OpenGL debugging optional
This commit is contained in:
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_BLUE_SIZE, 8));
|
||||||
checkSDLError(SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0));
|
checkSDLError(SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0));
|
||||||
checkSDLError(SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24));
|
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)
|
if (antialiasing > 0)
|
||||||
{
|
{
|
||||||
@ -577,7 +578,8 @@ void OMW::Engine::createWindow(Settings::Manager& settings)
|
|||||||
camera->setGraphicsContext(graphicsWindow);
|
camera->setGraphicsContext(graphicsWindow);
|
||||||
camera->setViewport(0, 0, traits->width, traits->height);
|
camera->setViewport(0, 0, traits->width, traits->height);
|
||||||
|
|
||||||
mViewer->setRealizeOperation(new Debug::EnableGLDebugOperation());
|
if (Debug::shouldDebugOpenGL())
|
||||||
|
mViewer->setRealizeOperation(new Debug::EnableGLDebugOperation());
|
||||||
|
|
||||||
mViewer->realize();
|
mViewer->realize();
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ either expressed or implied, of the FreeBSD Project.
|
|||||||
|
|
||||||
#include "gldebug.hpp"
|
#include "gldebug.hpp"
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
|
||||||
// OpenGL constants not provided by OSG:
|
// OpenGL constants not provided by OSG:
|
||||||
@ -144,3 +146,15 @@ void Debug::EnableGLDebugOperation::operator()(osg::GraphicsContext* graphicsCon
|
|||||||
unsigned int contextID = graphicsContext->getState()->getContextID();
|
unsigned int contextID = graphicsContext->getState()->getContextID();
|
||||||
enableGLDebugExtension(contextID);
|
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:
|
private:
|
||||||
OpenThreads::Mutex mMutex;
|
OpenThreads::Mutex mMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool shouldDebugOpenGL();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user