comparison pytouhou/ui/opengl/backend.pyx @ 610:1b31169dc344

Move the passthrough shader to the Framebuffer class, since it isn’t used in the use_framebuffer_blit path.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 21 Dec 2014 18:52:18 +0100
parents 23b9418e4b2f
children a6a191e371c7
comparison
equal deleted inserted replaced
609:23b9418e4b2f 610:1b31169dc344
47 47
48 48
49 cdef void discover_features() except *: 49 cdef void discover_features() except *:
50 '''Discover which features are supported by our context.''' 50 '''Discover which features are supported by our context.'''
51 51
52 global use_debug_group, use_vao, use_primitive_restart, use_framebuffer_blit, use_pack_invert 52 global use_debug_group, use_vao, use_primitive_restart, use_framebuffer_blit, use_pack_invert, use_scaled_rendering
53 global primitive_mode 53 global primitive_mode
54 global shader_header 54 global shader_header
55 global is_legacy 55 global is_legacy
56 56
57 version = epoxy_gl_version() 57 version = epoxy_gl_version()
58 is_desktop = epoxy_is_desktop_gl() 58 is_desktop = epoxy_is_desktop_gl()
59 is_legacy = is_desktop and version < 20 59 is_legacy = is_legacy or (is_desktop and version < 20)
60 60
61 use_debug_group = (is_desktop and version >= 43) or epoxy_has_gl_extension('GL_KHR_debug') 61 use_debug_group = (is_desktop and version >= 43) or epoxy_has_gl_extension('GL_KHR_debug')
62 use_vao = (is_desktop and version >= 30) or epoxy_has_gl_extension('GL_ARB_vertex_array_object') 62 use_vao = (is_desktop and version >= 30) or epoxy_has_gl_extension('GL_ARB_vertex_array_object')
63 use_primitive_restart = (is_desktop and version >= 31) 63 use_primitive_restart = (is_desktop and version >= 31)
64 use_framebuffer_blit = (is_desktop and version >= 30) 64 use_framebuffer_blit = (is_desktop and version >= 30)
65 use_pack_invert = epoxy_has_gl_extension('GL_MESA_pack_invert') 65 use_pack_invert = epoxy_has_gl_extension('GL_MESA_pack_invert')
66 use_scaled_rendering = not is_legacy #TODO: try to use the EXT framebuffer extension.
66 67
67 primitive_mode = GL_TRIANGLE_STRIP if use_primitive_restart else GL_TRIANGLES 68 primitive_mode = GL_TRIANGLE_STRIP if use_primitive_restart else GL_TRIANGLES
68 69
69 if not is_legacy: 70 if not is_legacy:
70 if is_desktop: 71 if is_desktop:
94 sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24 if is_legacy else 0) 95 sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24 if is_legacy else 0)
95 if double_buffer >= 0: 96 if double_buffer >= 0:
96 sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, double_buffer) 97 sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, double_buffer)
97 98
98 flags = sdl.WINDOW_SHOWN | sdl.WINDOW_OPENGL 99 flags = sdl.WINDOW_SHOWN | sdl.WINDOW_OPENGL
100
101 # Legacy contexts don’t support our required extensions for scaling.
99 if not is_legacy: 102 if not is_legacy:
100 flags |= sdl.WINDOW_RESIZABLE 103 flags |= sdl.WINDOW_RESIZABLE
101 104
102 window = Window(title, x, y, width, height, flags) 105 window = Window(title, x, y, width, height, flags)
103 window.gl_create_context() 106 window.gl_create_context()
104 107
105 discover_features() 108 discover_features()
106 109
107 #TODO: legacy could support one of the framebuffer extensions for resize, 110 # If we can’t use scaling but have previously created a resizable window,
108 # but for now set the window to a fixed size. 111 # recreate it unresizable.
109 if is_legacy and flags & sdl.WINDOW_RESIZABLE: 112 if not use_scaled_rendering and flags & sdl.WINDOW_RESIZABLE:
110 flags &= ~sdl.WINDOW_RESIZABLE 113 flags &= ~sdl.WINDOW_RESIZABLE
111 window = Window(title, x, y, width, height, flags) 114 window = Window(title, x, y, width, height, flags)
112 window.gl_create_context() 115 window.gl_create_context()
113 116
114 if use_debug_group: 117 if use_debug_group: