diff --git a/hw/nv2a.c b/hw/nv2a.c index 4c60a1da38..7275b03ca9 100644 --- a/hw/nv2a.c +++ b/hw/nv2a.c @@ -1501,19 +1501,19 @@ static void pgraph_context_init(GraphicsContext *context) const GLubyte *extensions; extensions = glGetString (GL_EXTENSIONS); - assert(glo_check_extension((const GLubyte*)"GL_EXT_texture_compression_s3tc", + assert(glo_check_extension(const GLubyte *)"GL_EXT_texture_compression_s3tc", extensions)); - assert(glo_check_extension((const GLubyte*)"GL_EXT_framebuffer_object", + assert(glo_check_extension(const GLubyte *)"GL_EXT_framebuffer_object", extensions)); - assert(glo_check_extension((const GLubyte*)"GL_ARB_vertex_program", + assert(glo_check_extension(const GLubyte *)"GL_ARB_vertex_program", extensions)); - assert(glo_check_extension((const GLubyte*)"GL_ARB_fragment_program", + assert(glo_check_extension(const GLubyte *)"GL_ARB_fragment_program", extensions)); - assert(glo_check_extension((const GLubyte*)"GL_ARB_texture_rectangle", + assert(glo_check_extension(const GLubyte *)"GL_ARB_texture_rectangle", extensions)); GLint max_vertex_attributes; diff --git a/target-i386/Makefile.objs b/target-i386/Makefile.objs index 27a17c4eb7..49572e9a29 100644 --- a/target-i386/Makefile.objs +++ b/target-i386/Makefile.objs @@ -7,7 +7,7 @@ obj-$(CONFIG_NO_KVM) += kvm-stub.o obj-$(CONFIG_LINUX_USER) += ioport-user.o obj-$(CONFIG_BSD_USER) += ioport-user.o obj-gl-y += gloffscreen_common.o -obj-gl-$(CONFIG_WIN32) += gloffscreen_wgl.o -obj-gl-$(CONFIG_LINUX) += gloffscreen_glx.o +obj-gl-$(CONFIG_WIN32) += gloffscreen_wgl.o +obj-gl-$(CONFIG_LINUX) += gloffscreen_glx.o obj-gl-$(CONFIG_DARWIN) += gloffscreen_cgl.o obj-$(CONFIG_OPENGL) += $(obj-gl-y) \ No newline at end of file diff --git a/target-i386/gloffscreen.h b/target-i386/gloffscreen.h index a10216e20e..b10b105d98 100644 --- a/target-i386/gloffscreen.h +++ b/target-i386/gloffscreen.h @@ -72,10 +72,11 @@ extern void glo_set_current(GloContext *context); extern void glo_kill(void); /* Check GL Extensions */ -extern GLboolean glo_check_extension( const GLubyte *extName, const GLubyte *extString ); +extern GLboolean glo_check_extension( + const GLubyte *extName, const GLubyte *extString); -/* Create an OpenGL context for a certain - * pixel format. formatflags are from the +/* Create an OpenGL context for a certain + * pixel format. formatflags are from the * GLO_ constants */ extern GloContext *glo_context_create(int formatFlags); diff --git a/target-i386/gloffscreen_cgl.c b/target-i386/gloffscreen_cgl.c index 6fa4f64991..c18006115a 100644 --- a/target-i386/gloffscreen_cgl.c +++ b/target-i386/gloffscreen_cgl.c @@ -52,7 +52,7 @@ struct GloMain glo; int glo_inited = 0; struct _GloContext { - CGLContextObj cglContext; + CGLContextObj cglContext; }; int glo_initialised(void) { @@ -74,18 +74,19 @@ void glo_init(void) { /* Uninitialise gloffscreen */ void glo_kill(void) { - glo_inited = 0; + glo_inited = 0; } /* Create an OpenGL context for a certain pixel format. formatflags are from the GLO_ constants */ -GloContext *glo_context_create( int formatFlags ) { +GloContext *glo_context_create(int formatFlags) +{ GloContext *context; - context = (GloContext*)malloc(sizeof(GloContext)); + context = (GloContext*)malloc(sizeof(GloContext)); memset(context, 0, sizeof(GloContext)); - - // pixel format attributes - CGLPixelFormatAttribute attributes[] = { + + // pixel format attributes + CGLPixelFormatAttribute attributes[] = { kCGLPFAAccelerated, (CGLPixelFormatAttribute)0 }; @@ -97,31 +98,35 @@ GloContext *glo_context_create( int formatFlags ) { CGLDestroyPixelFormat(pix); if (!glo_inited) - glo_init(); + glo_init(); + + glo_set_current(context); - glo_set_current(context); - return context; } /* Check if an extension is available. */ -GLboolean glo_check_extension( const GLubyte *extName, const GLubyte *extString ) { - return gluCheckExtension(extName, extString); +GLboolean glo_check_extension(const GLubyte *extName, + const GLubyte *extString) +{ + return gluCheckExtension(extName, extString); } /* Set current context */ -void glo_set_current( GloContext *context ) { - if(context == NULL) - CGLSetCurrentContext(NULL); - else - CGLSetCurrentContext(context->cglContext); +void glo_set_current(GloContext *context) +{ + if(context == NULL) + CGLSetCurrentContext(NULL); + else + CGLSetCurrentContext(context->cglContext); } /* Destroy a previously created OpenGL context */ -void glo_context_destroy( GloContext *context ) { +void glo_context_destroy(GloContext *context) +{ if (!context) return; - glo_set_current( NULL ); + glo_set_current(NULL); - CGLDestroyContext(context->cglContext); -} \ No newline at end of file + CGLDestroyContext(context->cglContext); +} diff --git a/target-i386/gloffscreen_wgl.c b/target-i386/gloffscreen_wgl.c index cf685a3346..4189ef144b 100644 --- a/target-i386/gloffscreen_wgl.c +++ b/target-i386/gloffscreen_wgl.c @@ -262,8 +262,8 @@ void glo_set_current(GloContext *context) { } /* Destroy a previously created OpenGL context */ -void glo_context_destroy(GloContext *context) { - +void glo_context_destroy(GloContext *context) +{ if (!context) return; wglMakeCurrent( NULL, NULL ); @@ -275,27 +275,30 @@ void glo_context_destroy(GloContext *context) { ReleaseDC( glo.hWnd, context->hDC ); } if (context->hContext) { - wglDeleteContext(context->hContext); + wglDeleteContext(context->hContext); } free(context); } -/* Check extension implementation for Windows. The Glu 1.2 framework in Windows doesn't include them... */ -GLboolean glo_check_extension( const GLubyte *extName, const GLubyte *extString ) { +/* Check extension implementation for Windows. + * The Glu 1.2 framework in Windows doesn't include them... */ +GLboolean glo_check_extension(const GLubyte *extName, + const GLubyte *extString) +{ + char *p = (char *) glGetString(GL_EXTENSIONS); + char *end; + if (p == NULL) { + return GL_FALSE; + } + end = p + strlen(p); - char *p = (char *) glGetString(GL_EXTENSIONS); - char *end; - if(p==NULL) - return GL_FALSE; - end = p + strlen(p); - - while (p < end) { - int n = strcspn(p, " "); - if((strlen(extName) == n) && (strncmp(extName,p,n) == 0)) { - return GL_TRUE; - } - p += (n + 1); - } - return GL_FALSE; + while (p < end) { + int n = strcspn(p, " "); + if ((strlen(extName) == n) && (strncmp(extName, p, n) == 0)) { + return GL_TRUE; + } + p += (n + 1); + } + return GL_FALSE; }