comparison pytouhou/ui/opengl/backend.pyx @ 557:0f2af7552462

Don’t hardcode GLSL version in our shaders, instead make them dependent on GL version.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 30 May 2014 16:40:36 +0200
parents c34b23e29d16
children 94725968dabb
comparison
equal deleted inserted replaced
556:c34b23e29d16 557:0f2af7552462
9 9
10 GameRenderer = None 10 GameRenderer = None
11 11
12 12
13 def init(options): 13 def init(options):
14 global flavor, version, major, minor, double_buffer, is_legacy, GameRenderer 14 global flavor, version, major, minor, double_buffer, is_legacy, shader_header, GameRenderer
15 15
16 flavor_name = options['flavor'] 16 flavor_name = options['flavor']
17 assert flavor_name in ('core', 'es', 'compatibility', 'legacy') 17 assert flavor_name in ('core', 'es', 'compatibility', 'legacy')
18 flavor = (sdl.GL_CONTEXT_PROFILE_CORE if flavor_name == 'core' else 18 flavor = (sdl.GL_CONTEXT_PROFILE_CORE if flavor_name == 'core' else
19 sdl.GL_CONTEXT_PROFILE_ES if flavor_name == 'es' else 19 sdl.GL_CONTEXT_PROFILE_ES if flavor_name == 'es' else
26 26
27 maybe_double_buffer = options['double-buffer'] 27 maybe_double_buffer = options['double-buffer']
28 double_buffer = maybe_double_buffer if maybe_double_buffer is not None else -1 28 double_buffer = maybe_double_buffer if maybe_double_buffer is not None else -1
29 29
30 is_legacy = flavor_name == 'legacy' 30 is_legacy = flavor_name == 'legacy'
31
32 try:
33 glsl_version = {'2.0': 110, '2.1': 120, '3.0': 130, '3.1': 140, '3.2': 150}[version]
34 except KeyError:
35 glsl_version = 100 * major + 10 * minor
36 shader_header = '#version %d\n' % glsl_version
31 37
32 #TODO: check for framebuffer/renderbuffer support. 38 #TODO: check for framebuffer/renderbuffer support.
33 39
34 from pytouhou.ui.opengl.gamerenderer import GameRenderer 40 from pytouhou.ui.opengl.gamerenderer import GameRenderer
35 41