diff --git a/src/Window_Carbon.c b/src/Window_Carbon.c index 779d4bc0e..d81667500 100644 --- a/src/Window_Carbon.c +++ b/src/Window_Carbon.c @@ -679,21 +679,6 @@ static void GLContext_SetDrawable(void) { GLContext_Check(code, "Attaching GL context"); } -static void GLContext_GetAttribs(struct GraphicsMode* mode, GLint* attribs, cc_bool fullscreen) { - int i = 0; - - if (!mode->IsIndexed) { attribs[i++] = AGL_RGBA; } - attribs[i++] = AGL_RED_SIZE; attribs[i++] = mode->R; - attribs[i++] = AGL_GREEN_SIZE; attribs[i++] = mode->G; - attribs[i++] = AGL_BLUE_SIZE; attribs[i++] = mode->B; - attribs[i++] = AGL_ALPHA_SIZE; attribs[i++] = mode->A; - attribs[i++] = AGL_DEPTH_SIZE; attribs[i++] = GLCONTEXT_DEFAULT_DEPTH; - - attribs[i++] = AGL_DOUBLEBUFFER; - if (fullscreen) { attribs[i++] = AGL_FULLSCREEN; } - attribs[i++] = 0; -} - cc_result Window_EnterFullscreen(void) { int width = DisplayInfo.Width; int height = DisplayInfo.Height; @@ -737,6 +722,21 @@ cc_result Window_ExitFullscreen(void) { return 0; } +static void GLContext_GetAttribs(struct GraphicsMode* mode, GLint* attribs, cc_bool fullscreen) { + int i = 0; + + attribs[i++] = AGL_RGBA; + attribs[i++] = AGL_RED_SIZE; attribs[i++] = mode->R; + attribs[i++] = AGL_GREEN_SIZE; attribs[i++] = mode->G; + attribs[i++] = AGL_BLUE_SIZE; attribs[i++] = mode->B; + attribs[i++] = AGL_ALPHA_SIZE; attribs[i++] = mode->A; + attribs[i++] = AGL_DEPTH_SIZE; attribs[i++] = GLCONTEXT_DEFAULT_DEPTH; + + attribs[i++] = AGL_DOUBLEBUFFER; + if (fullscreen) { attribs[i++] = AGL_FULLSCREEN; } + attribs[i++] = 0; +} + void GLContext_Create(void) { GLint attribs[20]; AGLPixelFormat fmt; diff --git a/src/Window_Win.c b/src/Window_Win.c index 037111c9b..c1e254b1c 100644 --- a/src/Window_Win.c +++ b/src/Window_Win.c @@ -712,8 +712,6 @@ void GLContext_Create(void) { GLContext_SelectGraphicsMode(&mode); ctx_handle = wglCreateContext(win_DC); - if (!ctx_handle) ctx_handle = wglCreateContext(win_DC); - if (!ctx_handle) { Logger_Abort2(GetLastError(), "Failed to create OpenGL context"); } diff --git a/src/Window_X11.c b/src/Window_X11.c index c42b3e5e6..d18287495 100644 --- a/src/Window_X11.c +++ b/src/Window_X11.c @@ -1293,7 +1293,8 @@ static void GetAttribs(struct GraphicsMode* mode, int* attribs, int depth) { /* See http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.opengl/doc/openglrf/glXChooseVisual.htm%23b5c84be452rree */ /* for the attribute declarations. Note that the attributes are different than those used in glxChooseVisual */ - if (!mode->IsIndexed) { attribs[i++] = GLX_RGBA; } + /* TODO always use RGBA? need to test 8bpp displays */ + if (DisplayInfo.Depth >= 15) { attribs[i++] = GLX_RGBA; } attribs[i++] = GLX_RED_SIZE; attribs[i++] = mode->R; attribs[i++] = GLX_GREEN_SIZE; attribs[i++] = mode->G; attribs[i++] = GLX_BLUE_SIZE; attribs[i++] = mode->B; diff --git a/src/_WindowBase.h b/src/_WindowBase.h index a3d4053b5..75cb1a0c2 100644 --- a/src/_WindowBase.h +++ b/src/_WindowBase.h @@ -78,13 +78,12 @@ void OpenKeyboardArgs_Init(struct OpenKeyboardArgs* args, STRING_REF const cc_st } -struct GraphicsMode { int R, G, B, A, IsIndexed; }; +struct GraphicsMode { int R, G, B, A; }; /* Creates a GraphicsMode compatible with the default display device */ static void InitGraphicsMode(struct GraphicsMode* m) { int bpp = DisplayInfo.Depth; - m->IsIndexed = bpp < 15; - m->A = 0; + switch (bpp) { case 32: m->R = 8; m->G = 8; m->B = 8; m->A = 8; break;