packages feed

nehe-tuts 0.2.0 → 0.2.1

raw patch · 2 files changed

+16/−25 lines, 2 files

Files

lesson11.hs view
@@ -14,12 +14,11 @@ import Foreign ( withForeignPtr, plusPtr, alloca, peek ) import qualified Data.ByteString.Internal as BSI import Util ( Image(..), bitmapLoad )-import Data.Array.IO ( readArray, IOUArray, newListArray )+import Data.Array.IO ( readArray, IOArray, newListArray ) import Control.Applicative ( (<$>), (<*>) ) import System.Directory ( getCurrentDirectory, setCurrentDirectory )-import Unsafe.Coerce ( unsafeCoerce ) -type Points = IOUArray (Int, Int, Int) Float+type Points = IOArray (Int, Int, Int) GLfloat  initGL :: IO GLuint initGL = do@@ -103,21 +102,21 @@         fxb = fromIntegral (x+1)/44 :: GLfloat         fyb = fromIntegral (y+1)/44 :: GLfloat     glTexCoord2f fx fy-    join $ glVertex3f <$> (readArray' points (x,y,0))-                      <*> (readArray' points (x,y,1))-                      <*> (readArray' points (x',y,2))+    join $ glVertex3f <$> (readArray points (x,y,0))+                      <*> (readArray points (x,y,1))+                      <*> (readArray points (x',y,2))     glTexCoord2f fx fyb-    join $ glVertex3f <$> (readArray' points (x,y+1,0))-                      <*> (readArray' points (x,y+1,1))-                      <*> (readArray' points (x',y+1,2))+    join $ glVertex3f <$> (readArray points (x,y+1,0))+                      <*> (readArray points (x,y+1,1))+                      <*> (readArray points (x',y+1,2))     glTexCoord2f fxb fyb-    join $ glVertex3f <$> (readArray' points (x+1,y+1,0))-                      <*> (readArray' points (x+1,y+1,1))-                      <*> (readArray' points ((x'+1)`mod`45,y+1,2))+    join $ glVertex3f <$> (readArray points (x+1,y+1,0))+                      <*> (readArray points (x+1,y+1,1))+                      <*> (readArray points ((x'+1)`mod`45,y+1,2))     glTexCoord2f fxb fy-    join $ glVertex3f <$> (readArray' points (x+1,y,0))-                      <*> (readArray' points (x+1,y,1))-                      <*> (readArray' points ((x'+1)`mod`45,y,2))+    join $ glVertex3f <$> (readArray points (x+1,y,0))+                      <*> (readArray points (x+1,y,1))+                      <*> (readArray points ((x'+1)`mod`45,y,2))   glEnd    writeIORef xrot $! xr + 0.3@@ -133,14 +132,6 @@    glFlush -readArray' :: IOUArray (Int, Int, Int) Float -> (Int, Int, Int) -> IO GLfloat-readArray' a (x,y,z) = do-  r <- readArray a (x,y,z)-  -- This line is extremely slow, because a RULES is missing-  -- in openglraw.  You can replace it with Unsafe.Coerce.unsafeCoerce-  -- on most platforms to get a HUGE speed up.-  return $! unsafeCoerce r- keyPressed :: GLFW.KeyCallback keyPressed GLFW.KeyEsc True = shutdown >> return () keyPressed _           _    = return ()@@ -180,7 +171,7 @@      let elems = concat [[((x/5)-4.5),                           ((y/5)-4.5),                           sin (((x/5)*40/360)*pi*2)]-                        | x <- [0..44]::[Float], y <- [0..44]::[Float] ]+                        | x <- [0..44]::[GLfloat], y <- [0..44]::[GLfloat] ]      points <- newListArray ((0,0,0), (44,44,2)) elems :: IO Points      -- initialize our window.      tex <- initGL
nehe-tuts.cabal view
@@ -1,5 +1,5 @@ Name:   nehe-tuts-Version: 0.2.0+Version: 0.2.1 Synopsis:   Port of the NeHe OpenGL tutorials to Haskell. Description:    Port of the NeHe OpenGL tutorials to Haskell; so far only lessons 1-12 have been ported. Author: Jason Dagit