changeset 612:73f134f84c7f

Request a RGB888 context, since SDL2’s default of RGB332 sucks. On X11/GLX, it will select the first config available, that is the best one, while on EGL it will iterate over them to select the one closest to what the application requested. Of course, anything lower than RGB888 looks bad and we really don’t want that.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 26 Mar 2015 20:20:37 +0100
parents a6a191e371c7
children 560b45a7d014
files pytouhou/lib/_sdl.pxd pytouhou/lib/sdl.pxd pytouhou/lib/sdl.pyx pytouhou/ui/opengl/backend.pyx
diffstat 4 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/lib/_sdl.pxd
+++ b/pytouhou/lib/_sdl.pxd
@@ -38,6 +38,9 @@ cdef extern from "SDL_video.h" nogil:
         SDL_GL_CONTEXT_MINOR_VERSION
         SDL_GL_CONTEXT_PROFILE_MASK
         SDL_GL_DOUBLEBUFFER
+        SDL_GL_RED_SIZE
+        SDL_GL_GREEN_SIZE
+        SDL_GL_BLUE_SIZE
         SDL_GL_DEPTH_SIZE
 
     ctypedef enum SDL_GLprofile:
--- a/pytouhou/lib/sdl.pxd
+++ b/pytouhou/lib/sdl.pxd
@@ -19,6 +19,9 @@ cdef SDL_GLattr GL_CONTEXT_MAJOR_VERSION
 cdef SDL_GLattr GL_CONTEXT_MINOR_VERSION
 cdef SDL_GLattr GL_CONTEXT_PROFILE_MASK
 cdef SDL_GLattr GL_DOUBLEBUFFER
+cdef SDL_GLattr GL_RED_SIZE
+cdef SDL_GLattr GL_GREEN_SIZE
+cdef SDL_GLattr GL_BLUE_SIZE
 cdef SDL_GLattr GL_DEPTH_SIZE
 
 cdef SDL_GLprofile GL_CONTEXT_PROFILE_CORE
--- a/pytouhou/lib/sdl.pyx
+++ b/pytouhou/lib/sdl.pyx
@@ -21,6 +21,9 @@ GL_CONTEXT_MAJOR_VERSION = SDL_GL_CONTEX
 GL_CONTEXT_MINOR_VERSION = SDL_GL_CONTEXT_MINOR_VERSION
 GL_CONTEXT_PROFILE_MASK = SDL_GL_CONTEXT_PROFILE_MASK
 GL_DOUBLEBUFFER = SDL_GL_DOUBLEBUFFER
+GL_RED_SIZE = SDL_GL_RED_SIZE
+GL_GREEN_SIZE = SDL_GL_GREEN_SIZE
+GL_BLUE_SIZE = SDL_GL_BLUE_SIZE
 GL_DEPTH_SIZE = SDL_GL_DEPTH_SIZE
 
 GL_CONTEXT_PROFILE_CORE = SDL_GL_CONTEXT_PROFILE_CORE
--- a/pytouhou/ui/opengl/backend.pyx
+++ b/pytouhou/ui/opengl/backend.pyx
@@ -94,6 +94,9 @@ def create_window(title, x, y, width, he
     sdl.gl_set_attribute(sdl.GL_CONTEXT_PROFILE_MASK, profile)
     sdl.gl_set_attribute(sdl.GL_CONTEXT_MAJOR_VERSION, major)
     sdl.gl_set_attribute(sdl.GL_CONTEXT_MINOR_VERSION, minor)
+    sdl.gl_set_attribute(sdl.GL_RED_SIZE, 8)
+    sdl.gl_set_attribute(sdl.GL_GREEN_SIZE, 8)
+    sdl.gl_set_attribute(sdl.GL_BLUE_SIZE, 8)
     sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24 if is_legacy else 0)
     if double_buffer >= 0:
         sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, double_buffer)