[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] [BUG] pygame-ctypes



Lenard Lindstrom wrote:

While trying to run 20,000 Light Years in Space, version 1.2 I get the following exception:

Traceback (most recent call last):
File "lightyears.py", line 23, in ?
startup.Main()
File "C:\prg\LightYears\code\startup.py", line 81, in Main
main.Main()
File "C:\prg\LightYears\code\main.py", line 103, in Main
quit = Main_Menu_Loop(n, clock, screen, (width, height))
File "C:\prg\LightYears\code\main.py", line 125, in Main_Menu_Loop
main_menu = current_menu = menu.Menu([
File "C:\prg\LightYears\code\menu.py", line 31, in __init__
(discard1, discard2,
File "C:\prg\LightYears\code\menu.py", line 149, in __Draw
extra.Tile_Texture(surf, "greenrust.jpg", r)
File "C:\prg\LightYears\code\extra.py", line 50, in Tile_Texture
output.set_clip(rect)
File "C:\PRG\PYGAME-CTYPES\CTYPES-SOC\pygame\surface.py", line 825, in set_cli
p
SDL_SetClipRect(self._surf, rect)
ctypes.ArgumentError: argument 2: exceptions.TypeError: expected LP_SDL_Rect instance instead of _RectProxy


Thanks, now fixed in r944.

Since SDL_SetClipRect has argtypes defined _RectProxy's _as_parameter_ is not used. A from_param method will not help here either, as it must belong to the type object in the argtypes list, not the object passed as an argument.


Yep sorry, the _as_parameter_ was cruft from some experimentation, it's removed now. The RectProxy is used when rects have negative width or height, which is supported by Pygame but not SDL. There's no nice way to handle this conversion, as many SDL functions modify the rectangle passed in (e.g., the blit functions). The onus for normalizing the rectangle before grabbing "_r" (the SDL_Rect) is therefore on the caller (Pygame), and there are some places I haven't addressed this yet.

20k LYIS now works great on my computer... This game was really addictive in the Pyweek comp. There's a large dump of exceptions when it quits, I think this is just the audio thread not shutting down correctly (may be a Pygame error, it's on my todo list).

Alex.