comparison pytouhou/ui/opengl/backend.pyx @ 592:19d930f9e3f0

Add the screenshot feature, using P or Home like the original game.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 23 Apr 2014 19:19:32 +0200
parents e15672733c93
children 974decb8df4f
comparison
equal deleted inserted replaced
591:2dfa4aa135d2 592:19d930f9e3f0
6 (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND, 6 (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND,
7 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST, 7 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST,
8 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY, 8 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY,
9 glPushDebugGroup, GL_DEBUG_SOURCE_APPLICATION, glPopDebugGroup, 9 glPushDebugGroup, GL_DEBUG_SOURCE_APPLICATION, glPopDebugGroup,
10 epoxy_gl_version, epoxy_is_desktop_gl, epoxy_has_gl_extension, 10 epoxy_gl_version, epoxy_is_desktop_gl, epoxy_has_gl_extension,
11 GL_PRIMITIVE_RESTART, glPrimitiveRestartIndex) 11 GL_PRIMITIVE_RESTART, glPrimitiveRestartIndex, glPixelStorei,
12 GL_PACK_INVERT_MESA)
12 13
13 14
14 GameRenderer = None 15 GameRenderer = None
15 16
16 17
45 46
46 47
47 def discover_features(): 48 def discover_features():
48 '''Discover which features are supported by our context.''' 49 '''Discover which features are supported by our context.'''
49 50
50 global use_debug_group, use_vao, use_primitive_restart, shader_header 51 global use_debug_group, use_vao, use_primitive_restart, use_pack_invert, shader_header
51 52
52 version = epoxy_gl_version() 53 version = epoxy_gl_version()
53 is_desktop = epoxy_is_desktop_gl() 54 is_desktop = epoxy_is_desktop_gl()
54 55
55 use_debug_group = (is_desktop and version >= 43) or epoxy_has_gl_extension('GL_KHR_debug') 56 use_debug_group = (is_desktop and version >= 43) or epoxy_has_gl_extension('GL_KHR_debug')
56 use_vao = (is_desktop and version >= 30) or epoxy_has_gl_extension('GL_ARB_vertex_array_object') 57 use_vao = (is_desktop and version >= 30) or epoxy_has_gl_extension('GL_ARB_vertex_array_object')
57 use_primitive_restart = (is_desktop and version >= 31) 58 use_primitive_restart = (is_desktop and version >= 31)
58 use_framebuffer_blit = (is_desktop and version >= 30) 59 use_framebuffer_blit = (is_desktop and version >= 30)
60 use_pack_invert = epoxy_has_gl_extension('GL_MESA_pack_invert')
59 61
60 if is_desktop: 62 if is_desktop:
61 # gl_FragColor isn’t supported anymore starting with GLSL 4.2. 63 # gl_FragColor isn’t supported anymore starting with GLSL 4.2.
62 if version >= 42: 64 if version >= 42:
63 version = 41 65 version = 41
111 113
112 if use_primitive_restart: 114 if use_primitive_restart:
113 glEnable(GL_PRIMITIVE_RESTART) 115 glEnable(GL_PRIMITIVE_RESTART)
114 glPrimitiveRestartIndex(0xFFFF); 116 glPrimitiveRestartIndex(0xFFFF);
115 117
118 if use_pack_invert:
119 glPixelStorei(GL_PACK_INVERT_MESA, True)
120
116 if use_debug_group: 121 if use_debug_group:
117 glPopDebugGroup() 122 glPopDebugGroup()
118 123
119 if swap_interval is not None: 124 if swap_interval is not None:
120 try: 125 try: