mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2025-07-05 12:38:47 +02:00
Add support for GLFW (#26)
Co-authored-by: Oliver Charles <ollie@ocharles.org.uk>
This commit is contained in:
51
src/DearImGui/GLFW.hs
Normal file
51
src/DearImGui/GLFW.hs
Normal file
@ -0,0 +1,51 @@
|
||||
{-# LANGUAGE BlockArguments #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PatternSynonyms #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
{-|
|
||||
Module: DearImGui.GLFW
|
||||
|
||||
GLFW specific functions backend for Dear ImGui.
|
||||
|
||||
Modules for initialising a backend with GLFW can be found under the corresponding backend,
|
||||
e.g. "DearImGui.GLFW.OpenGL".
|
||||
-}
|
||||
|
||||
module DearImGui.GLFW (
|
||||
-- ** GLFW
|
||||
glfwNewFrame
|
||||
, glfwShutdown
|
||||
)
|
||||
where
|
||||
|
||||
-- inline-c
|
||||
import qualified Language.C.Inline as C
|
||||
|
||||
-- inline-c-cpp
|
||||
import qualified Language.C.Inline.Cpp as Cpp
|
||||
|
||||
-- transformers
|
||||
import Control.Monad.IO.Class
|
||||
( MonadIO, liftIO )
|
||||
|
||||
|
||||
C.context (Cpp.cppCtx <> C.bsCtx)
|
||||
C.include "imgui.h"
|
||||
C.include "backends/imgui_impl_glfw.h"
|
||||
Cpp.using "namespace ImGui"
|
||||
|
||||
|
||||
-- | Wraps @ImGui_ImplGlfw_NewFrame@.
|
||||
glfwNewFrame :: MonadIO m => m ()
|
||||
glfwNewFrame = liftIO do
|
||||
[C.exp| void { ImGui_ImplGlfw_NewFrame(); } |]
|
||||
|
||||
|
||||
-- | Wraps @ImGui_ImplGlfw_Shutdown@.
|
||||
glfwShutdown :: MonadIO m => m ()
|
||||
glfwShutdown = liftIO do
|
||||
[C.exp| void { ImGui_ImplGlfw_Shutdown(); } |]
|
Reference in New Issue
Block a user