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;
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()
{
logInfo("GPU ", glGetString(GL_RENDERER));
logInfo("OpenGL ", glGetString(GL_VERSION));
#ifndef OPENGL_ES2
// init GL extensions
GLenum err = glewInit();
if(err != GLEW_OK)
logFatal("Unable to init GLEW: ", glewGetErrorString(err));
#ifndef NDEBUG
if(GLEW_ARB_debug_output)
glDebugMessageCallbackARB(oglDebugCallback, NULL);
#endif
const char *requiredExtensions[] = {
"GL_ARB_vertex_program",
"GL_ARB_vertex_shader",

View File

@ -29,6 +29,7 @@
X11Window::X11Window()
{
m_fbConfig = 0;
m_display = 0;
m_visual = 0;
m_window = 0;
@ -366,27 +367,24 @@ void X11Window::internalChooseGLVisual()
{
#ifndef OPENGL_ES2
static int attrList[] = {
GLX_USE_GL,
GLX_RGBA,
GLX_DOUBLEBUFFER,
//GLX_STENCIL_SIZE, 8,
/*
GLX_ACCUM_RED_SIZE, 8,
GLX_ACCUM_GREEN_SIZE, 8,
GLX_ACCUM_BLUE_SIZE, 8,
GLX_ACCUM_ALPHA_SIZE, 8,
*/
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_DOUBLEBUFFER, True,
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)
logFatal("Couldn't choose RGBA, double buffered visual");
m_rootWindow = RootWindow(m_display, m_visual->screen);
#else
static int attrList[] = {
//EGL_BUFFER_SIZE, 24,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
//EGL_STENCIL_SIZE, 8,
EGL_NONE
@ -406,7 +404,21 @@ void X11Window::internalChooseGLVisual()
void X11Window::internalCreateGLContext()
{
#ifndef OPENGL_ES2
m_glxContext = glXCreateContext(m_display, m_visual, NULL, True);
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);
if(!m_glxContext)
logFatal("Unable to create GLX context");

View File

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