minor
- fixed imports - cleaned debug-info. now not binary anymore, but readable
This commit is contained in:
parent
4bbf80ecab
commit
1e9c6a24fd
@ -31,6 +31,8 @@ import Foreign.Marshal.Utils
|
|||||||
|
|
||||||
import Prelude as P hiding (take, null)
|
import Prelude as P hiding (take, null)
|
||||||
|
|
||||||
|
import Render.Misc (printPtrAsFloatArray, printPtrAsUByteArray)
|
||||||
|
|
||||||
-- | helper-function for creating an integral out of [8-Bit Ints]
|
-- | helper-function for creating an integral out of [8-Bit Ints]
|
||||||
_w8ToInt :: Integral a => a -> a -> a
|
_w8ToInt :: Integral a => a -> a -> a
|
||||||
_w8ToInt i add = 256*i + add
|
_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) =
|
readInVAO d vcount (IQMVertexArray type' a format num offset ptr) =
|
||||||
do
|
do
|
||||||
let
|
let
|
||||||
byteLen = fromIntegral vcount * fromIntegral num * vaSize format
|
numElems = fromIntegral vcount * fromIntegral num
|
||||||
|
byteLen = numElems * vaSize format
|
||||||
data' = skipDrop (fromIntegral offset) byteLen d
|
data' = skipDrop (fromIntegral offset) byteLen d
|
||||||
|
|
||||||
unless (ptr == nullPtr) $ error $ "Error reading Vertex-Array: Double Read of " ++ show type'
|
unless (ptr == nullPtr) $ error $ "Error reading Vertex-Array: Double Read of " ++ show type'
|
||||||
p <- mallocBytes byteLen
|
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 ["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)
|
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
|
return $ IQMVertexArray type' a format num offset $ castPtr p
|
||||||
|
|
||||||
-- | Real internal Parser.
|
-- | Real internal Parser.
|
||||||
|
@ -10,7 +10,9 @@ import Graphics.Rendering.OpenGL.GLU.Errors
|
|||||||
import Graphics.UI.SDL.Types (Texture)
|
import Graphics.UI.SDL.Types (Texture)
|
||||||
import System.IO (hPutStrLn, stderr)
|
import System.IO (hPutStrLn, stderr)
|
||||||
import Linear
|
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 CFloat
|
||||||
up = V3 0 1 0
|
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.
|
-- | Prints any Pointer as Float-Array with given number of elements.
|
||||||
printPtrAsFloatArray :: Ptr a -> Int -> IO ()
|
printPtrAsFloatArray :: Ptr a -> Int -> IO ()
|
||||||
printPtrAsFloatArray pointer num = do
|
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
|
print a
|
||||||
|
|
||||||
curb :: Ord a => a -> a -> a -> a
|
curb :: Ord a => a -> a -> a -> a
|
||||||
|
Loading…
Reference in New Issue
Block a user