Last active
March 13, 2018 02:06
-
-
Save evanrinehart/082a82df2fe3550cfbc71a8b3160645f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import SDL | |
import SDLEntry | |
import qualified Data.Vector.Unboxed as VU | |
import System.Exit | |
import Data.IORef | |
main = do | |
worldVar <- newIORef 0 | |
let srate = 44100 | |
let samples = 1024 | |
sdlEntry | |
. configBootCb (onBoot worldVar) | |
. configEventCb (onEvent worldVar) | |
. configTimeCb (onTimeDelta worldVar) | |
. configRenderCb (onRender worldVar) | |
. configSoundCb (audioCb srate samples worldVar) | |
. configSampleCount samples | |
. configSampleRate srate | |
$ configDimensions 640 480 | |
onBoot wv = do | |
return () | |
onEvent wv ev = case eventPayload ev of | |
QuitEvent -> exitSuccess | |
other -> do | |
modifyIORef wv (+1) | |
print other | |
onTimeDelta wv dt = do | |
return () | |
onRender wv ren = do | |
x <- readIORef wv | |
print x | |
clear ren | |
audioCb srate samples wv = do | |
return (VU.replicate (2 * samples) 0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment