Questions tagged [pysdl2]

PySDL2 is a Python wrapper around version 2.0 of the cross-platform multimedia library SDL. PySDL2 is designed to provide Python code with low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.

PySDL2 is a Python wrapper around version 2.0 of the cross-platform multimedia library SDL. PySDL2 is designed to provide Python code with low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.

PySDL2 has been released as public domain work, and thus has no licensing restrictions. It does not rely on any additional C code, choosing to wrap the SDL 2.0 library using the ctypes Python module.

PySDL2 also offers support for the following SDL-related libraries:

Useful Links

60 questions
2
votes
1 answer

Improve sprites rendering performance?

I'm looking for a way how to improve performance of PySDL2 rendering large amount of big sprites. Bellow is my attempt, trying to use hardware rendering as much as possible: import sdl2.ext as sdl2ext, sdl2 import sys from random import randint def…
David Unric
  • 6,921
  • 1
  • 28
  • 62
2
votes
2 answers

How to get mouse position using PySDL2?

Do not understand at all how to achieve getting the mouse's position except by listening for events, but in the circumstance where the event queue is empty, how is this achieved? The documentation for pysdl for pygamers suggests using…
Jonline
  • 1,499
  • 2
  • 20
  • 49
2
votes
1 answer

PySDL2: Renderer or Window Surface for handling colors and text?

My question concerns the sdl2.ext.Renderer mainly, and has to do with a problem I've encountered when trying to render sprites on a sdl2.ext.Window surface. So right now, for coloring my background on an SDL2 Window, I make the following call:…
Micrified
  • 2,632
  • 3
  • 30
  • 45
2
votes
1 answer

SDL2 pixel graphics pipeline

I am new to SDL/SDL2, with little experience in C/C++, some with pygame, pyglet and PySide, and now I am trying PySDL2 in hope to find faster Processing alternative. Processing is for drawing, but there is a straightforward API for direct pixel…
anatoly techtonik
  • 17,421
  • 8
  • 111
  • 131
1
vote
0 answers

PySDL2 display grayscale numpy array on window surface

I have a grayscale image converted into numpy array. I am trying to render this image on the sdl2 window surface. sdl2.ext.init() self.window = sdl2.ext.Window("Hello World!", size=(W, H)) self.window.show() self.events = sdl2.ext.get_events() …
rpathak
  • 11
  • 1
1
vote
0 answers

PySDL2 LockTexture and modify pixels

I can't find any valuable example of locking a texture and modifying pixels in PySDL2 Here's my code : def run(): sdl2.ext.init() window = SDL_CreateWindow(b"test" sdl2.SDL_WINDOWPOS_CENTERED, sdl2.SDL_WINDOWPOS_CENTERED, 1024, 768,…
iliak
  • 51
  • 1
  • 4
1
vote
0 answers

Not receiving WM_DPICHANGED in SDL application

I'm trying to write a DPI aware application for Windows 10 with SDL2 using the PySDL2 bindings. For now I don't care about supporting any other operating systems or Windows versions older than the Anniversary Update. The problem is, that I don't…
Rojetto
  • 13
  • 4
1
vote
0 answers

Different sdl2 versions. How to use pip3 installed version instead of the debian version?

For SDL_GetVersion, the SDL2 Wiki states that : If you are linking to SDL dynamically, then it is possible that the current version will be different than the version you compiled against. This function returns the current version, while …
Sun Bear
  • 5,117
  • 5
  • 30
  • 71
1
vote
2 answers

Draw outline circle with sdl2

TL;DR: Using (py)sdl2, I am trying to draw a circle outline of which the interior is transparent and thus shows objects drawn behind it. Basically I need to find a way to erase the pixels of the interior of a filled circle (or draw them over…
Daniel Schreij
  • 663
  • 6
  • 22
1
vote
0 answers

Python - Black screen afther re-opening pygame application

I created a simple tile based game with python pygame and the android subset. When I exit the app on my android device and I re-open it I see a black screen, if I close the program form the 'tabs' then the game will work again, does anybody know…
Mirco De Zorzi
  • 66
  • 1
  • 11
1
vote
0 answers

How to horizontally (or vertically) flip the contents of an SDL2 window with PySDL2?

I would like to reflect the entire contents of and SDL2 Window across either or both of it's vertical or horizontal axes, using Python and PySDL2. So far I can get it to here: # window is an SDL_Window object created at runtime screen_px =…
Jonline
  • 1,499
  • 2
  • 20
  • 49
1
vote
1 answer

How to display the text in SDL2.ext?

How to work with the text in the SOM 2. There is a code. I do not understand what went wrong. bmpfont = sdl2.ext.BitmapFont(surface, (width, height)) software_renderer = sdl2.ext.SoftwareSpriteRenderSystem(window) factory =…
1
vote
1 answer

How to ensure an SDL2 fullscreen window is ready with Python (pysdl2)?

When generating a new fullscreen window, vis-a-vis: sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO) window = sdl2.ext.Window('win_name', (x_size, y_size), (0, 0), <>) If I begin loading resources, or blitting to the graphics buffer immediately, the…
Jonline
  • 1,499
  • 2
  • 20
  • 49
1
vote
1 answer

Pysdl2 stuck in tutorial

I have been doing this tutorial http://pysdl2.readthedocs.org/en/latest/tutorial/pong.html and i am stuck in the create world part of the tutorial (I would appreciate if anyone can wrap it up or give me the source code to the tutorial as i seem to…
1
vote
2 answers

How can I get python3.4 to find the PySDL2 module I downloaded on win7?

I downloaded pySDL2 (from https://bitbucket.org/marcusva/py-sdl2/downloads) and unzipped the SDL2 package to my folder C:\Python34\Lib\site-packages\PySDL2-0.9.3, which has a subfolder sdl2 which has a subfolder ext. I also copied a 'hello world'…
user1067305
  • 2,561
  • 5
  • 22
  • 28