Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create renderer when compiled using nix #196

Open
schell opened this issue May 22, 2019 · 2 comments
Open

Cannot create renderer when compiled using nix #196

schell opened this issue May 22, 2019 · 2 comments

Comments

@schell
Copy link
Contributor

schell commented May 22, 2019

I'm running into a funny error where I'm not able to create a renderer. This error only happens when building using nix (and I'm fairly new to nix so this could be a simple dependency gotcha). The same program compiled with stack builds and runs just fine. Here's the error that I'm getting:

SDLCallFailed {sdlExceptionCaller = "SDL.Video.createRenderer", sdlFunction = "SDL_CreateRenderer", sdlExceptionError = "Couldn't find matching render driver"}

And for debugging, given this code:

  let rcfg = SDL.RendererConfig
               { SDL.rendererType = SDL.AcceleratedVSyncRenderer
               , SDL.rendererTargetTexture = True
               }
  liftIO $ do
    print rcfg
    putStrLn ""
  SDL.getRenderDriverInfo
    >>= liftIO . mapM (\i -> print i >> putStrLn "")
  r <- SDL.createRenderer win (-1) rcfg
  ...

I get this output:

RendererConfig {rendererType = AcceleratedVSyncRenderer, rendererTargetTexture = True}

RendererInfo {rendererInfoName = "opengl", rendererInfoFlags = RendererConfig {rendererType = AcceleratedVSyncRenderer, rendererTargetTexture = True}, rendererInfoNumTextureFormats = 1, rendererInfoTextureFormats = [ARGB8888,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown], rendererInfoMaxTextureWidth = 0, rendererInfoMaxTextureHeight = 0}

RendererInfo {rendererInfoName = "opengles2", rendererInfoFlags = RendererConfig {rendererType = AcceleratedVSyncRenderer, rendererTargetTexture = True}, rendererInfoNumTextureFormats = 4, rendererInfoTextureFormats = [ARGB8888,ABGR8888,RGB888,BGR888,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown], rendererInfoMaxTextureWidth = 0, rendererInfoMaxTextureHeight = 0}

RendererInfo {rendererInfoName = "opengles", rendererInfoFlags = RendererConfig {rendererType = AcceleratedVSyncRenderer, rendererTargetTexture = False}, rendererInfoNumTextureFormats = 1, rendererInfoTextureFormats = [ABGR8888,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown], rendererInfoMaxTextureWidth = 0, rendererInfoMaxTextureHeight = 0}

RendererInfo {rendererInfoName = "software", rendererInfoFlags = RendererConfig {rendererType = SoftwareRenderer, rendererTargetTexture = True}, rendererInfoNumTextureFormats = 8, rendererInfoTextureFormats = [ARGB8888,ABGR8888,RGBA8888,BGRA8888,RGB888,BGR888,RGB565,RGB555,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown], rendererInfoMaxTextureWidth = 0, rendererInfoMaxTextureHeight = 0}

Furthermore, if I try to specify that the window use OpenGL by supplying defaultWindow{ windowOpenGL = Just defaultOpenGL } I get a different error:

SDLCallFailed {sdlExceptionCaller = "SDL.Video.createRenderer", sdlFunction = "SDL_CreateRenderer", sdlExceptionError = "Invalid window"}

Thanks for any help, it's much appreciated - even just spit balling.

@typetetris
Copy link

I guess SDLCallFailed {sdlExceptionCaller = "SDL.Video.createRenderer", sdlFunction = "SDL_CreateRenderer", sdlExceptionError = "Couldn't find matching render driver"} just means, that an appropriate driver could not be loaded, but the reason is masked by that.

Maybe try calling createRenderer win 0 defaultRenderer. The index of 0 means the first driver reported by getRenderDriverInfo is used and defaultRenderer simply ignored.

@someodd
Copy link

someodd commented Oct 13, 2023

For me (on Debian unstable) my Haskell project builds with nix build (never the problem) but I still get the following error with nix run:

 SDLCallFailed {sdlExceptionCaller = "SDL.Video.createRenderer", sdlFunction = "SDL_CreateRenderer", sdlExceptionError = "Couldn't find matching render driver"}

... and with SDL_DEBUG=1 SDL_VIDEODRIVER=wayland nix run

SDLCallFailed {sdlExceptionCaller = "SDL.Video.createRenderer", sdlFunction = "SDL_CreateRenderer", sdlExceptionError = "Parameter 'window' is invalid"}

Index of 0

If, as @typetetris suggests, I change my code to simply work with being built in a Nix env or through Nix build, as you suggest (using "the index of 0") I instead get this error:

SDLCallFailed {sdlExceptionCaller = "SDL.Video.createRenderer", sdlFunction = "SDL_CreateRenderer", sdlExceptionError = "Couldn't find matching GLX visual"}

... but I can set the variable and get an error like this:

$ SDL_VIDEODRIVER=wayland cabal run
myapp-exe: SDLCallFailed {sdlExceptionCaller = "SDL.Video.createRenderer", sdlFunction = "SDL_CreateRenderer", sdlExceptionError = "Parameter 'window' is invalid"}

Workaround

I'm using SDL_RENDER_DRIVER=software nix run as a workaround for now.

Other notes

If I don't use Nix at all (no environment or building) everything works fine.

Even if I use cabal build inside the Nix environment the build will produce the same errors above even outside the env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants