py-sdl / py-sdl2

Python ctypes wrapper around SDL2
Other
303 stars 49 forks source link

SDL_SetHint wrong type #198

Closed distantforest1 closed 2 years ago

distantforest1 commented 2 years ago

What doesn't work? Firstly apologies if I'm doing something wrong here, I'm still new to SDL. I'm attempting to run the SDL_SetHint function as follows:

sdl2.SDL_SetHint(sdl2.SDL_HINT_RENDER_SCALE_QUALITY, "2") Basing it off the documentation here: https://wiki.libsdl.org/SDL_SetHint

However I get this error:

File "D:\Code\pysdl2\examples\particles.py", line 201, in run
    sdl2.SDL_SetHint(sdl2.SDL_HINT_RENDER_SCALE_QUALITY, "2")
ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type

Platform (if relevant):

What am I doing wrong here?

a-hurst commented 2 years ago

Hi @keenfoong, I think the issue is that the second argument should be bytes type instead of str, since SDL2 generally expects UTF-8 encoded byte strings for string arguments.

Try the same code again as sdl2.SDL_SetHint(sdl2.SDL_HINT_RENDER_SCALE_QUALITY, b"2") and see if that works!

distantforest1 commented 2 years ago

That worked thanks!