added shading, reduced debug-output
This commit is contained in:
@ -259,9 +259,9 @@ parseIQM a =
|
||||
bufferData ElementArrayBuffer $= (fromIntegral byteLen, p, StaticDraw)
|
||||
checkError "bufferData tris"
|
||||
return $ castPtr p
|
||||
putStrLn "Triangles:"
|
||||
printPtrAsWord32Array tris ((*3).fromIntegral.num_triangles.bareheader $ bare) 3
|
||||
print bare
|
||||
--putStrLn "Triangles:"
|
||||
--printPtrAsWord32Array tris ((*3).fromIntegral.num_triangles.bareheader $ bare) 3
|
||||
--print bare
|
||||
return $ IQM
|
||||
{ header = bareheader bare
|
||||
, texts = baretexts bare
|
||||
@ -275,14 +275,14 @@ parseIQM a =
|
||||
|
||||
createVAO :: [(IQMVertexArray, BufferObject)] -> IO ()
|
||||
createVAO bo = do
|
||||
print bo
|
||||
--print bo
|
||||
initVAO (AttribLocation 0) IQMPosition bo
|
||||
initVAO (AttribLocation 1) IQMNormal bo
|
||||
initVAO (AttribLocation 2) IQMTexCoord bo
|
||||
|
||||
initVAO :: AttribLocation -> IQMVertexArrayType -> [(IQMVertexArray, BufferObject)] -> IO ()
|
||||
initVAO l t bo = do
|
||||
print $ concat ["adding ", show t, " to vertexBufferObject"]
|
||||
--print $ concat ["adding ", show t, " to vertexBufferObject"]
|
||||
let (IQMVertexArray _ _ _ num _ _,buf) = case filter (\(IQMVertexArray ty _ _ _ _ _, _) -> ty == t) bo of
|
||||
[(a,b)] -> (a,b)
|
||||
_ -> error "IQM-Object not render-able with current shader-mechanics"
|
||||
@ -325,11 +325,11 @@ readInVAO d vcount (IQMVertexArray type' a format num offset ptr) =
|
||||
putStrLn $ concat ["Allocating ", show vcount ,"x", show num,"x",show (vaSize format)," = ", show byteLen, " Bytes at ", show p, " for ", show type']
|
||||
putStrLn $ concat ["Filling starting at ", show offset, " with: "]
|
||||
unsafeUseAsCString data' (\s -> copyBytes p s byteLen)
|
||||
case type' of
|
||||
{-case type' of
|
||||
IQMBlendIndexes -> printPtrAsUByteArray p numElems 4
|
||||
IQMBlendWeights -> printPtrAsUByteArray p numElems 4
|
||||
IQMTexCoord -> printPtrAsFloatArray p numElems 2
|
||||
_ -> printPtrAsFloatArray p numElems 3
|
||||
_ -> printPtrAsFloatArray p numElems 3-}
|
||||
return $ IQMVertexArray type' a format num offset $ castPtr p
|
||||
|
||||
-- | Real internal Parser.
|
||||
|
@ -180,7 +180,7 @@ initMapShader tessFac (buf, vertDes) = do
|
||||
putStrLn $ unlines $ "Model-Uniforms: ":map show uni'
|
||||
putStrLn $ unlines $ ["Model-Indices: ", show (texIndex', normalIndex', vertexIndex')]
|
||||
|
||||
testobj <- parseIQM "models/box.iqm"
|
||||
testobj <- parseIQM "models/holzfaellerHaus1.iqm"
|
||||
let objs = [MapObject testobj (L.V3 0 10 0) (MapObjectState ())]
|
||||
|
||||
currentProgram $= Nothing
|
||||
@ -288,10 +288,11 @@ renderIQM :: IQM -> L.V3 CFloat -> L.V3 CFloat -> IO ()
|
||||
renderIQM m p@(L.V3 x y z) s@(L.V3 sx sy sz) = do
|
||||
withVAO (vertexArrayObject m) $ do
|
||||
vertexAttribArray (AttribLocation 0) $= Enabled
|
||||
vertexAttribArray (AttribLocation 1) $= Enabled
|
||||
checkError "setting array to enabled"
|
||||
bindBuffer ElementArrayBuffer $= Just (triangleBufferObject m)
|
||||
checkError "bindBuffer"
|
||||
let n = fromIntegral.num_triangles.header $ m
|
||||
let n = fromIntegral.(*3).num_triangles.header $ m
|
||||
--print $ concat ["drawing ", show n," triangles"]
|
||||
drawElements Triangles n UnsignedInt nullPtr
|
||||
checkError "drawing model"
|
||||
@ -332,7 +333,7 @@ drawMap = do
|
||||
|
||||
glPatchParameteri gl_PATCH_VERTICES 3
|
||||
|
||||
cullFace $= Nothing --Just Front
|
||||
cullFace $= Just Front
|
||||
polygonMode $= (Fill,Fill)
|
||||
|
||||
glDrawArrays gl_PATCHES 0 (fromIntegral numVert)
|
||||
@ -491,11 +492,11 @@ render = do
|
||||
currentProgram $= Just (state ^. gl.glMap.objectProgram)
|
||||
checkError "setting up shadowmap-program"
|
||||
--set up projection (= copy from state)
|
||||
{-mat44ToGPU frust projmo "mapObjects-projection"
|
||||
mat44ToGPU frust projmo "mapObjects-projection"
|
||||
--set up camera
|
||||
mat44ToGPU cam' vmatmo "mapObjects-cam"
|
||||
--set up normal
|
||||
mat33ToGPU nmap nmatmo "mapObjects-nmat"-}
|
||||
mat33ToGPU nmap nmatmo "mapObjects-nmat"
|
||||
|
||||
mapM_ renderObject (state ^. gl.glMap.mapObjects)
|
||||
checkError "draw mapobjects"
|
||||
|
Reference in New Issue
Block a user