Skip to content

Instantly share code, notes, and snippets.

@jlamothe
Created December 13, 2012 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlamothe/4273166 to your computer and use it in GitHub Desktop.
Save jlamothe/4273166 to your computer and use it in GitHub Desktop.
I appear to be running into a bug with the mapRGB function in the SDL library. This code should render a white circle, but it's coming out cyan instead. The following appears to be relevant: http://stackoverflow.com/questions/3286864/why-is-this-haskell-sdl-line-cyan-when-it-should-be-white
import qualified Graphics.UI.SDL as SDL
import qualified Graphics.UI.SDL.Primitives as Draw
main = SDL.withInit [SDL.InitEverything] $ do
SDL.setVideoMode 640 480 32 [SDL.Fullscreen]
>>= drawScreen
eventLoop
drawScreen :: SDL.Surface -> IO ()
drawScreen s = do
SDL.mapRGB (SDL.surfaceGetPixelFormat s) 255 255 255
>>= Draw.filledCircle s 320 240 200
SDL.flip s
eventLoop :: IO ()
eventLoop = SDL.pollEvent >>= eventHandler
eventHandler :: SDL.Event -> IO ()
eventHandler (SDL.KeyDown _) = return ()
eventHandler _ = eventLoop
-- jl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment