diff 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
line wrap: on
line diff
--- a/pytouhou/ui/opengl/backend.pyx
+++ b/pytouhou/ui/opengl/backend.pyx
@@ -1,3 +1,4 @@
+from pytouhou.lib import sdl
 from pytouhou.lib cimport sdl
 from pytouhou.lib.sdl cimport Window
 
@@ -74,7 +75,7 @@ def discover_features():
         shader_header = '#version %s\n\nprecision highp float;\n\n' % glsl_version
 
 
-def create_window(title, x, y, width, height):
+def create_window(title, x, y, width, height, swap_interval):
     '''Create a window (using SDL) and an OpenGL context.'''
 
     sdl.gl_set_attribute(sdl.GL_CONTEXT_PROFILE_MASK, profile)
@@ -115,4 +116,10 @@ def create_window(title, x, y, width, he
     if use_debug_group:
         glPopDebugGroup()
 
+    if swap_interval is not None:
+        try:
+            sdl.gl_set_swap_interval(swap_interval)
+        except sdl.SDLError:
+            pass
+
     return window