| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Box3D.Base
Description
Low-level bindings to box3d/base.h: version info, global allocator /
assert / log hooks, and timing helpers.
Synopsis
- data Version = Version {}
- getVersion :: IO Version
- isDoublePrecision :: IO Bool
- type AllocFcn = Int32 -> Int32 -> IO (Ptr ())
- type FreeFcn = Ptr () -> IO ()
- setAllocator :: FunPtr AllocFcn -> FunPtr FreeFcn -> IO ()
- getByteCount :: IO Int32
- type AssertFcn = CString -> CString -> CInt -> IO CInt
- type LogFcn = CString -> IO ()
- setAssertFcn :: FunPtr AssertFcn -> IO ()
- setLogFcn :: FunPtr LogFcn -> IO ()
- getTicks :: IO Word64
- getMilliseconds :: Word64 -> IO CFloat
- getMillisecondsAndReset :: Ptr Word64 -> IO CFloat
- yield :: IO ()
- sleep :: CInt -> IO ()
- hash :: Word32 -> Ptr Word8 -> CInt -> IO Word32
Version
Version numbering scheme, see https://semver.org/.
Constructors
| Version | |
Fields
| |
Instances
| Storable Version Source # | |
| Show Version Source # | |
| Eq Version Source # | |
getVersion :: IO Version Source #
Get the current version of Box3D.
Allocator
type AllocFcn = Int32 -> Int32 -> IO (Ptr ()) Source #
User allocation function: void* (int32 size, int32 alignment).
setAllocator :: FunPtr AllocFcn -> FunPtr FreeFcn -> IO () Source #
Override the default allocation functions. Set during application startup.
The FunPtrs must point to C functions: the engine calls the hooks from
inside unsafe FFI calls, where re-entering Haskell is undefined
behaviour, so wrapping Haskell functions is not supported yet.
getByteCount :: IO Int32 Source #
Total bytes allocated by Box3D.
Assert / log hooks
type AssertFcn = CString -> CString -> CInt -> IO CInt Source #
Assert callback: int (const char* condition, const char* file, int line).
Return 0 to skip the debugger break.
setAssertFcn :: FunPtr AssertFcn -> IO () Source #
Override the default assert callback. Must point to a C function, see
setAllocator.
setLogFcn :: FunPtr LogFcn -> IO () Source #
Override the default logging callback. Must point to a C function, see
setAllocator.
Timing
getMillisecondsAndReset :: Ptr Word64 -> IO CFloat Source #
Milliseconds passed from an initial tick value, resetting it to now.