From: Alexis Laferrière Date: Fri, 20 May 2016 18:35:51 +0000 (-0400) Subject: lib/gamnit & egl: extract number of color bits as attributes X-Git-Url: http://nitlanguage.org lib/gamnit & egl: extract number of color bits as attributes Signed-off-by: Alexis Laferrière --- diff --git a/lib/gamnit/display.nit b/lib/gamnit/display.nit index 69ddb41..6e7c58c 100644 --- a/lib/gamnit/display.nit +++ b/lib/gamnit/display.nit @@ -44,6 +44,15 @@ class GamnitDisplay # Only affects the desktop implementations. var show_cursor: Bool = true is writable + # Number of bits used for the red value in the color buffer + fun red_bits: Int do return 8 + + # Number of bits used for the green value in the color buffer + fun green_bits: Int do return 8 + + # Number of bits used for the blue value in the color buffer + fun blue_bits: Int do return 8 + # Prepare this display # # The implementation varies per platform. diff --git a/lib/gamnit/display_android.nit b/lib/gamnit/display_android.nit index 3ae7ee5..e9d1b4a 100644 --- a/lib/gamnit/display_android.nit +++ b/lib/gamnit/display_android.nit @@ -37,7 +37,7 @@ redef class GamnitDisplay setup_egl_display native_display # We need 8 bits per color for selection by color - select_egl_config(8, 8, 8, 0, 8, 0, 0) + select_egl_config(red_bits, green_bits, blue_bits, 0, 8, 0, 0) var format = egl_config.attribs(egl_display).native_visual_id native_window.set_buffers_geometry(0, 0, format) diff --git a/lib/gamnit/display_linux.nit b/lib/gamnit/display_linux.nit index c879577..1dbee21 100644 --- a/lib/gamnit/display_linux.nit +++ b/lib/gamnit/display_linux.nit @@ -48,7 +48,7 @@ redef class GamnitDisplay setup_egl_display x11_display if debug_gamnit then print "Setting up EGL context" - select_egl_config(8, 8, 8, 8, 8, 0, 0) + select_egl_config(red_bits, green_bits, blue_bits, 8, 8, 0, 0) setup_egl_context window_handle end