- fixed imports
- cleaned debug-info. now not binary anymore, but readable
This commit is contained in:
Nicole Dresselhaus 2014-06-10 23:15:59 +02:00
parent 4bbf80ecab
commit 1e9c6a24fd
No known key found for this signature in database
GPG Key ID: BC16D887851A1A80
2 changed files with 19 additions and 4 deletions

View File

@ -31,6 +31,8 @@ import Foreign.Marshal.Utils
import Prelude as P hiding (take, null)
import Render.Misc (printPtrAsFloatArray, printPtrAsUByteArray)
-- | helper-function for creating an integral out of [8-Bit Ints]
_w8ToInt :: Integral a => a -> a -> a
_w8ToInt i add = 256*i + add
@ -271,14 +273,19 @@ readInVAO :: ByteString -> Word32 -> IQMVertexArray -> IO IQMVertexArray
readInVAO d vcount (IQMVertexArray type' a format num offset ptr) =
do
let
byteLen = fromIntegral vcount * fromIntegral num * vaSize format
numElems = fromIntegral vcount * fromIntegral num
byteLen = numElems * vaSize format
data' = skipDrop (fromIntegral offset) byteLen d
unless (ptr == nullPtr) $ error $ "Error reading Vertex-Array: Double Read of " ++ show type'
p <- mallocBytes byteLen
putStrLn $ concat ["Allocating ", show vcount ,"x", show num,"x",show (vaSize format)," = ", show byteLen, " Bytes at ", show p, " for ", show type']
putStrLn $ concat ["Filling with: ", show data', " starting at ", show offset]
putStrLn $ concat ["Filling starting at ", show offset, " with: "]
unsafeUseAsCString data' (\s -> copyBytes p s byteLen)
case type' of
IQMBlendIndexes -> printPtrAsUByteArray p numElems
IQMBlendWeights -> printPtrAsUByteArray p numElems
_ -> printPtrAsFloatArray p numElems
return $ IQMVertexArray type' a format num offset $ castPtr p
-- | Real internal Parser.

View File

@ -10,7 +10,9 @@ import Graphics.Rendering.OpenGL.GLU.Errors
import Graphics.UI.SDL.Types (Texture)
import System.IO (hPutStrLn, stderr)
import Linear
import Foreign.C (CFloat)
import Foreign.C (CFloat, CUChar)
import Foreign.Marshal.Array (peekArray)
import Foreign.Ptr (Ptr, castPtr)
up :: V3 CFloat
up = V3 0 1 0
@ -124,7 +126,13 @@ getCam (x',z') dist' xa' ya' = lookAt (cpos ^+^ at') at' up
-- | Prints any Pointer as Float-Array with given number of elements.
printPtrAsFloatArray :: Ptr a -> Int -> IO ()
printPtrAsFloatArray pointer num = do
a <- peekArray num (castPtr pointer :: Ptr Float)
a <- peekArray num (castPtr pointer :: Ptr CFloat)
print a
-- | Prints any Pointer as UByte-Array with given number of elements.
printPtrAsUByteArray :: Ptr a -> Int -> IO ()
printPtrAsUByteArray pointer num = do
a <- peekArray num (castPtr pointer :: Ptr CUChar)
print a
curb :: Ord a => a -> a -> a -> a