diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2010-04-12 14:40:31 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2010-04-12 14:40:31 +0200 |
commit | dafe16f191f99dc1199a5b386fad916a78c5c4f1 (patch) | |
tree | 35b889df1cfdbf696e0b2e68c1e17f3fca6a743e /src/GLX.hs | |
parent | d56001cb33d5a6d688cfd97dba71408c8fff1f7d (diff) | |
download | htanks-dafe16f191f99dc1199a5b386fad916a78c5c4f1.tar htanks-dafe16f191f99dc1199a5b386fad916a78c5c4f1.zip |
Some improvements on coordinate calculation & player rendering
Diffstat (limited to 'src/GLX.hs')
-rw-r--r-- | src/GLX.hs | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -11,7 +11,7 @@ import Data.Maybe (isJust) import Data.Ratio import Graphics.Rendering.OpenGL.GL (($=), GLdouble, GLfloat, Vector3(..), Capability(..)) -import Graphics.Rendering.OpenGL.GL.CoordTrans (matrixMode, MatrixMode(..), viewport, Position(..), Size(..), loadIdentity, ortho, translate) +import Graphics.Rendering.OpenGL.GL.CoordTrans (matrixMode, MatrixMode(..), viewport, Position(..), Size(..), loadIdentity, ortho, translate, scale, rotate) import Graphics.X11.Types import Graphics.X11.Xlib.Atom (internAtom) @@ -179,8 +179,9 @@ windowToGameCoords :: Integral a => GLX -> a -> a -> IO (Float, Float) windowToGameCoords glx x y = getWindowAttributes (glxDisplay glx) (glxWindow glx) >>= \wa -> let w = fromIntegral . wa_width $ wa h = fromIntegral . wa_height $ wa - in return (((-w/2 + wx)/s + lw/2), ((h/2 - wy)/s + lh/2)) - where s = fromRational . glxScale $ glx + in return (((-w/2 + wx)/sx + lw/2), ((h/2 - wy)/sy + lh/2)) + where sx = fromRational . glxScale $ glx + sy = sx*(cos $ pi/6) lw = fromIntegral . glxLevelWidth $ glx lh = fromIntegral . glxLevelHeight $ glx wx = fromIntegral x @@ -197,6 +198,8 @@ resize lw lh w h = do matrixMode $= Projection loadIdentity ortho (-sf*aspectf) (sf*aspectf) (-sf) sf (-1) 1 + scale 1 1 (0.1 :: GLfloat) + rotate (-30) $ Vector3 1 0 (0 :: GLfloat) translate $ Vector3 (-(fromIntegral lw)/2) (-(fromIntegral lh)/2) (0 :: GLfloat) matrixMode $= Modelview 0 |