mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-11-22 16:57:00 +00:00
Wrap GetCurrentContext and SetCurrentContext
This commit is contained in:
parent
0b86356a49
commit
36a38f774a
@ -18,6 +18,8 @@ module DearImGui
|
|||||||
Context(..)
|
Context(..)
|
||||||
, createContext
|
, createContext
|
||||||
, destroyContext
|
, destroyContext
|
||||||
|
, getCurrentContext
|
||||||
|
, setCurrentContext
|
||||||
|
|
||||||
-- * Main
|
-- * Main
|
||||||
, newFrame
|
, newFrame
|
||||||
@ -139,19 +141,31 @@ Cpp.using "namespace ImGui"
|
|||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGuiContext*@.
|
-- | Wraps @ImGuiContext*@.
|
||||||
newtype Context = Context (Ptr ())
|
newtype Context = Context (Ptr ImGuiContext)
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::CreateContext()@.
|
-- | Wraps @ImGui::CreateContext()@.
|
||||||
createContext :: MonadIO m => m Context
|
createContext :: MonadIO m => m Context
|
||||||
createContext = liftIO do
|
createContext = liftIO do
|
||||||
Context <$> [C.exp| void* { CreateContext() } |]
|
Context <$> [C.exp| ImGuiContext* { CreateContext() } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Wraps @ImGui::DestroyContext()@.
|
-- | Wraps @ImGui::DestroyContext()@.
|
||||||
destroyContext :: MonadIO m => Context -> m ()
|
destroyContext :: MonadIO m => Context -> m ()
|
||||||
destroyContext (Context contextPtr) = liftIO do
|
destroyContext (Context contextPtr) = liftIO do
|
||||||
[C.exp| void { DestroyContext((ImGuiContext*)$(void* contextPtr)); } |]
|
[C.exp| void { DestroyContext($(ImGuiContext* contextPtr)); } |]
|
||||||
|
|
||||||
|
|
||||||
|
-- | Wraps @ImGui::GetCurrentContext()@.
|
||||||
|
getCurrentContext :: MonadIO m => m Context
|
||||||
|
getCurrentContext = liftIO do
|
||||||
|
Context <$> [C.exp| ImGuiContext* { GetCurrentContext() } |]
|
||||||
|
|
||||||
|
|
||||||
|
-- | Wraps @ImGui::SetCurrentContext()@.
|
||||||
|
setCurrentContext :: MonadIO m => Context -> m ()
|
||||||
|
setCurrentContext (Context contextPtr) = liftIO do
|
||||||
|
[C.exp| void { SetCurrentContext($(ImGuiContext* contextPtr)) } |]
|
||||||
|
|
||||||
|
|
||||||
-- | Start a new Dear ImGui frame, you can submit any command from this point
|
-- | Start a new Dear ImGui frame, you can submit any command from this point
|
||||||
|
@ -53,10 +53,14 @@ instance Storable ImVec4 where
|
|||||||
return ImVec4{ x, y, z, w }
|
return ImVec4{ x, y, z, w }
|
||||||
|
|
||||||
|
|
||||||
|
data ImGuiContext
|
||||||
|
|
||||||
|
|
||||||
imguiContext :: Context
|
imguiContext :: Context
|
||||||
imguiContext = mempty
|
imguiContext = mempty
|
||||||
{ ctxTypesTable = Map.fromList
|
{ ctxTypesTable = Map.fromList
|
||||||
[ ( TypeName "ImVec3", [t| ImVec3 |] )
|
[ ( TypeName "ImVec3", [t| ImVec3 |] )
|
||||||
, ( TypeName "ImVec4", [t| ImVec4 |] )
|
, ( TypeName "ImVec4", [t| ImVec4 |] )
|
||||||
|
, ( TypeName "ImGuiContext", [t| ImGuiContext |])
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user