Mercurial > touhou
comparison pytouhou/ui/opengl/backend.pyx @ 585:e0166cda75d5
Use primitive-restart to lower the size of our ibo, if supported.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 08 Oct 2014 14:28:37 +0200 |
parents | 47cf4e3d159d |
children | 6c9d8a3d853f |
comparison
equal
deleted
inserted
replaced
584:538b52aafbca | 585:e0166cda75d5 |
---|---|
4 from pytouhou.lib.opengl cimport \ | 4 from pytouhou.lib.opengl cimport \ |
5 (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND, | 5 (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND, |
6 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST, | 6 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST, |
7 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY, | 7 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY, |
8 glPushDebugGroup, GL_DEBUG_SOURCE_APPLICATION, glPopDebugGroup, | 8 glPushDebugGroup, GL_DEBUG_SOURCE_APPLICATION, glPopDebugGroup, |
9 epoxy_gl_version, epoxy_is_desktop_gl, epoxy_has_gl_extension) | 9 epoxy_gl_version, epoxy_is_desktop_gl, epoxy_has_gl_extension, |
10 GL_PRIMITIVE_RESTART, glPrimitiveRestartIndex) | |
10 | 11 |
11 | 12 |
12 GameRenderer = None | 13 GameRenderer = None |
13 | 14 |
14 | 15 |
43 | 44 |
44 | 45 |
45 def discover_features(): | 46 def discover_features(): |
46 '''Discover which features are supported by our context.''' | 47 '''Discover which features are supported by our context.''' |
47 | 48 |
48 global use_debug_group, use_vao, shader_header | 49 global use_debug_group, use_vao, use_primitive_restart, shader_header |
49 | 50 |
50 version = epoxy_gl_version() | 51 version = epoxy_gl_version() |
51 is_desktop = epoxy_is_desktop_gl() | 52 is_desktop = epoxy_is_desktop_gl() |
52 | 53 |
53 use_debug_group = (is_desktop and version >= 43) or epoxy_has_gl_extension('GL_KHR_debug') | 54 use_debug_group = (is_desktop and version >= 43) or epoxy_has_gl_extension('GL_KHR_debug') |
54 use_vao = (is_desktop and version >= 30) or epoxy_has_gl_extension('GL_ARB_vertex_array_object') | 55 use_vao = (is_desktop and version >= 30) or epoxy_has_gl_extension('GL_ARB_vertex_array_object') |
56 use_primitive_restart = (is_desktop and version >= 31) | |
55 | 57 |
56 if is_desktop: | 58 if is_desktop: |
57 # gl_FragColor isn’t supported anymore starting with GLSL 4.2. | 59 # gl_FragColor isn’t supported anymore starting with GLSL 4.2. |
58 if version >= 42: | 60 if version >= 42: |
59 version = 41 | 61 version = 41 |
103 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) | 105 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) |
104 glEnableClientState(GL_COLOR_ARRAY) | 106 glEnableClientState(GL_COLOR_ARRAY) |
105 glEnableClientState(GL_VERTEX_ARRAY) | 107 glEnableClientState(GL_VERTEX_ARRAY) |
106 glEnableClientState(GL_TEXTURE_COORD_ARRAY) | 108 glEnableClientState(GL_TEXTURE_COORD_ARRAY) |
107 | 109 |
110 if use_primitive_restart: | |
111 glEnable(GL_PRIMITIVE_RESTART) | |
112 glPrimitiveRestartIndex(0xFFFF); | |
113 | |
108 if use_debug_group: | 114 if use_debug_group: |
109 glPopDebugGroup() | 115 glPopDebugGroup() |
110 | 116 |
111 return window | 117 return window |