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

Make results of SDL.getRenderDriverInfo printable without causing errors #227

Merged
merged 3 commits into from
Dec 28, 2021

Conversation

oshyshko
Copy link
Contributor

When running on macOS 10.15.7 + lts-16.29 (ghc-8.8.4),
SDL.getRenderDriverInfo produces an unprintable result (lazy errors).

This commit makes the results printable.

Here's a test that shows the problem:

#!/usr/bin/env stack
-- stack --resolver lts-16.29 script --package sdl2 --package text

module Main where

import           SDL

main :: IO ()
main =
    getRenderDriverInfo >>= mapM_ (\r -> do
        putStrLn $ "rendererInfoName r: " <> (show . rendererInfoName $ r)
        putStrLn $ "length (rendererInfoTextureFormats r): " <> (show . length . rendererInfoTextureFormats $ r)
        mapM_ print $ rendererInfoTextureFormats r)

-- before the change it fails with this output:
-- rendererInfoName r: "metal"
-- length (rendererInfoTextureFormats r): 16
-- ARGB8888
-- ABGR8888
-- YV12
-- IYUV
-- PixelFormatIssue.hs: fromNumber: not numbered
-- CallStack (from HasCallStack):
--   error, called at src/SDL/Video/Renderer.hs:982:10 in sdl2-2.5.3.0-IOGOFDmjwAe2qgad8A3RFO:SDL.Video.Renderer

-- after the change
-- rendererInfoName r: "metal"
-- length (rendererInfoTextureFormats r): 16
-- ARGB8888
-- ABGR8888
-- YV12
-- IYUV
-- Unknown 842094158
-- Unknown 825382478
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- rendererInfoName r: "opengl"
-- length (rendererInfoTextureFormats r): 16
-- ARGB8888
-- ABGR8888
-- RGB888
-- BGR888
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- rendererInfoName r: "opengles2"
-- length (rendererInfoTextureFormats r): 16
-- ARGB8888
-- ABGR8888
-- RGB888
-- BGR888
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- rendererInfoName r: "software"
-- length (rendererInfoTextureFormats r): 16
-- ARGB8888
-- ABGR8888
-- RGBA8888
-- BGRA8888
-- RGB888
-- BGR888
-- RGB565
-- RGB555
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0
-- Unknown 0

Notice the trailing zeros returned by rendererInfoTextureFormats.
These are not addressed by the PR and presumably should be fixed at an another place.

@dpwiz
Copy link
Member

dpwiz commented Dec 23, 2021

Please rebase for new CI to kick in.

@oshyshko
Copy link
Contributor Author

Please rebase for new CI to kick in.

Done.

@dpwiz dpwiz merged commit e9b0b69 into haskell-game:master Dec 28, 2021
@dpwiz dpwiz mentioned this pull request Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants