little cleanup

- some formatting
- changed y/z-Coords on Map (y is height now, map is in x/z-plane)
This commit is contained in:
Nicole Dresselhaus 2014-01-02 13:02:01 +01:00
parent 2ff7534ede
commit 306381c4ed
4 changed files with 35 additions and 27 deletions

View File

@ -26,6 +26,7 @@ import GHC.Conc.Sync (unsafeIOToSTM)
import Prelude as P import Prelude as P
import System.IO.Unsafe (unsafePerformIO) import System.IO.Unsafe (unsafePerformIO)
import Foreign.Marshal.Array (allocaArray) import Foreign.Marshal.Array (allocaArray)
import Render.Misc (dumpInfo)
data ProgramState = PS { keysPressed :: IntSet data ProgramState = PS { keysPressed :: IntSet
, px :: GLfloat , px :: GLfloat
@ -365,6 +366,7 @@ keyEvent state press = do
| code == 25 -> accept $ ps { dheading = dheading - deltaH } | code == 25 -> accept $ ps { dheading = dheading - deltaH }
| code == 27 -> accept $ ps { dheading = dheading + deltaH } | code == 27 -> accept $ ps { dheading = dheading + deltaH }
| code == 42 -> accept $ ps { showShadowMap = not showShadowMap } | code == 42 -> accept $ ps { showShadowMap = not showShadowMap }
| code == 31 -> dumpInfo >> accept ps
| otherwise -> deny ps | otherwise -> deny ps
-- on RELEASE only -- on RELEASE only
False False
@ -522,7 +524,6 @@ main = do
(w', h') <- liftIO $ reconfigure w h (w', h') <- liftIO $ reconfigure w h
liftIO $ Gtk.labelSetText label $ unwords ["Width:",show w',"Height:",show h'] liftIO $ Gtk.labelSetText label $ unwords ["Width:",show w',"Height:",show h']
Gtk.widgetShowAll window Gtk.widgetShowAll window
Gtk.mainGUI Gtk.mainGUI

View File

@ -105,11 +105,11 @@ colorLookup hs t = if inRange (bounds hs) t then c else (0.0, 0.0, 0.0)
Mountain -> (0.5, 0.5, 0.5) Mountain -> (0.5, 0.5, 0.5)
coordLookup :: (Int,Int) -> GLfloat -> (GLfloat, GLfloat, GLfloat) coordLookup :: (Int,Int) -> GLfloat -> (GLfloat, GLfloat, GLfloat)
coordLookup (x,y) h = coordLookup (x,z) y =
if even x then if even x then
(fromIntegral $ x `div` 2, fromIntegral (2 * y) * lineHeight, h) (fromIntegral $ x `div` 2, y, fromIntegral (2 * z) * lineHeight)
else else
(fromIntegral (x `div` 2) / 2.0, fromIntegral (2 * y + 1) * lineHeight, h) (fromIntegral (x `div` 2) / 2.0, y, fromIntegral (2 * z + 1) * lineHeight)
-- if writing in ASCII-Format transpose so i,j -> y,x -- if writing in ASCII-Format transpose so i,j -> y,x

View File

@ -1,12 +1,12 @@
module Render.Misc where module Render.Misc where
import Graphics.Rendering.OpenGL.GL.StringQueries import Control.Monad
import qualified Data.ByteString as B (ByteString)
import Graphics.Rendering.OpenGL.GL.Shaders
import Graphics.Rendering.OpenGL.GL.StateVar import Graphics.Rendering.OpenGL.GL.StateVar
import Graphics.Rendering.OpenGL.GL.StringQueries
import Graphics.Rendering.OpenGL.GLU.Errors import Graphics.Rendering.OpenGL.GLU.Errors
import System.IO (hPutStrLn, stderr) import System.IO (hPutStrLn, stderr)
import Control.Monad
import Graphics.Rendering.OpenGL.GL.Shaders
import qualified Data.ByteString as B (ByteString)
checkError :: String -> IO () checkError :: String -> IO ()

View File

@ -1,17 +1,19 @@
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE BangPatterns #-}
module Render.Render where module Render.Render where
import Graphics.Rendering.OpenGL.GL.BufferObjects
import Graphics.Rendering.OpenGL.GL.ObjectName
import Graphics.Rendering.OpenGL.GL.StateVar
import Render.Misc
import Graphics.Rendering.OpenGL.Raw.Core31.Types (GLfloat)
import Foreign.Storable (sizeOf)
import Foreign.Marshal.Array (withArray)
import Graphics.Rendering.OpenGL.GL.VertexSpec
import Graphics.Rendering.OpenGL.GL.Shaders
import Graphics.Rendering.OpenGL.GL.VertexArrays (Capability(..), vertexAttribArray)
import qualified Data.ByteString as B import qualified Data.ByteString as B
import Foreign.Marshal.Array (withArray)
import Foreign.Storable (sizeOf)
import Graphics.Rendering.OpenGL.GL.BufferObjects
import Graphics.Rendering.OpenGL.GL.Framebuffer (clearColor)
import Graphics.Rendering.OpenGL.GL.ObjectName
import Graphics.Rendering.OpenGL.GL.Shaders
import Graphics.Rendering.OpenGL.GL.StateVar
import Graphics.Rendering.OpenGL.GL.VertexArrays (Capability (..),
vertexAttribArray)
import Graphics.Rendering.OpenGL.GL.VertexSpec
import Graphics.Rendering.OpenGL.Raw.Core31.Types (GLfloat)
import Render.Misc
vertexShaderFile :: String vertexShaderFile :: String
vertexShaderFile = "shaders/vertex.shader" vertexShaderFile = "shaders/vertex.shader"
@ -50,3 +52,8 @@ initShader = do
checkError "initShader" checkError "initShader"
return (projectionMatrixIndex, colorIndex, vertexIndex) return (projectionMatrixIndex, colorIndex, vertexIndex)
initRendering :: IO ()
initRendering = do
clearColor $= Color4 0 0 0 0
checkError "initRendering"