mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2025-07-04 20:18:47 +02:00
Add setNextWindow functions, pushColor, pushStyle, indent-related functions (#27)
This commit is contained in:
@ -19,14 +19,15 @@ import Language.C.Types
|
||||
|
||||
-- dear-imgui
|
||||
import DearImGui.Structs
|
||||
( ImVec3, ImVec4 )
|
||||
( ImVec2, ImVec3, ImVec4 )
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
imguiContext :: Context
|
||||
imguiContext = mempty
|
||||
{ ctxTypesTable = Map.fromList
|
||||
[ ( TypeName "ImVec3", [t| ImVec3 |] )
|
||||
[ ( TypeName "ImVec2", [t| ImVec2 |] )
|
||||
, ( TypeName "ImVec3", [t| ImVec3 |] )
|
||||
, ( TypeName "ImVec4", [t| ImVec4 |] )
|
||||
]
|
||||
}
|
||||
|
@ -8,6 +8,23 @@ import Foreign
|
||||
( Storable(..), castPtr, plusPtr )
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
data ImVec2 = ImVec2 { x, y :: {-# unpack #-} !Float }
|
||||
|
||||
|
||||
instance Storable ImVec2 where
|
||||
sizeOf ~ImVec2{x, y} = sizeOf x + sizeOf y
|
||||
|
||||
alignment _ = 0
|
||||
|
||||
poke ptr ImVec2{ x, y } = do
|
||||
poke (castPtr ptr `plusPtr` (sizeOf x * 0)) x
|
||||
poke (castPtr ptr `plusPtr` (sizeOf x * 1)) y
|
||||
|
||||
peek ptr = do
|
||||
x <- peek (castPtr ptr )
|
||||
y <- peek (castPtr ptr `plusPtr` (sizeOf x * 1))
|
||||
return ImVec2{ x, y }
|
||||
|
||||
|
||||
data ImVec3 = ImVec3 { x, y, z :: {-# unpack #-} !Float }
|
||||
|
||||
|
Reference in New Issue
Block a user