[pypy-svn] r54817 - in pypy/dist/pypy/rlib/rsdl: . test

arigo at codespeak.net arigo at codespeak.net
Sat May 17 12:51:02 CEST 2008


Author: arigo
Date: Sat May 17 12:51:01 2008
New Revision: 54817

Modified:
   pypy/dist/pypy/rlib/rsdl/RSDL.py
   pypy/dist/pypy/rlib/rsdl/test/test_basic.py
Log:
(karlb, cami, arigo)
Basic support for creating and inspecting surfaces.


Modified: pypy/dist/pypy/rlib/rsdl/RSDL.py
==============================================================================
--- pypy/dist/pypy/rlib/rsdl/RSDL.py	(original)
+++ pypy/dist/pypy/rlib/rsdl/RSDL.py	Sat May 17 12:51:01 2008
@@ -18,7 +18,8 @@
 
     INIT_VIDEO = platform.ConstantInteger('SDL_INIT_VIDEO')
 
-    Surface = platform.Struct('SDL_Surface', [])
+    Surface = platform.Struct('SDL_Surface', [('w', rffi.INT),
+                                              ('h', rffi.INT)])
 
 globals().update(platform.configure(CConfig))
 
@@ -28,3 +29,9 @@
 SetVideoMode = external('SDL_SetVideoMode', [rffi.INT, rffi.INT,
                                              rffi.INT, Uint32],
                         lltype.Ptr(Surface))
+CreateRGBSurface = external('SDL_CreateRGBSurface', [Uint32, rffi.INT,
+                                                     rffi.INT, rffi.INT,
+                                                     Uint32, Uint32,
+                                                     Uint32, Uint32],
+                            lltype.Ptr(Surface))
+FreeSurface = external('SDL_FreeSurface', [lltype.Ptr(Surface)], lltype.Void)

Modified: pypy/dist/pypy/rlib/rsdl/test/test_basic.py
==============================================================================
--- pypy/dist/pypy/rlib/rsdl/test/test_basic.py	(original)
+++ pypy/dist/pypy/rlib/rsdl/test/test_basic.py	Sat May 17 12:51:01 2008
@@ -1,5 +1,7 @@
 import py
 from pypy.rlib.rsdl import RSDL
+from pypy.rlib.rarithmetic import r_uint
+from pypy.rpython.lltypesystem import rffi
 
 
 def test_sdl_init():
@@ -11,3 +13,16 @@
     surface = RSDL.SetVideoMode(640, 480, 32, 0)
     assert surface
     RSDL.Quit()
+
+def test_surface_basic():
+    assert RSDL.Init(RSDL.INIT_VIDEO) >= 0
+    surface = RSDL.CreateRGBSurface(0, 150, 50, 32,
+                                    r_uint(0x000000FF),
+                                    r_uint(0x0000FF00),
+                                    r_uint(0x00FF0000),
+                                    r_uint(0xFF000000))
+    assert surface
+    assert rffi.getintfield(surface, 'c_w') == 150
+    assert rffi.getintfield(surface, 'c_h') == 50
+    RSDL.FreeSurface(surface)
+    RSDL.Quit()



More information about the Pypy-commit mailing list