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	Sun Oct 19 17:22:26 2014 +0200
+++ b/pytouhou/interfaces/eosd.py	Sat Oct 25 18:49:41 2014 +0200
@@ -17,16 +17,16 @@
 
 
 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	Sun Oct 19 17:22:26 2014 +0200
+++ b/pytouhou/interfaces/sample.py	Sat Oct 25 18:49:41 2014 +0200
@@ -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	Sun Oct 19 17:22:26 2014 +0200
+++ b/pytouhou/ui/opengl/gamerenderer.pyx	Sat Oct 25 18:49:41 2014 +0200
@@ -27,6 +27,7 @@
 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 @@
 
 
 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 @@
             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	Sun Oct 19 17:22:26 2014 +0200
+++ b/pytouhou/ui/window.pxd	Sat Oct 25 18:49:41 2014 +0200
@@ -23,6 +23,7 @@
     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	Sun Oct 19 17:22:26 2014 +0200
+++ b/pytouhou/ui/window.pyx	Sat Oct 25 18:49:41 2014 +0200
@@ -77,17 +77,19 @@
 
 
 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	Sun Oct 19 17:22:26 2014 +0200
+++ b/scripts/pytouhou	Sat Oct 25 18:49:41 2014 +0200
@@ -280,8 +280,8 @@
 
 
 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,