Skip to content

Commit

Permalink
Got a good look at that model now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Palmer authored and Luke Palmer committed Apr 9, 2010
1 parent d2acc64 commit 20271f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Graphics/Formats/Collada/Render.hs
Expand Up @@ -88,8 +88,8 @@ compileInput (O.Input _ semantic source) = do
where
convertSem O.SemPosition = GL.VertexArray
convertSem O.SemNormal = GL.NormalArray
convertSem O.SemVertex = GL.VertexArray -- hmmm
convertSem O.SemTexCoord = GL.TextureCoordArray
conversion sem = error $ "Unknown semantic: " ++ show sem

compilePrimitive :: O.Primitive -> CompileM (DrawM ())
compilePrimitive (O.PrimTriangles _material inputs indices) = do
Expand All @@ -109,7 +109,6 @@ compilePrimitive (O.PrimTriangles _material inputs indices) = do
return . wrapDrawM (GL.renderPrimitive GL.Triangles) . forM_ (zip (cycle [0..maxE]) indices) $ \(inpix,ix) -> do
let inp = Map.findWithDefault mempty inpix compiled
ciIndex inp ix
_ -> return (return ())



Expand Down
17 changes: 14 additions & 3 deletions sample.hs
Expand Up @@ -7,6 +7,7 @@ import qualified Graphics.Rendering.OpenGL.GL as GL
import qualified Graphics.Rendering.OpenGL.GLU as GLU
import Control.Applicative
import Data.VectorSpace
import Data.IORef

instance AdditiveGroup GL.GLdouble where
zeroV = 0
Expand All @@ -21,6 +22,8 @@ instance InnerSpace GL.GLdouble where
(<.>) = (*)

main = do
GLUT.initialDisplayMode GL.$= [GLUT.RGBAMode, GLUT.DoubleBuffered, GLUT.WithDepthBuffer]

GLUT.getArgsAndInitialize
GLUT.createWindow "Hello!"

Expand All @@ -34,6 +37,10 @@ main = do
GL.depthFunc GL.$= Just GL.Lequal
GL.depthMask GL.$= GL.Enabled

print =<< GL.get GLUT.doubleBuffered

scaleRef <- newIORef 1

GLUT.displayCallback GLUT.$= (do
GL.clearColor GL.$= GL.Color4 0.2 0 0 0
GL.clear [GL.ColorBuffer, GL.DepthBuffer]
Expand All @@ -44,13 +51,17 @@ main = do
GL.matrixMode GL.$= GL.Modelview 0
GL.loadIdentity
GLU.lookAt (uncurry3 GL.Vertex3 eye) (uncurry3 GL.Vertex3 object) (uncurry3 GL.Vector3 up)
scale <- readIORef scaleRef
writeIORef scaleRef $! (scale + 0.001 :: GL.GLfloat)
GL.scale scale scale scale
action
GLUT.swapBuffers)
GLUT.swapBuffers
GLUT.postRedisplay Nothing)
GLUT.mainLoop

where
eye = (0,200,120)
object = (120, 0, 0)
eye = (120,200,120)
object = (120, 100, 0)
up = normalized $ (object ^-^ eye) `cross` ((object ^-^ eye) `cross` (0,1,0))
cross (bx,by,bz) (cx,cy,cz) = (by*cz - cy*bz, bz*cx - bx*cz, bx*cy - by*cx)

Expand Down

0 comments on commit 20271f6

Please sign in to comment.