diff --git a/gl/gloffscreen_glx.c b/gl/gloffscreen_glx.c index f8f134a1ec..3a0e608164 100644 --- a/gl/gloffscreen_glx.c +++ b/gl/gloffscreen_glx.c @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -52,8 +53,8 @@ GloContext *glo_context_create(int formatFlags) if (!initialized) { x_display = XOpenDisplay(0); - printf("gloffscreen: GLX_VERSION = %s\n", glXGetClientString(x_display, GLX_VERSION)); - printf("gloffscreen: GLX_VENDOR = %s\n", glXGetClientString(x_display, GLX_VENDOR)); + printf("gloffscreen: GLX_VERSION = %s\n", glXGetClientString(x_display, GLX_VERSION)); + printf("gloffscreen: GLX_VENDOR = %s\n", glXGetClientString(x_display, GLX_VENDOR)); } else { printf("gloffscreen already inited\n"); exit(EXIT_FAILURE); @@ -95,17 +96,35 @@ GloContext *glo_context_create(int formatFlags) #endif /* Create GLX context */ - context->glx_context = glXCreateNewContext(x_display, configs[0], GLX_RGBA_TYPE, NULL, True); + PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = + (PFNGLXCREATECONTEXTATTRIBSARBPROC) + glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB"); + if (glXCreateContextAttribsARB == NULL) { + fprintf(stderr,"GLX doesn't support ARB_create_context extension.\n"); + exit(EXIT_FAILURE); + } + int context_attribute_list[] = { + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 3, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, + None + }; + context->glx_context = glXCreateContextAttribsARB(x_display, configs[0], 0, True, context_attribute_list); + XSync(x_display, False); if (context->glx_context == NULL) return NULL; glo_set_current(context); if (!initialized) { /* Initialize glew */ + glewExperimental = GL_TRUE; if (GLEW_OK != glewInit()) { /* GLEW failed! */ - printf("Glew init failed."); - exit(1); + fprintf(stderr,"GLEW init failed.\n"); + exit(EXIT_FAILURE); } + + /* Get rid of GLEW errors */ + while(glGetError() != GL_NO_ERROR); } initialized = true; @@ -132,6 +151,6 @@ void glo_context_destroy(GloContext *context) { if (!context) { return; } glo_set_current(NULL); - glXDestroyContext(x_display, context->glx_context); + glXDestroyContext(x_display, context->glx_context); } diff --git a/hw/xbox/nv2a.c b/hw/xbox/nv2a.c index d95090e116..464179ff44 100644 --- a/hw/xbox/nv2a.c +++ b/hw/xbox/nv2a.c @@ -3074,6 +3074,10 @@ static void pgraph_init(NV2AState *d) glextensions_init(); /* Check context capabilities */ + GLint major, minor; + glGetIntegerv(GL_MAJOR_VERSION, &major); + glGetIntegerv(GL_MINOR_VERSION, &minor); + assert(major == 3 && minor == 3); assert(glo_check_extension("GL_EXT_texture_compression_s3tc")); GLint max_vertex_attributes;