aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Final.hs143
-rw-r--r--Graphics/Glyph/BufferBuilder.hs33
-rw-r--r--Graphics/Glyph/GLMath.hs14
-rw-r--r--Graphics/Glyph/Mat4.hs18
-rw-r--r--LICENSE13
-rw-r--r--README.md42
-rw-r--r--README.txt9
-rw-r--r--Terralloc.cabal2
-rwxr-xr-xterralloc3
9 files changed, 186 insertions, 91 deletions
diff --git a/Final.hs b/Final.hs
index 3cdf576..3756908 100644
--- a/Final.hs
+++ b/Final.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
@@ -10,11 +9,9 @@ import Graphics.UI.SDL.Image as SDLImg
import Graphics.UI.SDL as SDL
import Graphics.SDL.SDLHelp
import Graphics.Glyph.Util
-import Graphics.Glyph.ExtendedGL
import Control.Monad
import Graphics.Glyph.BufferBuilder
-import Graphics.Glyph.ObjLoader
import qualified Data.Map as Map
import Data.Word
@@ -24,50 +21,80 @@ import Data.Array.IO
import Data.Sequence as Seq
import Prelude as P
-import Debug.Trace
import Data.Bits
import Resources
import System.Random
-import Debug.Trace
import System.Environment
-import System.Exit
-buildArray :: SDL.Surface -> SDL.Surface -> IO (Array (Int,Int) Tile)
+{-
+ - This function builds an array of tile from the heightmap and
+ - terrain map passed as SDL surfaces.
+ -
+ - Returns: An array with bounds [(0,0),(w,h)] of tiles where
+ - w is the minimum width of the two images and h is the minimum
+ - height.
+ -}
+buildArray :: SDL.Surface -> SDL.Surface -> Array (Int,Int) Tile
buildArray terrain height =
+ {- Pick the minimum width and height between the two images -}
let w = min (SDL.surfaceGetWidth terrain) $ SDL.surfaceGetWidth height
h = min (SDL.surfaceGetHeight terrain) $ SDL.surfaceGetHeight height
+
+ {- Function that returns a Tile for an x y coordinate -}
conv (x,y) =
let terrainVal = fromIntegral $ getPixelUnsafe x y terrain
+ {- The height is encoded as the sum of the color channels, to make life a litte
+ - easier on the heightmap reader. -}
sumit word =
((word `shiftR` 8) .&. 0xFF) +
((word `shiftR`16) .&. 0xFF) +
((word `shiftR`24) .&. 0xFF)
+
+ {- The value of the hightmap at the coordinate. I will promise
+ - the compmiler that my surfaces will not change. -}
heightVal = (fromIntegral.sumit) (getPixelUnsafe x y height)
+
+ {- The value of the terrain map at thata location -}
terrainVal' = Map.findWithDefault Resources.Unknown terrainVal tileMap in
Tile terrainVal' heightVal
- list = map conv [(x,y) | x <- [0..w-1], y <- [0..h-1]]
- in do
- putStrLn $ show (head list)
- return $ listArray ((0,0),(w-1,h-1)) list
+ {- build the list of Tiles to jam into the array -}
+ list = map conv [(x,y) | x <- [0..w-1], y <- [0..h-1]]
+ in listArray ((0,0),(w-1,h-1)) list
--- colors regions of water in the array
+{- This function takes the array generated in the function from above and
+ - creates a new array that colors in the array with locations of bodies
+ - of water and assigns an id to each of them. This allows for me to go
+ - back and assign heights for the bodies of water. -}
colorArray :: Array (Int,Int) Tile -> IO (IOArray (Int,Int) Int)
colorArray marr = do
- let pollseq (Seq.viewl -> (head :< tail)) = (head,tail)
+
+ {- Very simple function that take splits a sequence
+ - into a head and a tail -}
+ let pollseq (Seq.viewl -> (head' :< tail')) = (head',tail')
+ pollseq _ = undefined
+
let bnd@(_,(w,h)) = bounds marr
ret <- newArray bnd 0
- let myfunction place = do
- val <- readArray ret place
- case marr ! place of
+
+ {- Boolean funcion. Returns true if the
+ - tile at the position `place` is water
+ - and has not yet been assigned an id -}
+ let myfunction a_place = do
+ val <- readArray ret a_place
+ case marr ! a_place of
(Tile Water _) -> return $ val==0
_ -> return False
+
+ {- Uses a queue method to flood fill bodies
+ - of water and write that to an array -}
let floodfill :: (Int,Int) -> ((Int,Int) -> IO Bool) -> Int -> IO ()
floodfill start func' val = do
let func t@(x,y) = if not (x <= w && x >= 0 && y <= h && y >= 0) then return False else func' t
+ {- Just magic. Does a flood fill -}
_ <- untilM2 (return . Seq.null) (Seq.singleton start) $ \queue -> do
let (head',tail') = pollseq queue
bool <- func head'
@@ -80,6 +107,8 @@ colorArray marr = do
return ((x-1,y), queue' |> (x,y-1) |> (x,y+1))
return tail3
return ()
+ {- Iterates through all the points and does a flood fill on
+ - them -}
foldM_ (\val place -> do
bool <- myfunction place
if bool then do
@@ -89,37 +118,50 @@ colorArray marr = do
) 1 [(x,y) | x <- [0..w], y <- [0..h]]
return ret
--- elevation quad is corner verticices
+{- This function takes the two arrays from the functions above and generates
+ - 2 things:
+ - A map of water bodies ids to elevations (to detect if you are under water
+ - A builder that will generate all of the quads for the water. -}
getWaterQuads :: Array (Int,Int) Tile -> IOArray (Int,Int) Int -> IO ( Map.Map Int GLfloat, BuilderM GLfloat () )
getWaterQuads marr arr = do
let (_,(w,h)) = bounds marr
+
+ {- Iterates through the bodies of water and finds the lowest altitude
+ - of the land surrounding the water. Returns a type of body id
+ - to minx, miny, maxx, maxy and elevation -}
let elevationCacheIO :: IO (Map.Map Int (Int,Int,Int,Int,Int))
elevationCacheIO = do
+ {- Tuple of functions that will be mapped with
+ - the application operator ($) -}
let tup = (min,max,max,min,min)
foldM (\themap (x,y) -> do
bodyID <- readArray arr (x,y)
if bodyID == 0 then return themap else do
- let valid (x,y) = x >= 0 && x <= w && y >= 0 && y <= h
- let neighbors (x,y) = P.filter valid $ map (zipWithT2 (+) (x,y))
+ let valid (aX,aY) = aX >= 0 && aX <= w && aY >= 0 && aY <= h
+ let neighbors (aX,aY) = P.filter valid $ map (zipWithT2 (+) (aX,aY))
[ (1,0),
(0,1), (0,-1),
(-1,0) ]
- let toelev x =
- let tile = marr ! x in
+ let toelev aX =
+ let tile = marr ! aX in
(tileType tile == Water) ? 1000000000000 $ elevation tile
let elev = minimum $ map toelev (neighbors (x,y))
- let newmap = Map.insertWith (\old->
- zipWithT5 (P.$) (zipWithT5 (P.$) tup old)
- ) bodyID (elev,x,y,x,y) themap
+ let newmap =
+ Map.insertWith (zipWithT5 (P.$) . (zipWithT5 (P.$) tup))
+ bodyID (elev,x,y,x,y) themap
return newmap
) (Map.empty::Map.Map Int (Int,Int,Int,Int,Int)) [(x,y) | x <- [0..w], y <- [0..h]]
elevMap <- elevationCacheIO
- let elevMap2 = Map.map (\(elev,_,_,_,_) -> do
+
+ {- A map between body id and elevation. Get rid of the bounding quad box -}
+ let elevMap2 = Map.map (\(elev,_,_,_,_) ->
fromIntegral elev / 10) elevMap
let dat = Map.toList elevMap
- return (elevMap2,sequence_ $ for dat $ \(_, (elev,maxx,maxy,minx,miny)) -> do
+ {- Iterate through the map and draw the bounding quad
+ - for the body of water -}
+ return (elevMap2,sequence_ $ for dat $ \(_, (elev,maxx,maxy,minx,miny)) ->
let mxx = fromIntegral maxx + 1
mnx = fromIntegral minx - 1
mxy = fromIntegral maxy + 1
@@ -139,12 +181,12 @@ printArray arr = do
putStrLn $ "h=" ++! (h+1)
forM_ [0..h] $ \y -> do
forM_ [0..w] $ \x -> do
- let next = arr ! (x,y)
- putStr $ (show $ tileType next)
+ let lNext = arr ! (x,y)
+ putStr $ show $ tileType lNext
putStr " "
forM_ [0..w] $ \x -> do
- let next = arr ! (x,y)
- putStr $ (elevShow $ elevation next)
+ let lNext = arr ! (x,y)
+ putStr $ elevShow $ elevation lNext
putStrLn ""
where elevShow x =
let len = P.length elevMap
@@ -152,16 +194,19 @@ printArray arr = do
if nx >= len then "=" else [elevMap !! nx]
elevMap = "`.,-~*<:!;%&#@0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+printShowArray :: (Show a) => IOArray (Int,Int) a -> IO ()
printShowArray arr = do
(_,(w,h)) <- getBounds arr
putStrLn $ "w=" ++! (w+1)
putStrLn $ "h=" ++! (h+1)
forM_ [0..h] $ \y -> do
forM_ [0..w] $ \x -> do
- next <- readArray arr (x,y)
- putStr $ (show $ next)
+ lNext <- readArray arr (x,y)
+ putStr $ show lNext
putStrLn ""
+{- The colors each tile type is mapped to
+ - as an array -}
toColor :: TileType -> (GLfloat,GLfloat,GLfloat,GLfloat)
toColor Tundra = (0.5,0.5,0.5,1.0)
toColor Mountains = (0.5,0.4,0.03,1.0)
@@ -170,7 +215,10 @@ toColor Jungle = (0,1.0,0.0,1.0)
toColor Forest = (0,0.2,0.0,1.0)
toColor Beach = (0.7,0.7,0.6,1.0)
toColor Water = (0,0,1.0,1.0)
+toColor Resources.Unknown = (0,0,0,0)
+{- Map of color to TileType used for
+ - parsing the terrain map -}
tileMap :: Map.Map Word32 TileType
tileMap =
let c = rgbToWord in
@@ -196,7 +244,7 @@ createBuilder arr = do
[(x,y) | x <- [1..w], y <- [1..h]]
- inferingNormals $ do
+ inferingNormals $
forM_ (trianglesFromQuads lst) $ \(x,y,z,_) -> do
let f = fromIntegral
let bUseTexture a = bColor4 (0,0,0,f a)
@@ -212,21 +260,21 @@ createLocations arr gen density typ = do
let run :: [Int] -> (Int,Int) -> MonadPlusBuilder ( Seq.Seq GLfloat ) [Int]
run rs (x,y) = do
- let ((_:he), t) = P.splitAt (head rs `mod` density + 1) rs
+ let (_:he, t) = P.splitAt (head rs `mod` density + 1) rs
let signum' = floor.signum
- when (isType x y typ) $ do
- forM_ he $ \rand -> do
+ when (isType x y typ) $
+ forM_ he $ \rand ->
let (a',b',c) = toTup rand
- let (a,b) = (f a', f b')
- let [sx,sy,sz,rot,noise] = (P.take 5 $ randomRs (0.0,1.0) $ mkStdGen c)
+ (a,b) = (f a', f b')
+ [sx,sy,sz,rot,noise] = (P.take 5 $ randomRs (0.0,1.0) $ mkStdGen c)
- let elev = getElev x y
- let elev_dx = getElev (x + signum' a) y
- let elev_dy = getElev x (y + signum' b)
- let realelev =
- ((elev * (1-abs a) + elev_dx * (abs a)) +
- (elev * (1-abs b) + elev_dy * (abs b))) / 2.0
+ elev = getElev x y
+ elev_dx = getElev (x + signum' a) y
+ elev_dy = getElev x (y + signum' b)
+ realelev =
+ ((elev * (1-abs a) + elev_dx * abs a) +
+ (elev * (1-abs b) + elev_dy * abs b)) / 2.0 in
when (elev_dx > 0 && elev_dy > 0) $
plusM $ Seq.fromList [
@@ -244,10 +292,9 @@ createLocations arr gen density typ = do
foldM_ run (randoms gen) [(x,y) | x <- [1..w], y <- [1..h]]
return ()
- where isType x y t =
- (tileType $ arr ! (x,y)) == t
+ where isType x y t = tileType (arr ! (x,y)) == t
f x = (fromIntegral x - 128) / 128 * (sqrt 2 / 2)
- toTup x = ( (x .&. 0xFF),
+ toTup x = ( x .&. 0xFF ,
(x `shiftR` 8) .&. 0xFF,
(x `shiftR` 16) .&. 0xFF)
@@ -266,7 +313,7 @@ main = do
_ -> sequence [SDLImg.load "maps/wonderland_terrain.png", SDLImg.load "maps/wonderland_height.png"]
putStrLn "Done Loading ..."
- arr <- buildArray terrain height
+ let arr = buildArray terrain height
putStrLn "Array Built"
printArray arr
coloredArr <- colorArray arr
diff --git a/Graphics/Glyph/BufferBuilder.hs b/Graphics/Glyph/BufferBuilder.hs
index 43447a1..9dae0aa 100644
--- a/Graphics/Glyph/BufferBuilder.hs
+++ b/Graphics/Glyph/BufferBuilder.hs
@@ -4,19 +4,15 @@
{-# LANGUAGE MultiParamTypeClasses #-}
module Graphics.Glyph.BufferBuilder where
-import Control.Monad
import Graphics.Rendering.OpenGL
import Foreign.Storable
import Foreign.Ptr
import Foreign.Marshal.Array
import Data.Array.Storable
-import Data.Setters
-import Debug.Trace
import qualified Data.Foldable as Fold
import Data.Sequence as Seq
import Data.Map as Map
-import Graphics.Glyph.Mat4
import Graphics.Glyph.Util
import Graphics.Glyph.GLMath
@@ -117,7 +113,7 @@ instance (Num t) => Monad (BuilderM t) where
| otherwise = Builder b1 b2
(Builder !b1 !b2) ><> leaf@(LeafBuilder !_) =
(Builder b1 (b2 ><> leaf))
- builder1 ><> builder2 = (Builder builder1 builder2)
+ builder1' ><> builder2' = (Builder builder1' builder2')
b1@(BuilderM _ ret) >>= func = b1 >> func ret
@@ -126,33 +122,33 @@ instance (Num t) => Monad (BuilderM t) where
instance Functor Builder where
fmap f (Builder b1 b2) = (Builder (fmap f b1) (fmap f b2))
- fmap f (LeafBuilder seq) = (LeafBuilder (fmap f seq))
+ fmap f (LeafBuilder seq') = (LeafBuilder (fmap f seq'))
instance Fold.Foldable Builder where
foldl f ini (Builder b1 b2) =
Fold.foldl f (Fold.foldl f ini b1) b2
- foldl f ini (LeafBuilder seq) =
- Fold.foldl f ini seq
+ foldl f ini (LeafBuilder seq') =
+ Fold.foldl f ini seq'
foldr f ini (Builder b1 b2) =
Fold.foldr f (Fold.foldr f ini b2) b1
- foldr f ini (LeafBuilder seq) =
- Fold.foldr f ini seq
+ foldr f ini (LeafBuilder seq') =
+ Fold.foldr f ini seq'
expandBuilder :: Builder a -> b -> (b -> a -> (b,[a])) -> Builder a
expandBuilder builder ini f = snd $ expandBuilder' builder ini f
where expandBuilder' :: Builder a -> b -> (b -> a -> (b,[a])) -> (b,Builder a)
- expandBuilder' (Builder builder1 builder2) ini f =
- let (snowball1,newBuilder1) = expandBuilder' builder1 ini f
- (snowball2,newBuilder2) = expandBuilder' builder2 snowball1 f in
+ expandBuilder' (Builder builder1 builder2) ini' f' =
+ let (snowball1,newBuilder1) = expandBuilder' builder1 ini' f'
+ (snowball2,newBuilder2) = expandBuilder' builder2 snowball1 f' in
(snowball2,Builder newBuilder1 newBuilder2)
- expandBuilder' (LeafBuilder seq1) ini f =
- let (seq,snow) = Fold.foldl' (\(seq', snow) datum ->
- let (snow',lst) = f snow datum in
- (seq' >< Seq.fromList lst,snow')) (Seq.empty,ini) seq1 in
- (snow,LeafBuilder seq)
+ expandBuilder' (LeafBuilder seq1) initial func =
+ let (sequ,snow) = Fold.foldl' (\(seq', snowball) datum ->
+ let (snow',lst) = func snowball datum in
+ (seq' >< Seq.fromList lst,snow')) (Seq.empty,initial) seq1 in
+ (snow,LeafBuilder sequ)
{- Add a vertex to the current builder -}
bVertex3 :: (a,a,a) -> BuilderM a ()
@@ -313,4 +309,3 @@ translating trans (BuilderM builder ret) = do
case datum of
VertexLink tup -> VertexLink $ zipWithT3 (+) tup trans
_ -> datum) ret
-translating _ x = x
diff --git a/Graphics/Glyph/GLMath.hs b/Graphics/Glyph/GLMath.hs
index cd0fd53..b1df4c5 100644
--- a/Graphics/Glyph/GLMath.hs
+++ b/Graphics/Glyph/GLMath.hs
@@ -1,5 +1,5 @@
{-# LANGUAGE MultiParamTypeClasses #-}
-{-# OPTIONS_GHC -XFlexibleInstances #-}
+{-# LANGUAGE FlexibleInstances #-}
module Graphics.Glyph.GLMath where
import Graphics.Glyph.Mat4
import qualified Graphics.Rendering.OpenGL as GL
@@ -19,6 +19,7 @@ module Graphics.Glyph.GLMath where
GL.get (uniform loc)
return (Vec3 (x,y,z)) )
(\(Vec3 (x,y,z)) -> uniform loc GL.$= Vertex3 x y z)
+ uniformv _ = undefined
instance UniformComponent a => Uniform (Vec4 a) where
uniform loc = GL.makeStateVar
@@ -27,6 +28,7 @@ module Graphics.Glyph.GLMath where
GL.get (uniform loc)
return (Vec4 (x,y,z,w)) )
(\(Vec4 (x,y,z,w)) -> uniform loc GL.$= GL.Vertex4 x y z w)
+ uniformv _ = undefined
class (Floating flT) => Vector flT b where
(<+>) :: b flT -> b flT -> b flT
@@ -83,14 +85,14 @@ module Graphics.Glyph.GLMath where
(×) = cross
lookAtMatrix :: Vec3 GLfloat -> Vec3 GLfloat -> Vec3 GLfloat -> Mat4 GLfloat
- lookAtMatrix e@(Vec3 (ex,ey,ez)) c u =
+ lookAtMatrix e c u =
let f@(Vec3 (fx,fy,fz)) = normalize (c <-> e)
s@(Vec3 (sx,sy,sz)) = normalize (f × u)
u'@(Vec3 (ux,uy,uz)) = s × f in
Matrix4 (sx, ux, -fx, 0,
sy, uy, -fy, 0,
sz, uz, -fz, 0,
- -(s<.>e) , -(u'<.>e), (f<.>e), 1 )
+ -(s<.>e) , -(u'<.>e), f<.>e, 1 )
orthoMatrix :: GLfloat -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> Mat4 GLfloat
orthoMatrix top bot right left near far =
@@ -107,7 +109,7 @@ module Graphics.Glyph.GLMath where
res22 = - (zf + zn) / (zf - zn)
res23 = - 1
res32 = - (2 * zf * zn) / (zf - zn) in
- trace ("res22=" ++ (show res22)) $
+ trace ("res22=" ++ show res22) $
Matrix4 (res00, 0, 0, 0,
0, res11, 0, 0,
0, 0, res22, res23,
@@ -161,8 +163,8 @@ module Graphics.Glyph.GLMath where
m20,m21,m22,m23,
m30,m31,m32,m33)) vec =
let (Vec4 (v0,v1,v2,v3)) = mat -*| vec in
- (Matrix4 (m00,m01,m02,m03,
+ Matrix4 (m00,m01,m02,m03,
m10,m11,m12,m13,
m20,m21,m22,m23,
- m30+v0,m31+v1,m32+v2,m33+v3))
+ m30+v0,m31+v1,m32+v2,m33+v3)
diff --git a/Graphics/Glyph/Mat4.hs b/Graphics/Glyph/Mat4.hs
index 294871c..c1ae485 100644
--- a/Graphics/Glyph/Mat4.hs
+++ b/Graphics/Glyph/Mat4.hs
@@ -8,7 +8,7 @@ import Foreign.Marshal.Array
import Foreign.Ptr
import Foreign.Storable
-import Graphics.Rendering.OpenGL (GLfloat,Uniform(..),uniform,UniformLocation(..),makeStateVar)
+import Graphics.Rendering.OpenGL (Uniform(..),uniform,UniformLocation(..),makeStateVar)
import Graphics.Rendering.OpenGL.Raw.Core31
data Mat4 a = Matrix4 (a,a,a,a,
@@ -89,9 +89,10 @@ instance Uniform (Mat4 GLfloat) where
getter :: IO (Mat4 GLfloat)
getter = do
pid <- liftM fromIntegral getCurrentProgram
- ( allocaArray 16 $ \buf -> do
+ allocaArray 16 $ \buf -> do
glGetUniformfv pid loc buf
- fromPtr buf return )
+ fromPtr buf return
+ uniformv _ = undefined
instance Uniform (Mat3 GLfloat) where
uniform (UniformLocation loc) = makeStateVar getter setter
@@ -100,9 +101,10 @@ instance Uniform (Mat3 GLfloat) where
getter :: IO (Mat3 GLfloat)
getter = do
pid <- liftM fromIntegral getCurrentProgram
- ( allocaArray 9 $ \buf -> do
+ allocaArray 9 $ \buf -> do
glGetUniformfv pid loc buf
- fromPtr buf return )
+ fromPtr buf return
+ uniformv _ = undefined
getCurrentProgram :: IO GLint
getCurrentProgram = alloca $ glGetIntegerv gl_CURRENT_PROGRAM >> peek
@@ -206,10 +208,10 @@ transpose4 (Matrix4
(m00,m01,m02,m03,
m10,m11,m12,m13,
m20,m21,m22,m23,
- m30,m31,m32,m33 )) = (Matrix4 (m00, m10, m20, m30,
+ m30,m31,m32,m33 )) = Matrix4 (m00, m10, m20, m30,
m01, m11, m21, m31,
m02, m12, m22, m32,
- m03, m13, m23, m33))
+ m03, m13, m23, m33)
scale4 :: (Num a) => a -> Mat4 a -> Mat4 a
scale4 n (Matrix4 (m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44)) =
Matrix4 (m11*n,m12*n,m13*n,m14*n,m21*n,m22*n,m23*n,m24*n,m31*n,m32*n,m33*n,m34*n,m41*n,m42*n,m43*n,m44*n)
@@ -256,4 +258,4 @@ trunc4 (Matrix4
_ , _ , _ ,_)) = Matrix3 (m11,m12,m13,m21,m22,m23,m31,m32,m33)
toNormalMatrix :: (RealFloat a,Eq a) => Mat4 a -> Maybe (Mat3 a)
-toNormalMatrix mat = inv4 mat >>= return . trunc4 . transpose4
+toNormalMatrix mat = liftM (trunc4 . transpose4) $ inv4 mat
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..5c93f45
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6079413
--- /dev/null
+++ b/README.md
@@ -0,0 +1,42 @@
+Terralloc
+--------
+
+Welcome to the wonderful worlds generated by Terralloc. This program is an
+OpenGL program written in 100% Haskell which allows you to build worlds based
+off of terrain maps and height maps. Look in the `maps` folder for some example
+worlds.
+
+Usage
+-----
+
+To use Terralloc just compile it with `cabal install` and run it with the
+`./terralloc` script. Ex `./terralloc spain`
+
+Requirements
+------------
+
+As far as Haskell goes, this project is NOT portable. You must compile it using
+GHC since Terralloc makes liberal use of the many useful GHC extensions.
+
+For an OS, this was developed and tested on Arch Linux and Ubuntu 12.04
+theoretically it should run on Mac and maybe Windows, but I have to way of
+testing it.
+
+Running the built-in maps requires a beefy GPU with support for at least OpenGL
+4.0
+
+This project uses SDL on OpenGL, so make sure the libraries for both are
+installed.
+
+Academia
+--------
+
+For those of you who are as nerdy as I and am looking for a good example of
+modern OpenGL in Haskell. This is a really good resource, if you are willing to
+pick through it.
+
+I plan soon to start a project Hagl (pronounced Haggle) separate from the
+current HOpenGL for a fully integrated OpenGL complete with compile-time meta
+programming to include, check and integrate shader source with the Haskell code
+to maximize the benefits of the GHC type system and ensure correctness of code.
+
diff --git a/README.txt b/README.txt
deleted file mode 100644
index 7c605f6..0000000
--- a/README.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-This is still a work in progress, and I have not yet had time to bang around with tying to get it to compile on 12.04. A statically linked binary has been included (These things are getting big!)
-
-This program reads terrain.png and height.png to generate the terrain. You may edit these to your hearts content and look at the difference in the generated terrain.
-
-The water is still a work in progress. I am trying to get pseudo reflections to work and it is not being the best.
-
-Controls:
- w,s,mouse - move
- =/- - speed up time/slow down time
diff --git a/Terralloc.cabal b/Terralloc.cabal
index bd0545f..7281d81 100644
--- a/Terralloc.cabal
+++ b/Terralloc.cabal
@@ -16,7 +16,7 @@ maintainer: joshuarahm@gmail.com
build-type: Simple
cabal-version: >=1.8
-executable final
+executable terralloc.bin
main-is: Final.hs
extensions: FlexibleInstances
ghc-options: -rtsopts -O3
diff --git a/terralloc b/terralloc
new file mode 100755
index 0000000..386e9fc
--- /dev/null
+++ b/terralloc
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+dist/build/final/final +RTS -K3000000000 -RTS $@