changeset 108:c9584f25067b

- fixed issue #19: the sdl2.ext.TextureSpriteRenderer and sdl2.ext.SoftwareSpriteRenderer misinterpret the x and y arguments, when set to 0. - fixed sdl2.SDL_GL_GetDrawableSize() function for non-hg SDL2 versions
author Marcus von Appen <marcus@sysfault.org>
date Tue, 15 Oct 2013 08:22:51 +0200
parents d5267c0b82a5
children 2d125a97e1c6
files sdl2/ext/sprite.py sdl2/video.py
diffstat 2 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/sdl2/ext/sprite.py	Tue Oct 15 07:58:23 2013 +0200
+++ b/sdl2/ext/sprite.py	Tue Oct 15 08:22:51 2013 +0200
@@ -624,8 +624,11 @@
                 r.y = y + sp.y
                 blit_surface(sp.surface, None, imgsurface, r)
         else:
-            r.x = x or sprites.x
-            r.y = y or sprites.y
+            r.x = sprites.x
+            r.y = sprites.y
+            if x is not None and y is not None:
+                r.x = x
+                r.y = y
             surface.SDL_BlitSurface(sprites.surface, None, self.surface, r)
         video.SDL_UpdateWindowSurface(self.window)
 
@@ -682,9 +685,11 @@
                 if rcopy(renderer, sp.texture, None, r) == -1:
                     raise SDLError()
         else:
-            if x is None or y is None:
-                r.x = sprites.x
-                r.y = sprites.y
-                r.w, r.h = sprites.size
+            r.x = sprites.x
+            r.y = sprites.y
+            r.w, r.h = sprites.size
+            if x is not None and y is not None:
+                r.x = x
+                r.y = y
             render.SDL_RenderCopy(self.sdlrenderer, sprites.texture, None, r)
         render.SDL_RenderPresent(self.sdlrenderer)
--- a/sdl2/video.py	Tue Oct 15 07:58:23 2013 +0200
+++ b/sdl2/video.py	Tue Oct 15 08:22:51 2013 +0200
@@ -1,6 +1,6 @@
 from ctypes import Structure, POINTER, c_int, c_void_p, c_char_p, c_float, \
     py_object
-from .dll import _bind
+from .dll import _bind, nullfunc
 from .stdinc import Uint16, Uint32, SDL_bool
 from .rect import SDL_Rect
 from .surface import SDL_Surface
@@ -250,5 +250,5 @@
 SDL_GL_GetSwapInterval = _bind("SDL_GL_GetSwapInterval", None, c_int)
 SDL_GL_SwapWindow = _bind("SDL_GL_SwapWindow", [POINTER(SDL_Window)])
 SDL_GL_DeleteContext = _bind("SDL_GL_DeleteContext", [SDL_GLContext])
-SDL_GL_GetDrawableSize = _bind("SDL_GL_GetDrawableSize", [POINTER(SDL_Window), POINTER(c_int), POINTER(c_int)])
+SDL_GL_GetDrawableSize = _bind("SDL_GL_GetDrawableSize", [POINTER(SDL_Window), POINTER(c_int), POINTER(c_int)], optfunc=nullfunc)