Render floor
This commit is contained in:
parent
c23e63e667
commit
656b5e8bc1
1 changed files with 39 additions and 6 deletions
37
Render.hs
37
Render.hs
|
@ -18,12 +18,14 @@ import qualified Data.Map as M
|
|||
|
||||
import Bindings.GLPng
|
||||
|
||||
import Graphics.Rendering.OpenGL.GL (($=), GLfloat, GLdouble)
|
||||
import Graphics.Rendering.OpenGL.GL (($=), GLfloat, GLdouble, Capability(..))
|
||||
import Graphics.Rendering.OpenGL.GL.BeginEnd (renderPrimitive, PrimitiveMode(..))
|
||||
import Graphics.Rendering.OpenGL.GL.CoordTrans (matrixMode, MatrixMode(..), viewport, Position(..), Size(..), loadIdentity, ortho)
|
||||
import Graphics.Rendering.OpenGL.GL.Framebuffer (clear, ClearBuffer(..))
|
||||
import Graphics.Rendering.OpenGL.GL.Texturing.Objects (TextureObject(..))
|
||||
import Graphics.Rendering.OpenGL.GL.Texturing.Application (texture)
|
||||
import Graphics.Rendering.OpenGL.GL.Texturing.Objects (textureBinding, TextureObject(..))
|
||||
import Graphics.Rendering.OpenGL.GL.Texturing.Parameters (Repetition(..), Clamping(..), TextureFilter(..), MinificationFilter, MagnificationFilter)
|
||||
import Graphics.Rendering.OpenGL.GL.Texturing.Specification (TextureTarget(..))
|
||||
import Graphics.Rendering.OpenGL.GL.VertexSpec
|
||||
|
||||
|
||||
|
@ -78,14 +80,45 @@ render = do
|
|||
tank <- liftM head $ gets tanks
|
||||
let x = fromReal . posx $ tank
|
||||
y = fromReal . posy $ tank
|
||||
(lw, lh) <- gets level >>= \l -> return (fromIntegral . levelWidth $ l :: GLfloat, fromIntegral . levelHeight $ l :: GLfloat)
|
||||
|
||||
textureWood <- getTexture TextureWood
|
||||
|
||||
liftIO $ do
|
||||
clear [ColorBuffer]
|
||||
|
||||
loadIdentity
|
||||
|
||||
texture Texture2D $= Enabled
|
||||
textureBinding Texture2D $= Just textureWood
|
||||
|
||||
renderPrimitive Quads $ do
|
||||
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
||||
vertex $ Vertex2 (-0.5*lw) (-0.5*lh)
|
||||
|
||||
texCoord $ TexCoord2 0 lw
|
||||
vertex $ Vertex2 (-0.5*lw) (0.5*lh)
|
||||
|
||||
texCoord $ TexCoord2 lh lw
|
||||
vertex $ Vertex2 (0.5*lw) (0.5*lh)
|
||||
|
||||
texCoord $ TexCoord2 lh (0 :: GLfloat)
|
||||
vertex $ Vertex2 (0.5*lw) (-0.5*lh)
|
||||
|
||||
|
||||
texture Texture2D $= Disabled
|
||||
|
||||
renderPrimitive Quads $ do
|
||||
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
||||
vertex $ Vertex2 (x-0.5 :: GLfloat) (y-0.5 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat)
|
||||
vertex $ Vertex2 (x-0.5 :: GLfloat) (y+0.5 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat)
|
||||
vertex $ Vertex2 (x+0.5 :: GLfloat) (y+0.5 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
|
||||
vertex $ Vertex2 (x+0.5 :: GLfloat) (y-0.5 :: GLfloat)
|
||||
|
||||
fromReal :: (Real a, Fractional b) => a -> b
|
||||
|
|
Reference in a new issue