Simplified texture and model loading; also use crosshair for DefaultPlayer
This commit is contained in:
parent
dafe16f191
commit
08762ddc9a
7 changed files with 55 additions and 54 deletions
|
@ -3,7 +3,6 @@ module Render ( setup
|
|||
) where
|
||||
|
||||
|
||||
import Paths_htanks
|
||||
import Game
|
||||
import MainLoop
|
||||
import Level
|
||||
|
@ -36,18 +35,6 @@ import Graphics.Rendering.OpenGL.GL.Texturing.Specification (TextureTarget(..))
|
|||
import Graphics.Rendering.OpenGL.GL.VertexArrays (clientState, ClientArrayType(..))
|
||||
import Graphics.Rendering.OpenGL.GL.VertexSpec
|
||||
|
||||
import Foreign.ForeignPtr
|
||||
import Foreign.Marshal.Array
|
||||
|
||||
|
||||
texturePath :: Texture -> IO FilePath
|
||||
texturePath t = getDataFileName $ path t
|
||||
where
|
||||
path TextureWood = "tex/Wood.png"
|
||||
path TextureTank = "tex/Tank.png"
|
||||
path TextureCannon = "tex/Cannon.png"
|
||||
path TextureBullet = "tex/Bullet.png"
|
||||
path TextureCrosshair = "tex/Crosshair.png"
|
||||
|
||||
getTexture :: Texture -> Main TextureObject
|
||||
getTexture t = do
|
||||
|
@ -63,11 +50,6 @@ getTexture t = do
|
|||
modify $ \state -> state {textures = M.insert t tex ts}
|
||||
return tex
|
||||
|
||||
modelPath :: Model -> IO FilePath
|
||||
modelPath t = getDataFileName $ path t
|
||||
where
|
||||
path ModelTank = "model/tank.obj"
|
||||
|
||||
getModel :: Model -> Main InterleavedObj
|
||||
getModel m = do
|
||||
ms <- gets models
|
||||
|
@ -176,19 +158,6 @@ render = do
|
|||
rotate 90 $ Vector3 1 0 (0 :: GLfloat)
|
||||
drawObject modelTank 1
|
||||
|
||||
{-unsafeRenderPrimitive Quads $ do
|
||||
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
||||
vertex $ Vertex2 (-0.5 :: GLfloat) (-0.5 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat)
|
||||
vertex $ Vertex2 (-0.5 :: GLfloat) (0.5 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat)
|
||||
vertex $ Vertex2 (0.5 :: GLfloat) (0.5 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
|
||||
vertex $ Vertex2 (0.5 :: GLfloat) (-0.5 :: GLfloat)-}
|
||||
|
||||
rotate (rotAim-rotDir) $ Vector3 0 0 (1 :: GLfloat)
|
||||
|
||||
--textureBinding Texture2D $= Just textureCannon
|
||||
|
@ -196,22 +165,7 @@ render = do
|
|||
unsafePreservingMatrix $ do
|
||||
rotate 90 $ Vector3 1 0 (0 :: GLfloat)
|
||||
drawObject modelTank 0
|
||||
|
||||
|
||||
|
||||
{-unsafeRenderPrimitive Quads $ do
|
||||
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
||||
vertex $ Vertex2 (-0.5 :: GLfloat) (-0.5 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat)
|
||||
vertex $ Vertex2 (-0.5 :: GLfloat) (0.5 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat)
|
||||
vertex $ Vertex2 (0.5 :: GLfloat) (0.5 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
|
||||
vertex $ Vertex2 (0.5 :: GLfloat) (-0.5 :: GLfloat)-}
|
||||
|
||||
texture Texture2D $= Enabled
|
||||
|
||||
forM_ bulletlist $ \bullet -> unsafePreservingMatrix $ do
|
||||
|
@ -219,7 +173,7 @@ render = do
|
|||
y = realToFrac . bulletY $ bullet
|
||||
rotDir = realToFrac . bulletDir $ bullet
|
||||
|
||||
translate $ Vector3 x y (0.1 :: GLfloat)
|
||||
translate $ Vector3 x y (0.2 :: GLfloat)
|
||||
rotate 30 $ Vector3 1 0 (0 :: GLfloat)
|
||||
rotate rotDir $ Vector3 0 0 (1 :: GLfloat)
|
||||
|
||||
|
|
Reference in a new issue