mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-29 03:33:48 +00:00
Experimenting with GL debug context and GL_ARB_debug_output
This commit is contained in:
parent
704981dd00
commit
395ff079e9
3 changed files with 109 additions and 1 deletions
|
@ -23,9 +23,56 @@ bool void unload_all_glsyms() { return false; }
|
|||
#define GLAPIENTRY
|
||||
#endif
|
||||
|
||||
#include <GL/glext.h>
|
||||
static const char *glDebugTypeToStr(unsigned e)
|
||||
{
|
||||
switch(e)
|
||||
{
|
||||
case GL_DEBUG_TYPE_ERROR_ARB: return " ERR";
|
||||
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: return "depr";
|
||||
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: return " UB!";
|
||||
case GL_DEBUG_TYPE_PORTABILITY_ARB: return "port";
|
||||
case GL_DEBUG_TYPE_PERFORMANCE_ARB: return "perf";
|
||||
case GL_DEBUG_TYPE_OTHER_ARB: return "othr";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
static const char *glDebugSeverityToStr(unsigned e)
|
||||
{
|
||||
switch(e)
|
||||
{
|
||||
case GL_DEBUG_SEVERITY_HIGH_ARB: return "###";
|
||||
case GL_DEBUG_SEVERITY_MEDIUM_ARB: return "+++";
|
||||
case GL_DEBUG_SEVERITY_LOW_ARB: return "---";
|
||||
//case GL_DEBUG_SEVERITY_NOTIFICATION: return " ";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
static void GLAPIENTRY debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
|
||||
{
|
||||
switch(severity)
|
||||
{
|
||||
case GL_DEBUG_SEVERITY_HIGH_ARB:
|
||||
case GL_DEBUG_SEVERITY_MEDIUM_ARB:
|
||||
case GL_DEBUG_SEVERITY_LOW_ARB:
|
||||
{
|
||||
const char *ty = glDebugTypeToStr(type);
|
||||
const char *sev = glDebugSeverityToStr(severity);
|
||||
|
||||
std::ostringstream os;
|
||||
os << sev << " GL[" << ty << "]: " << message;
|
||||
debugLog(os.str());
|
||||
}
|
||||
break;
|
||||
|
||||
/*case GL_DEBUG_SEVERITY_NOTIFICATION:
|
||||
break;
|
||||
default:
|
||||
assert(false);*/
|
||||
}
|
||||
}
|
||||
|
||||
PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL;
|
||||
|
||||
// GL_ARB_shader_objects
|
||||
|
@ -183,6 +230,25 @@ bool lookup_all_glsyms()
|
|||
glMapBufferARB = (PFNGLMAPBUFFERARBPROC)SDL_GL_GetProcAddress("glMapBufferARB");
|
||||
glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)SDL_GL_GetProcAddress("glUnmapBufferARB");
|
||||
|
||||
|
||||
#if _DEBUG
|
||||
//PFNGLDEBUGMESSAGECONTROLARBPROC glDebugMessageControlARB = (PFNGLDEBUGMESSAGECONTROLARBPROC)SDL_GL_GetProcAddress("glDebugMessageControlARB");
|
||||
PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)SDL_GL_GetProcAddress("glDebugMessageCallbackARB");
|
||||
//PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB = (PFNGLDEBUGMESSAGEINSERTARBPROC)SDL_GL_GetProcAddress("glDebugMessageInsertARB");
|
||||
if(glDebugMessageCallbackARB)
|
||||
{
|
||||
/*glDebugMessageCallbackARB(debugCallback, NULL);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);*/
|
||||
}
|
||||
|
||||
//if(glDebugMessageControlARB)
|
||||
// glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, NULL, 0, GL_TRUE);
|
||||
|
||||
//if(glDebugMessageInsertARB)
|
||||
// glDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, 0, "GL debug test");
|
||||
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,44 @@
|
|||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
// Extensions from newer glext.h versions
|
||||
#ifndef GL_ARB_debug_output
|
||||
#define GL_ARB_debug_output 1
|
||||
typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
|
||||
#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242
|
||||
#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243
|
||||
#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244
|
||||
#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245
|
||||
#define GL_DEBUG_SOURCE_API_ARB 0x8246
|
||||
#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247
|
||||
#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248
|
||||
#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249
|
||||
#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A
|
||||
#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B
|
||||
#define GL_DEBUG_TYPE_ERROR_ARB 0x824C
|
||||
#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D
|
||||
#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E
|
||||
#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F
|
||||
#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250
|
||||
#define GL_DEBUG_TYPE_OTHER_ARB 0x8251
|
||||
#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143
|
||||
#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144
|
||||
#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145
|
||||
#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146
|
||||
#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147
|
||||
#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148
|
||||
typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
|
||||
typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
|
||||
typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam);
|
||||
typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
|
||||
GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
|
||||
GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam);
|
||||
GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
|
||||
#endif
|
||||
#endif /* GL_ARB_debug_output */
|
||||
|
||||
#ifdef _WINDOWS_
|
||||
#error windows.h was included! euuugh!
|
||||
#endif
|
||||
|
|
|
@ -93,6 +93,10 @@ void Window::_open(unsigned w, unsigned h, bool full, unsigned bpp, bool vsync,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
|
||||
#endif
|
||||
|
||||
int pos = SDL_WINDOWPOS_CENTERED_DISPLAY(display);
|
||||
WIN = SDL_CreateWindow("", pos, pos, usew, useh, flags);
|
||||
if(!WIN)
|
||||
|
|
Loading…
Reference in a new issue