iqm still does not render, starts again.

This commit is contained in:
Stefan Dresselhaus
2014-05-16 09:10:09 +02:00
parent a6efea80cf
commit da3a334121
8 changed files with 184 additions and 175 deletions

View File

@ -228,14 +228,17 @@ parseIQM a =
createVAO :: [(IQMVertexArray, BufferObject)] -> IO ()
createVAO bo = do
print bo
initVAO (AttribLocation 0) IQMPosition bo
initVAO (AttribLocation 2) IQMColor bo
initVAO (AttribLocation 1) IQMNormal bo
-- initVAO (AttribLocation 3) IQMTexCoord bo
initVAO (AttribLocation 2) IQMTexCoord bo
initVAO :: AttribLocation -> IQMVertexArrayType -> [(IQMVertexArray, BufferObject)] -> IO ()
initVAO l t bo = do
let [(IQMVertexArray _ _ _ num _ _,buf)] = filter (\(IQMVertexArray ty _ _ _ _ _, _) -> ty == t) bo
print t
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"
bindBuffer (toBufferTargetfromVAType t)$= Just buf
vertexAttribArray l $= Enabled
vertexAttribPointer l $= (ToFloat, VertexArrayDescriptor num Float 0 nullPtr)

View File

@ -134,6 +134,8 @@ initMapShader tessFac (buf, vertDes) = do
let
objs = [MapObject testobj (L.V3 0 10 0) (MapObjectState ())]
currentProgram $= Nothing
! vertexSource' <- B.readFile objectVertexShaderFile
! fragmentSource' <- B.readFile objectFragmentShaderFile
vertexShader' <- compileShaderSource VertexShader vertexSource'
@ -145,6 +147,22 @@ initMapShader tessFac (buf, vertDes) = do
currentProgram $= Just objProgram
vertexIndex' <- get (attribLocation program "Position")
vertexAttribArray vertexIndex $= Enabled
checkError "Object-vertexInd"
normalIndex' <- get (attribLocation program "Normal")
vertexAttribArray normalIndex $= Enabled
checkError "Object-normalInd"
texIndex' <- get (attribLocation program "TexCoord")
vertexAttribArray colorIndex $= Enabled
checkError "Object-texInd"
att <- get (activeAttribs objProgram)
putStrLn $ unlines $ "Attributes: ":map show att
putStrLn $ unlines $ ["Indices: ", show (texIndex', normalIndex', vertexIndex')]
checkError "initShader"
let sdata = MapShaderData
{ shdrVertexIndex = vertexIndex