comparison pytouhou/ui/opengl/backend.pyx @ 589:0768122da817

Add a frameskip option, and use swap interval to implement it.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 10 Oct 2014 15:59:11 +0200
parents 6c9d8a3d853f
children e15672733c93
comparison
equal deleted inserted replaced
588:7a82c4b52b16 589:0768122da817
1 from pytouhou.lib import sdl
1 from pytouhou.lib cimport sdl 2 from pytouhou.lib cimport sdl
2 from pytouhou.lib.sdl cimport Window 3 from pytouhou.lib.sdl cimport Window
3 4
4 from pytouhou.lib.opengl cimport \ 5 from pytouhou.lib.opengl cimport \
5 (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND, 6 (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND,
72 version = 20 73 version = 20
73 glsl_version = {20: '100', 30: '300 es'}[version] 74 glsl_version = {20: '100', 30: '300 es'}[version]
74 shader_header = '#version %s\n\nprecision highp float;\n\n' % glsl_version 75 shader_header = '#version %s\n\nprecision highp float;\n\n' % glsl_version
75 76
76 77
77 def create_window(title, x, y, width, height): 78 def create_window(title, x, y, width, height, swap_interval):
78 '''Create a window (using SDL) and an OpenGL context.''' 79 '''Create a window (using SDL) and an OpenGL context.'''
79 80
80 sdl.gl_set_attribute(sdl.GL_CONTEXT_PROFILE_MASK, profile) 81 sdl.gl_set_attribute(sdl.GL_CONTEXT_PROFILE_MASK, profile)
81 sdl.gl_set_attribute(sdl.GL_CONTEXT_MAJOR_VERSION, major) 82 sdl.gl_set_attribute(sdl.GL_CONTEXT_MAJOR_VERSION, major)
82 sdl.gl_set_attribute(sdl.GL_CONTEXT_MINOR_VERSION, minor) 83 sdl.gl_set_attribute(sdl.GL_CONTEXT_MINOR_VERSION, minor)
113 glPrimitiveRestartIndex(0xFFFF); 114 glPrimitiveRestartIndex(0xFFFF);
114 115
115 if use_debug_group: 116 if use_debug_group:
116 glPopDebugGroup() 117 glPopDebugGroup()
117 118
119 if swap_interval is not None:
120 try:
121 sdl.gl_set_swap_interval(swap_interval)
122 except sdl.SDLError:
123 pass
124
118 return window 125 return window