enable opengl debugging on x11

This commit is contained in:
Eduardo Bart 2012-04-12 16:24:00 -03:00
parent a46a16738c
commit 879827bdbc
3 changed files with 37 additions and 13 deletions

View File

@ -28,17 +28,28 @@
Graphics g_graphics; Graphics g_graphics;
void oglDebugCallback(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, int length, const char* message, void* userParam)
{
logWarning("OGL: ", message);
}
void Graphics::init() void Graphics::init()
{ {
logInfo("GPU ", glGetString(GL_RENDERER)); logInfo("GPU ", glGetString(GL_RENDERER));
logInfo("OpenGL ", glGetString(GL_VERSION)); logInfo("OpenGL ", glGetString(GL_VERSION));
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
// init GL extensions // init GL extensions
GLenum err = glewInit(); GLenum err = glewInit();
if(err != GLEW_OK) if(err != GLEW_OK)
logFatal("Unable to init GLEW: ", glewGetErrorString(err)); logFatal("Unable to init GLEW: ", glewGetErrorString(err));
#ifndef NDEBUG
if(GLEW_ARB_debug_output)
glDebugMessageCallbackARB(oglDebugCallback, NULL);
#endif
const char *requiredExtensions[] = { const char *requiredExtensions[] = {
"GL_ARB_vertex_program", "GL_ARB_vertex_program",
"GL_ARB_vertex_shader", "GL_ARB_vertex_shader",

View File

@ -29,6 +29,7 @@
X11Window::X11Window() X11Window::X11Window()
{ {
m_fbConfig = 0;
m_display = 0; m_display = 0;
m_visual = 0; m_visual = 0;
m_window = 0; m_window = 0;
@ -366,27 +367,24 @@ void X11Window::internalChooseGLVisual()
{ {
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
static int attrList[] = { static int attrList[] = {
GLX_USE_GL, GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_RGBA, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_DOUBLEBUFFER, GLX_DOUBLEBUFFER, True,
//GLX_STENCIL_SIZE, 8,
/*
GLX_ACCUM_RED_SIZE, 8,
GLX_ACCUM_GREEN_SIZE, 8,
GLX_ACCUM_BLUE_SIZE, 8,
GLX_ACCUM_ALPHA_SIZE, 8,
*/
None None
}; };
m_visual = glXChooseVisual(m_display, m_screen, attrList); int nelements;
m_fbConfig = glXChooseFBConfig(m_display, m_screen, attrList, &nelements);
if(!m_fbConfig)
logFatal("Couldn't choose RGBA, double buffered fbconfig");
m_visual = glXGetVisualFromFBConfig(m_display, *m_fbConfig);
if(!m_visual) if(!m_visual)
logFatal("Couldn't choose RGBA, double buffered visual"); logFatal("Couldn't choose RGBA, double buffered visual");
m_rootWindow = RootWindow(m_display, m_visual->screen); m_rootWindow = RootWindow(m_display, m_visual->screen);
#else #else
static int attrList[] = { static int attrList[] = {
//EGL_BUFFER_SIZE, 24,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
//EGL_STENCIL_SIZE, 8, //EGL_STENCIL_SIZE, 8,
EGL_NONE EGL_NONE
@ -406,7 +404,21 @@ void X11Window::internalChooseGLVisual()
void X11Window::internalCreateGLContext() void X11Window::internalCreateGLContext()
{ {
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
GLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = NULL;
glXCreateContextAttribsARB = (GLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB");
if(glXCreateContextAttribsARB) {
int attrs[] = {
#ifndef NDEBUG
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
#endif
None
};
m_glxContext = glXCreateContextAttribsARB(m_display, *m_fbConfig, NULL, True, attrs);
} else
m_glxContext = glXCreateContext(m_display, m_visual, NULL, True); m_glxContext = glXCreateContext(m_display, m_visual, NULL, True);
//m_glxContext = glXCreateContext(m_display, m_visual, NULL, True);
if(!m_glxContext) if(!m_glxContext)
logFatal("Unable to create GLX context"); logFatal("Unable to create GLX context");

View File

@ -82,6 +82,7 @@ public:
bool isMaximized(); bool isMaximized();
private: private:
GLXFBConfig *m_fbConfig;
Display *m_display; Display *m_display;
XVisualInfo *m_visual; XVisualInfo *m_visual;
Window m_window; Window m_window;