From 6acc7e2d13f98eccd02f3f19d6e8734f665554fd Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Sun, 12 Jul 2015 04:23:15 +0200 Subject: [PATCH 1/4] GLX version for GL 3.3 Core --- gl/gloffscreen_glx.c | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/gl/gloffscreen_glx.c b/gl/gloffscreen_glx.c index f8f134a1ec..669602b3db 100644 --- a/gl/gloffscreen_glx.c +++ b/gl/gloffscreen_glx.c @@ -52,8 +52,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 +95,51 @@ GloContext *glo_context_create(int formatFlags) #endif /* Create GLX context */ - context->glx_context = glXCreateNewContext(x_display, configs[0], GLX_RGBA_TYPE, NULL, True); + + /* FIXME: Check for "GLX_ARB_create_context" extension*/ + #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 + #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 + #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 + #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 + typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display*, GLXFBConfig, GLXContext, Bool, const int*); + GLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (GLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB"); + if (glXCreateContextAttribsARB == NULL) return NULL; + 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); + if (context->glx_context == NULL) { + assert(0); + } + 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."); + printf("GLEW init failed."); exit(1); } + + /* Get rid of GLEW errors */ + while(glGetError() != GL_NO_ERROR); + + GLint major, minor; + glGetIntegerv(GL_MAJOR_VERSION, &major); + glGetIntegerv(GL_MINOR_VERSION, &minor); + printf("GL %d.%d\n",major,minor); +#if 0 + if (GLEW_VERSION_3_3) { + printf("OpenGL 3.3 Core not supported!\n"); + exit(1); + } +#endif } initialized = true; @@ -132,6 +166,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); } From b392aeed7abc7c5ed8b3514a123f561369e6c74c Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Mon, 13 Jul 2015 13:10:40 +0200 Subject: [PATCH 2/4] Cleanup GLX --- gl/gloffscreen_glx.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/gl/gloffscreen_glx.c b/gl/gloffscreen_glx.c index 669602b3db..b0c968c76d 100644 --- a/gl/gloffscreen_glx.c +++ b/gl/gloffscreen_glx.c @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -95,15 +96,13 @@ GloContext *glo_context_create(int formatFlags) #endif /* Create GLX context */ - - /* FIXME: Check for "GLX_ARB_create_context" extension*/ - #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 - #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 - #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 - #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 - typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display*, GLXFBConfig, GLXContext, Bool, const int*); - GLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (GLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB"); - if (glXCreateContextAttribsARB == NULL) return NULL; + PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = + (PFNGLXCREATECONTEXTATTRIBSARBPROC) + glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB"); + if (glXCreateContextAttribsARB == NULL) { + printf("GLX doesn't support ARB_create_context extension.\n"); + exit(1); + } int context_attribute_list[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 3, @@ -111,9 +110,6 @@ GloContext *glo_context_create(int formatFlags) None }; context->glx_context = glXCreateContextAttribsARB(x_display, configs[0], 0, True, context_attribute_list); - if (context->glx_context == NULL) { - assert(0); - } XSync(x_display, False); if (context->glx_context == NULL) return NULL; glo_set_current(context); @@ -123,7 +119,7 @@ GloContext *glo_context_create(int formatFlags) glewExperimental = GL_TRUE; if (GLEW_OK != glewInit()) { /* GLEW failed! */ - printf("GLEW init failed."); + printf("GLEW init failed.\n"); exit(1); } From c32594ed12b8b82aa9ef3e1f70fb329b1dc81653 Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Mon, 13 Jul 2015 14:22:47 +0200 Subject: [PATCH 3/4] Check GL Version in NV2A --- gl/gloffscreen_glx.c | 11 ----------- hw/xbox/nv2a.c | 4 ++++ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/gl/gloffscreen_glx.c b/gl/gloffscreen_glx.c index b0c968c76d..6b5c89adfa 100644 --- a/gl/gloffscreen_glx.c +++ b/gl/gloffscreen_glx.c @@ -125,17 +125,6 @@ GloContext *glo_context_create(int formatFlags) /* Get rid of GLEW errors */ while(glGetError() != GL_NO_ERROR); - - GLint major, minor; - glGetIntegerv(GL_MAJOR_VERSION, &major); - glGetIntegerv(GL_MINOR_VERSION, &minor); - printf("GL %d.%d\n",major,minor); -#if 0 - if (GLEW_VERSION_3_3) { - printf("OpenGL 3.3 Core not supported!\n"); - exit(1); - } -#endif } initialized = true; diff --git a/hw/xbox/nv2a.c b/hw/xbox/nv2a.c index 3dbbb32b07..e3bcc1c56a 100644 --- a/hw/xbox/nv2a.c +++ b/hw/xbox/nv2a.c @@ -3044,6 +3044,10 @@ static void pgraph_init(PGRAPHState *pg) 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; From 3364a7b4616de5a4c106ace28548afb78bfd7545 Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Mon, 13 Jul 2015 14:25:40 +0200 Subject: [PATCH 4/4] Fatal messages to stderr --- gl/gloffscreen_glx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gl/gloffscreen_glx.c b/gl/gloffscreen_glx.c index 6b5c89adfa..3a0e608164 100644 --- a/gl/gloffscreen_glx.c +++ b/gl/gloffscreen_glx.c @@ -100,8 +100,8 @@ GloContext *glo_context_create(int formatFlags) (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB"); if (glXCreateContextAttribsARB == NULL) { - printf("GLX doesn't support ARB_create_context extension.\n"); - exit(1); + fprintf(stderr,"GLX doesn't support ARB_create_context extension.\n"); + exit(EXIT_FAILURE); } int context_attribute_list[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, @@ -119,8 +119,8 @@ GloContext *glo_context_create(int formatFlags) glewExperimental = GL_TRUE; if (GLEW_OK != glewInit()) { /* GLEW failed! */ - printf("GLEW init failed.\n"); - exit(1); + fprintf(stderr,"GLEW init failed.\n"); + exit(EXIT_FAILURE); } /* Get rid of GLEW errors */