packages feed

SDL 0.6.0 → 0.6.1

raw patch · 5 files changed

+84/−2 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

+ Examples/MacOSX/Main.hs view
@@ -0,0 +1,39 @@+import Graphics.UI.SDL as SDL+import System.Exit+import System.Random++width = 640+height = 480++main = withInit [InitVideo] $ +    do screen <- setVideoMode 640 480 16 [SWSurface]+       setCaption "Test" ""+       enableUnicode True+       image <- loadBMP "../image.bmp"+       display image+       loop (display image)++display :: Surface -> IO ()+display image+    = do screen <- getVideoSurface+         let format = surfaceGetPixelFormat screen+         red <- mapRGB format 0xFF 0 0+         green <- mapRGB format 0 0xFF 0+         fillRect screen Nothing green+         fillRect screen (Just (Rect 10 10 10 10)) red+         posX <- randomRIO (0,width-1-surfaceGetWidth image)+         posY <- randomRIO (0,height-1-surfaceGetHeight image)+         blitSurface image Nothing screen (Just (Rect posX posY 0 0))+         SDL.flip screen+++loop :: IO () -> IO ()+loop display+    = do event <- waitEvent+         case event of+           Quit -> exitWith ExitSuccess+           KeyDown (Keysym _ _ 'q') -> exitWith ExitSuccess+           KeyDown (Keysym _ _ ' ') -> display+           _ -> return ()+         loop display+
+ Examples/MacOSX/Makefile view
@@ -0,0 +1,10 @@+test: wrapper.o SDLWrapper.hs+	ghc -no-hs-main --make wrapper.o SDLWrapper.hs -o test+SDLWrapper_stub.h: SDLWrapper.hs+	ghc -no-hs-main --make SDLWrapper.hs -c+wrapper.o: SDLWrapper_stub.h+	ghc -no-hs-main `sdl-config --cflags` -Wall wrapper.c -c+clean:+	rm -f *.hi *.o *_stub.c *_stub.h test+.PHONY: clean+
+ Examples/MacOSX/SDLWrapper.hs view
@@ -0,0 +1,4 @@+{-# LANGUAGE ForeignFunctionInterface #-}+module SDLWrapper where+import Main+foreign export ccall "haskell_main" main :: IO ()
+ Examples/MacOSX/wrapper.c view
@@ -0,0 +1,25 @@+//for explanations see http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#using-own-main++#include <SDL.h>+#include <HsFFI.h>++#ifdef __GLASGOW_HASKELL__+#include "SDLWrapper_stub.h"+#endif++#ifdef __GLASGOW_HASKELL__+extern void __stginit_SDLWrapper ( void );+#endif++int main(int argc, char *argv[])+{+  hs_init(&argc, &argv);+#ifdef __GLASGOW_HASKELL__+  hs_add_root(__stginit_SDLWrapper);+#endif++  haskell_main();++  hs_exit();+  return 0;+}
SDL.cabal view
@@ -1,6 +1,6 @@ Cabal-Version:      >= 1.6 Name:               SDL-Version:            0.6.0+Version:            0.6.1 Maintainer:         Lemmih (lemmih@gmail.com) Author:             Lemmih (lemmih@gmail.com) Copyright:          2004-2010, Lemmih@@ -10,7 +10,11 @@ Category:           Foreign binding Synopsis:           Binding to libSDL Tested-with:        GHC ==6.6, GHC ==6.8, GHC ==6.10, GHC ==6.12.2, Hugs ==20050308-Data-files:         README, MACOSX, WIN32+Data-files:         README, MACOSX, WIN32,+                    Examples/MacOSX/Main.hs,+                    Examples/MacOSX/Makefile,+                    Examples/MacOSX/SDLWrapper.hs,+                    Examples/MacOSX/wrapper.c Extra-Source-files: configure, configure.ac, SDL.buildinfo.in, config.mk.in, includes/HsSDLConfig.h.in  Library