I want to use Haskell’s SDL-binding for drawing simple objects (triangle, circles and the like). There is a function for drawing rectangles in Graphics.UI.SDL.Video that works ok. But I can’t get the functions I found for drawing other primitives (in Graphics.UI.SDL.Primitives) to work. The following code only draws a rectangle. Any ideas what I missed?
module Main where
import Graphics.UI.SDL as SDL
import Graphics.UI.SDL.Color
import Graphics.UI.SDL.Primitives
main = do
SDL.init [SDL.InitVideo]
screen <- SDL.setVideoMode 500 500 32 [SDL.HWSurface]
SDL.fillRect screen Nothing (SDL.Pixel 0x0000FF)
fillRect screen (Just (SDL.Rect 10 10 30 30)) (SDL.Pixel 0x00FF0000)
filledCircle screen 40 40 50 (SDL.Pixel 0x00FF0000)
SDL.flip screen
delay 2000
SDL.quit
The pixel color you give filledCircle and fillRect has its alpha component set to zero; try
SDL.Pixel 0x00FF00FFinstead. filledCircle seems to respect the color’s alpha component whereas fillRect apparently does not.