comparison pytouhou/ui/opengl/backend.pyx @ 636:4fa0a8e7d941

Add a GLFW implementation of gui.Window.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 14 May 2017 20:14:03 +0100
parents 80687f258001
children
comparison
equal deleted inserted replaced
635:80687f258001 636:4fa0a8e7d941
1 cimport pytouhou.lib.gui as gui 1 cimport pytouhou.lib.gui as gui
2 from pytouhou.lib.gui import Error as GUIError 2 from pytouhou.lib.gui import Error as GUIError
3 from .backend_sdl import create_sdl_window 3 from .backend_sdl import create_sdl_window
4 from .backend_glfw import create_glfw_window
4 5
5 from pytouhou.lib.opengl cimport \ 6 from pytouhou.lib.opengl cimport \
6 (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND, 7 (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND,
7 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST, 8 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST,
8 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY, 9 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY,
21 working. 22 working.
22 ''' 23 '''
23 24
24 cdef str flavor 25 cdef str flavor
25 26
26 global profile, major, minor, double_buffer, is_legacy, GameRenderer 27 global profile, major, minor, double_buffer, is_legacy, GameRenderer, use_glfw
27 28
29 use_glfw = options['frontend'] == 'glfw'
28 flavor = options['flavor'] 30 flavor = options['flavor']
29 assert flavor in ('core', 'es', 'compatibility', 'legacy') 31 assert flavor in ('core', 'es', 'compatibility', 'legacy')
30 profile = flavor 32 profile = flavor
31 version = str(options['version']) 33 version = str(options['version'])
32 assert len(version) == 3 and version[1] == '.' 34 assert len(version) == 3 and version[1] == '.'
87 89
88 def create_window(title, x, y, width, height, swap_interval): 90 def create_window(title, x, y, width, height, swap_interval):
89 '''Create a window (using SDL) and an OpenGL context.''' 91 '''Create a window (using SDL) and an OpenGL context.'''
90 92
91 cdef gui.Window window 93 cdef gui.Window window
92 window = create_sdl_window(title, x, y, width, height) 94 if use_glfw:
95 window = create_glfw_window(title, width, height)
96 else:
97 window = create_sdl_window(title, x, y, width, height)
93 window.create_gl_context() 98 window.create_gl_context()
94 discover_features() 99 discover_features()
95 100
96 if use_debug_group: 101 if use_debug_group:
97 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "OpenGL initialisation") 102 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "OpenGL initialisation")