minor cleanup

This commit is contained in:
Nicole Dresselhaus 2014-06-10 23:37:05 +02:00
parent 1e9c6a24fd
commit 32f1043d7c
No known key found for this signature in database
GPG Key ID: BC16D887851A1A80
2 changed files with 8 additions and 6 deletions

View File

@ -231,18 +231,18 @@ parseIQM a =
createVAO :: [(IQMVertexArray, BufferObject)] -> IO () createVAO :: [(IQMVertexArray, BufferObject)] -> IO ()
createVAO bo = do createVAO bo = do
print bo print bo
initVAO (AttribLocation 0) IQMPosition bo initVAO (AttribLocation 0) IQMPosition bo
initVAO (AttribLocation 1) IQMNormal bo initVAO (AttribLocation 1) IQMNormal bo
initVAO (AttribLocation 2) IQMTexCoord bo initVAO (AttribLocation 2) IQMTexCoord bo
initVAO :: AttribLocation -> IQMVertexArrayType -> [(IQMVertexArray, BufferObject)] -> IO () initVAO :: AttribLocation -> IQMVertexArrayType -> [(IQMVertexArray, BufferObject)] -> IO ()
initVAO l t bo = do initVAO l t bo = do
print t print $ concat ["adding ", show t, " to vertexBufferObject"]
let (IQMVertexArray _ _ _ num _ _,buf) = case filter (\(IQMVertexArray ty _ _ _ _ _, _) -> ty == t) bo of let (IQMVertexArray _ _ _ num _ _,buf) = case filter (\(IQMVertexArray ty _ _ _ _ _, _) -> ty == t) bo of
[(a,b)] -> (a,b) [(a,b)] -> (a,b)
_ -> error "IQM-Object not render-able with current shader-mechanics" _ -> error "IQM-Object not render-able with current shader-mechanics"
bindBuffer (toBufferTargetfromVAType t)$= Just buf bindBuffer (toBufferTargetfromVAType t) $= Just buf
vertexAttribArray l $= Enabled vertexAttribArray l $= Enabled
vertexAttribPointer l $= (ToFloat, VertexArrayDescriptor num Float 0 nullPtr) vertexAttribPointer l $= (ToFloat, VertexArrayDescriptor num Float 0 nullPtr)

View File

@ -288,7 +288,9 @@ renderIQM :: IQM -> L.V3 CFloat -> L.V3 CFloat -> IO ()
renderIQM m p@(L.V3 x y z) s@(L.V3 sx sy sz) = do renderIQM m p@(L.V3 x y z) s@(L.V3 sx sy sz) = do
bindVertexArrayObject $= Just (vertexArrayObject m) bindVertexArrayObject $= Just (vertexArrayObject m)
let n = num_vertexes.header $ m let n = num_vertexes.header $ m
--print $ concat ["drawing ", show n," triangles from object ",show m]
glDrawArrays gl_TRIANGLES 0 (fromIntegral n) glDrawArrays gl_TRIANGLES 0 (fromIntegral n)
checkError "drawing model"
return () return ()
renderObject :: MapObject -> IO () renderObject :: MapObject -> IO ()