From 4bbf80ecab66507a66f686b46cdb1cd40abdf1ef Mon Sep 17 00:00:00 2001 From: Stefan Dresselhaus Date: Tue, 10 Jun 2014 22:59:48 +0200 Subject: [PATCH] not changing to Data.Vector and staying on C-Array - added Print-Function for Float-C-Arrays --- src/Importer/IQM/Parser.hs | 2 +- src/Render/Misc.hs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Importer/IQM/Parser.hs b/src/Importer/IQM/Parser.hs index 6f3cde8..b3cafb1 100644 --- a/src/Importer/IQM/Parser.hs +++ b/src/Importer/IQM/Parser.hs @@ -276,7 +276,7 @@ readInVAO d vcount (IQMVertexArray type' a format num offset ptr) = unless (ptr == nullPtr) $ error $ "Error reading Vertex-Array: Double Read of " ++ show type' p <- mallocBytes byteLen - putStrLn $ concat ["Allocating ", 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] unsafeUseAsCString data' (\s -> copyBytes p s byteLen) return $ IQMVertexArray type' a format num offset $ castPtr p diff --git a/src/Render/Misc.hs b/src/Render/Misc.hs index a00a408..4d302d1 100644 --- a/src/Render/Misc.hs +++ b/src/Render/Misc.hs @@ -121,6 +121,12 @@ getCam (x',z') dist' xa' ya' = lookAt (cpos ^+^ at') at' up xa = realToFrac xa' ya = realToFrac ya'-} +-- | 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) + print a + curb :: Ord a => a -> a -> a -> a curb l h x | x < l = l