Kaydet (Commit) 39312d64 authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Jan Holesovsky

Don't call GL debugging methods if there is no context.

Change-Id: Ie6b824953b8ad19fd1b6a146cb6bf52bbb152ef7
Reviewed-on: https://gerrit.libreoffice.org/18277Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst a4cd1c4f
...@@ -210,9 +210,11 @@ public: ...@@ -210,9 +210,11 @@ public:
OpenGLProgram* GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" ); OpenGLProgram* GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" );
OpenGLProgram* UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" ); OpenGLProgram* UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" );
/// Is this GL context the current context ?
bool isCurrent(); bool isCurrent();
static void clearCurrent(); static void clearCurrent();
/// Is there a current GL context ?
static bool hasCurrent();
/// make this GL context current - so it is implicit in subsequent GL calls /// make this GL context current - so it is implicit in subsequent GL calls
void makeCurrent(); void makeCurrent();
/// reset the GL context so this context is not implicit in subsequent GL calls. /// reset the GL context so this context is not implicit in subsequent GL calls.
......
...@@ -1402,6 +1402,17 @@ bool OpenGLContext::isCurrent() ...@@ -1402,6 +1402,17 @@ bool OpenGLContext::isCurrent()
#endif #endif
} }
bool OpenGLContext::hasCurrent()
{
#if defined( WNT )
return wglGetCurrentContext() != NULL;
#elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID ) || defined(LIBO_HEADLESS)
return false;
#elif defined( UNX )
return glXGetCurrentContext() != None;
#endif
}
void OpenGLContext::clearCurrent() void OpenGLContext::clearCurrent()
{ {
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "opengl/zone.hxx" #include "opengl/zone.hxx"
#include "opengl/watchdog.hxx" #include "opengl/watchdog.hxx"
#include <osl/conditn.h> #include <osl/conditn.h>
#include <vcl/opengl/OpenGLContext.hxx>
#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID #if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID
#include "opengl/x11/X11DeviceInfo.hxx" #include "opengl/x11/X11DeviceInfo.hxx"
...@@ -690,15 +691,21 @@ void OpenGLHelper::debugMsgPrint(const char *pArea, const char *pFormat, ...) ...@@ -690,15 +691,21 @@ void OpenGLHelper::debugMsgPrint(const char *pArea, const char *pFormat, ...)
va_list aArgs; va_list aArgs;
va_start (aArgs, pFormat); va_start (aArgs, pFormat);
char pStr[1024]; char pStr[1044];
#ifdef _WIN32 #ifdef _WIN32
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #endif
vsnprintf(pStr, sizeof(pStr), pFormat, aArgs); vsnprintf(pStr, sizeof(pStr), pFormat, aArgs);
pStr[sizeof(pStr)-1] = '\0'; pStr[sizeof(pStr)-20] = '\0';
bool bHasContext = !OpenGLContext::hasCurrent();
if (!bHasContext)
strcat(pStr, "- no GL context");
SAL_INFO(pArea, pStr); SAL_INFO(pArea, pStr);
if (bHasContext)
{
OpenGLZone aZone; OpenGLZone aZone;
if (GLEW_KHR_debug) if (GLEW_KHR_debug)
...@@ -713,6 +720,7 @@ void OpenGLHelper::debugMsgPrint(const char *pArea, const char *pFormat, ...) ...@@ -713,6 +720,7 @@ void OpenGLHelper::debugMsgPrint(const char *pArea, const char *pFormat, ...)
GL_DEBUG_SEVERITY_LOW_AMD, GL_DEBUG_SEVERITY_LOW_AMD,
1, // one[sic] id is as good as another ? 1, // one[sic] id is as good as another ?
strlen(pStr), pStr); strlen(pStr), pStr);
}
va_end (aArgs); va_end (aArgs);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment