changeset 596:ab131d04987d

Fix a regression introduced in the previous commit when the interface has a different resolution than 640×480 and framebuffer_blit is enabled.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 25 Oct 2014 18:49:41 +0200
parents b7b4a234bf70
children 244c99c568c8
files pytouhou/interfaces/eosd.py pytouhou/interfaces/sample.py pytouhou/ui/opengl/gamerenderer.pyx pytouhou/ui/window.pxd pytouhou/ui/window.pyx scripts/pytouhou
diffstat 6 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/interfaces/eosd.py
+++ b/pytouhou/interfaces/eosd.py
@@ -17,16 +17,16 @@ from pytouhou.game.text import Text, Cou
 
 
 class EoSDInterface(object):
+    width = 640
+    height = 480
+    game_pos = (32, 16)
+
     def __init__(self, resource_loader, player_state):
         self.game = None
         self.player_state = player_state
         front = resource_loader.get_single_anm('front.anm')
         self.ascii_anm = resource_loader.get_single_anm('ascii.anm')
 
-        self.width = 640
-        self.height = 480
-        self.game_pos = (32, 16)
-
         self.highscore = 1000000 #TODO: read score.dat
         self.items = ([Effect((0, 32 * i), 6, front) for i in range(15)] +
                       [Effect((416 + 32 * i, 32 * j), 6, front) for i in range(7) for j in range(15)] +
--- a/pytouhou/interfaces/sample.py
+++ b/pytouhou/interfaces/sample.py
@@ -13,15 +13,15 @@
 ##
 
 class SampleInterface(object):
+    width = 384
+    height = 448
+    game_pos = (0, 0)
+
     def __init__(self, resource_loader, player_state):
         self.game = None
         self.player_state = player_state
         self.ascii_anm = resource_loader.get_single_anm('ascii.anm') #XXX
 
-        self.width = 384
-        self.height = 448
-        self.game_pos = (0, 32)
-
         self.items = []
         self.level_start = []
         self.labels = {}
--- a/pytouhou/ui/opengl/gamerenderer.pyx
+++ b/pytouhou/ui/opengl/gamerenderer.pyx
@@ -27,6 +27,7 @@ from pytouhou.lib.opengl cimport \
 from pytouhou.utils.matrix cimport mul, new_identity
 from pytouhou.utils.maths cimport perspective, setup_camera, ortho_2d
 from pytouhou.game.text cimport NativeText, GlyphCollection
+from pytouhou.ui.window cimport Window
 from .shaders.eosd import GameShader, BackgroundShader, PassthroughShader
 from .renderer cimport Texture
 from .backend cimport is_legacy, use_debug_group, use_pack_invert
@@ -37,7 +38,7 @@ Color = namedtuple('Color', 'r g b a')
 
 
 cdef class GameRenderer(Renderer):
-    def __init__(self, resource_loader, _):
+    def __init__(self, resource_loader, Window window):
         Renderer.__init__(self, resource_loader)
 
         if not is_legacy:
@@ -46,7 +47,7 @@ cdef class GameRenderer(Renderer):
             self.interface_shader = self.game_shader
             self.passthrough_shader = PassthroughShader()
 
-            self.framebuffer = Framebuffer(0, 0, 640, 480)
+            self.framebuffer = Framebuffer(0, 0, window.width, window.height)
 
 
     def __dealloc__(self):
--- a/pytouhou/ui/window.pxd
+++ b/pytouhou/ui/window.pxd
@@ -23,6 +23,7 @@ cdef class Window:
     cdef Runner runner
     cdef Clock clock
     cdef int frame, frameskip
+    cdef int width, height
 
     cdef void set_size(self, int width, int height) nogil
     cpdef set_runner(self, Runner runner=*)
--- a/pytouhou/ui/window.pyx
+++ b/pytouhou/ui/window.pyx
@@ -77,17 +77,19 @@ cdef class Runner:
 
 
 cdef class Window:
-    def __init__(self, backend, long fps_limit=-1, frameskip=1):
+    def __init__(self, backend, int width=640, int height=480, long fps_limit=-1, frameskip=1):
         if backend is not None:
             self.win = backend.create_window(
                 'PyTouhou',
                 sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED,
-                640, 480, #XXX
+                width, height,
                 frameskip)
 
         self.clock = Clock(fps_limit)
         self.frame = 0
         self.frameskip = frameskip
+        self.width = width
+        self.height = height
 
 
     cdef void set_size(self, int width, int height) nogil:
--- a/scripts/pytouhou
+++ b/scripts/pytouhou
@@ -280,8 +280,8 @@ def main(window, path, data, stage_num, 
 
 
 with SDL(sound=args.no_sound):
-    window = Window(backend, fps_limit=args.fps_limit,
-                    frameskip=args.frameskip)
+    window = Window(backend, Interface.width, Interface.height,
+                    fps_limit=args.fps_limit, frameskip=args.frameskip)
 
     main(window, args.path, tuple(args.data), args.stage, args.rank,
          args.character, args.replay, args.save_replay, args.skip_replay,