sdl2.ext.TextureSpriteRenderSystem.renderer doesn't exist
The docs say that there's a
renderer property in
TextureSpriteRenderSystem, and some parts of pysdl2 think so too. It seems that it has been replaced with a
_renderer at some point, but some pieces of code haven't been refactored to reflect that.
import ctypes from sdl2 import * import sdl2.ext sdl2.ext.init() window = sdl2.ext.Window("Test", (640, 480)) render_system = sdl2.ext.TextureSpriteRenderSystem(window) sprite_factory = sdl2.ext.SpriteFactory(renderer = render_system) foo_bmp = sprite_factory.from_image(r"foo.bmp") window.show() done = False while not done: event = SDL_Event() while SDL_PollEvent(ctypes.byref(event)): if event.type == SDL_QUIT: done = True render_system.render(foo_bmp) sdl2.ext.quit()
The code above fails with:
Traceback (most recent call last): File "sdltest.py", line 11, in <module> foo_bmp = sprite_factory.from_image(r"foo.bmp") File "../../../sdl2/ext/sprite.py", line 416, in from_image return self.from_surface(load_image(fname), True) File "../../../sdl2/ext/sprite.py", line 426, in from_surface texture = render.SDL_CreateTextureFromSurface(renderer.renderer, AttributeError: 'TextureSpriteRenderSystem' object has no attribute 'renderer'
Creating a SpriteFactory like this:
sprite_factory = sdl2.ext.SpriteFactory(renderer = render_system._renderer)