SDL-gfx (empty) → 0.4.0
raw patch · 6 files changed
+200/−0 lines, 6 filesdep +SDLdep +basebuild-type:Customsetup-changed
Dependencies added: SDL, base
Files
- Graphics/UI/SDL/Framerate.hs +64/−0
- Graphics/UI/SDL/Primitives.hs +25/−0
- Graphics/UI/SDL/Rotozoomer.hs +55/−0
- LICENSE +35/−0
- SDL-gfx.cabal +16/−0
- Setup.lhs +5/−0
+ Graphics/UI/SDL/Framerate.hs view
@@ -0,0 +1,64 @@+-----------------------------------------------------------------------------+-- |+-- Module : Graphics.UI.SDL.Framerate+-- Copyright : (c) David Himmelstrup 2005+-- License : BSD-like+--+-- Maintainer : lemmih@gmail.com+-- Stability : provisional+-- Portability : portable+--+-----------------------------------------------------------------------------+module Graphics.UI.SDL.Framerate+ ( new+ , init+ , set+ , get+ , delay+ , FPSManager+ ) where++import Foreign as Foreign hiding (new)+import Foreign.C++import Prelude hiding (init)++data FPSManagerStruct+type FPSManager = ForeignPtr FPSManagerStruct++sizeOfManager :: Int+sizeOfManager = 16++new :: IO FPSManager+new = do manager <- Foreign.mallocBytes sizeOfManager >>= newForeignPtr finalizerFree+ init manager+ return manager++-- void SDL_initFramerate(FPSmanager * manager);+foreign import ccall unsafe "SDL_initFramerate" sdlInitFramerate :: Ptr FPSManagerStruct -> IO ()+init :: FPSManager -> IO ()+init manager+ = withForeignPtr manager sdlInitFramerate+++-- int SDL_setFramerate(FPSmanager * manager, int rate);+foreign import ccall unsafe "SDL_setFramerate" sdlSetFramerate :: Ptr FPSManagerStruct -> Int -> IO Int+set :: FPSManager -> Int -> IO Bool+set manager hz+ = withForeignPtr manager $ \fpsPtr ->+ do ret <- sdlSetFramerate fpsPtr hz+ case ret of+ (-1) -> return False+ _ -> return True++-- int SDL_getFramerate(FPSmanager * manager);+foreign import ccall unsafe "SDL_getFramerate" sdlGetFramerate :: Ptr FPSManagerStruct -> IO Int+get :: FPSManager -> IO Int+get manager = withForeignPtr manager sdlGetFramerate++-- void SDL_framerateDelay(FPSmanager * manager);+foreign import ccall unsafe "SDL_framerateDelay" sdlFramerateDelay :: Ptr FPSManagerStruct -> IO ()+delay :: FPSManager -> IO ()+delay manager = withForeignPtr manager sdlFramerateDelay++
+ Graphics/UI/SDL/Primitives.hs view
@@ -0,0 +1,25 @@+-----------------------------------------------------------------------------+-- |+-- Module : Graphics.UI.SDL.Primitives+-- Copyright : (c) David Himmelstrup 2005+-- License : BSD-like+--+-- Maintainer : lemmih@gmail.com+-- Stability : provisional+-- Portability : portable+--+-----------------------------------------------------------------------------+module Graphics.UI.SDL.Primitives where++import Foreign++import Graphics.UI.SDL.General+import Graphics.UI.SDL.Types+import Graphics.UI.SDL.Color+import Graphics.UI.SDL.Rect++++-- int pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);+-- foregin import+
+ Graphics/UI/SDL/Rotozoomer.hs view
@@ -0,0 +1,55 @@+-----------------------------------------------------------------------------+-- |+-- Module : Graphics.UI.SDL.Rotozoomer+-- Copyright : (c) David Himmelstrup 2005+-- License : BSD-like+--+-- Maintainer : lemmih@gmail.com+-- Stability : provisional+-- Portability : portable+--+-----------------------------------------------------------------------------+module Graphics.UI.SDL.Rotozoomer where++import Foreign+import Foreign.C++import Graphics.UI.SDL.Video+import Graphics.UI.SDL.General+import Graphics.UI.SDL.Types++finalizeWhenNotNull :: String -> Ptr SurfaceStruct -> IO Surface+finalizeWhenNotNull errMsg image+ = if image == nullPtr+ then failWithError errMsg+ else mkFinalizedSurface image++++-- SDL_Surface * rotozoomSurface (SDL_Surface *src, double angle, double zoom, int smooth);+foreign import ccall unsafe "rotozoomSurface" sdlRotozoom+ :: Ptr SurfaceStruct -> Double -> Double -> Int -> IO (Ptr SurfaceStruct)+rotozoom :: Surface -> Double -> Double -> Bool -> IO Surface+rotozoom src angle zoom smooth+ = withForeignPtr src $ \imgSrc ->+ sdlRotozoom imgSrc angle zoom (fromBool smooth) >>= finalizeWhenNotNull "rotozoomSurface"++{-+-- SDL_Surface * rotozoomSurfaceXY (SDL_Surface *src, double angle, double zoomx, double zoomy, int smooth);+foreign import ccall unsafe "rotozoomSurfaceXY" sdlRotozoomXY+ :: Ptr SurfaceStruct -> Double -> Double -> Double -> Int -> IO (Ptr SurfaceStruct)+rotozoomXY :: Surface -> Double -> Double -> Double -> Bool -> IO Surface+rotozoomXY src angle zoomx zoomy smooth+ = withForeignPtr src $ \imgSrc ->+ sdlRotozoomXY imgSrc angle zoomx zoomy (fromBool smooth) >>= finalizeWhenNotNull "rotozoomSurfaceXY"+-}++-- SDL_Surface * zoomSurface (SDL_Surface *src, double zoomx, double zoomy, int smooth);+foreign import ccall unsafe "zoomSurface" sdlZoom+ :: Ptr SurfaceStruct -> Double -> Double -> Int -> IO (Ptr SurfaceStruct)+zoom :: Surface -> Double -> Double -> Bool -> IO Surface+zoom src zoomx zoomy smooth+ = withForeignPtr src $ \imgSrc ->+ sdlZoom imgSrc zoomx zoomy (fromBool smooth) >>= finalizeWhenNotNull "zoomSurface"++
+ LICENSE view
@@ -0,0 +1,35 @@+Copyright (c) 2004-2006, David Himmelstrup+All rights reserved.++Redistribution and use in source and binary forms,+with or without modification, are permitted provided+that the following conditions are met:++ * Redistributions of source code must retain+ the above copyright notice, this list of+ conditions and the following disclaimer.+ * Redistributions in binary form must reproduce+ the above copyright notice, this list of+ conditions and the following disclaimer in the+ documentation and/or other materials provided+ with the distribution.+ * Neither the name of David Himmelstrup nor the+ names of other contributors may be used to+ endorse or promote products derived from this+ software without specific prior written permission.+++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND+CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE+USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY+OF SUCH DAMAGE.
+ SDL-gfx.cabal view
@@ -0,0 +1,16 @@+Name: SDL-gfx+Version: 0.4.0+Maintainer: Lemmih (lemmih@gmail.com)+Author: Lemmih (lemmih@gmail.com)+Copyright: 2004-2005, Lemmih+License-File: LICENSE+Build-Depends: base, SDL+Category: Foreign binding+Synopsis: Binding to libSDL_gfx+Extensions: CPP, ForeignFunctionInterface+Exposed-Modules:+ Graphics.UI.SDL.Rotozoomer,+ Graphics.UI.SDL.Primitives,+ Graphics.UI.SDL.Framerate+Includes: SDL.h SDL_framerate.h SDL_gfxPrimitives.h SDL_rotozoom.h+GHC-Options: -fglasgow-exts -O2 -fvia-c
+ Setup.lhs view
@@ -0,0 +1,5 @@+#!/usr/bin/env runhaskell+> module Main where+> import Distribution.Simple+> main :: IO ()+> main = defaultMainWithHooks defaultUserHooks