0

I recently managed to get pysdl2 (0.9.3) working on a Windows 8.1 (64-bit) machine (along with the extension modules gfx, mixer, ttf and image). Everything worked fine, including all demos in pysdl2's example folder.

However, when I try to run the same code with the same SDL2 DLL versions on Windows 7 (64-bit), I get the error message:

sdl2.ext.common.SDLrror: 'directx not available'

After calling

sdl2.ext.init()

I tried installing the Directx End User Runtimes (June 2010) and even the complete SDK, but to no avail. I also tried changing the SDL_VIDEODRIVER environment variable to something else than directx, but this does not work either (apparently 'windib' is not available as an option anymore in SDL2).

I know SDL2 is probably looking for Directx 9, which has been completely replaced by Directx 11 nowadays, but after installing the end user runtimes, my system should have Directx 9 at its disposal again. In addition, if this was the cause of the problem, then it also shouldn't have worked on Windows 8.1, since this OS is even newer and is even less likely to carry DX9?

EDIT: On a sidenote, pygame (which uses the older SDL 1.2 libraries) is able to find directx as

pygame.display.get_driver()

outputs:

'directx'

so there must be something wrong with the internal configuration of the SDL2 libraries.

4
  • Aside: The "DirectX End-User Runtime" never actually installs "DirectX" anymore. Both WIndows 7 and Windows 8.1 have 'DirectX 9.0c' in the operating system always, and you can't uninstall or install it. All the DXSETUP package does is install D3DX9 and it's kin. See Not So Direct Setup May 1, 2015 at 16:02
  • Is DirectX listed in the detected drivers, if you check the detected drivers: val = sdl2.video.SDL_GetNumVideoDrivers(); for i in range(val): print(sdl2.video.SDL_GetVideoDriver(i))
    – Marcus
    May 4, 2015 at 17:29
  • No, that only lists 'windows' and 'dummy'. May 6, 2015 at 7:35
  • I think it is just this machine. I tested it on another Windows 7 Pc and it worked fine there. The weird thing is that pygame does work in directx mode on the machine that refuses to run sdl2. I hope it is the exception and most Windows 7 pc's will not experience any trouble with this... May 7, 2015 at 11:29

1 Answer 1

1

I had the same error directx not available on Windows XP and worked around it by setting the environment variable SDL_VIDEODRIVER to windows using

set SDL_VIDEODRIVER=windows 

on the command prompt before starting my Python module. You could also do this directly from Python with

os.environ['SDL_VIDEODRIVER'] = 'windows'

Note that windows is the only supported driver for Windows in SDL2. directx and windib are only valid for SDL1.2.

I ran into this problem because I was importing both Pygame and PySDL2. It turns out that the Pygame module (which uses SDL1.2) changes SDL_VIDEODRIVER to directx when it is imported.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.