2021-01-24 18:25:40 +00:00
|
|
|
{-# LANGUAGE BlockArguments #-}
|
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
|
|
{-# LANGUAGE NamedFieldPuns #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
{-# LANGUAGE PatternSynonyms #-}
|
|
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
|
|
|
|
{-|
|
|
|
|
Module: DearImGui.OpenGL
|
|
|
|
|
2021-02-06 14:44:58 +00:00
|
|
|
OpenGL 2 backend for Dear ImGui.
|
2021-01-24 18:25:40 +00:00
|
|
|
-}
|
|
|
|
|
2021-02-06 14:44:58 +00:00
|
|
|
module DearImGui.OpenGL2
|
2021-01-24 18:25:40 +00:00
|
|
|
( openGL2Init
|
|
|
|
, openGL2Shutdown
|
|
|
|
, openGL2NewFrame
|
|
|
|
, openGL2RenderDrawData
|
|
|
|
)
|
|
|
|
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 )
|
|
|
|
|
|
|
|
-- DearImGui
|
|
|
|
import DearImGui
|
|
|
|
( DrawData(..) )
|
|
|
|
|
|
|
|
|
|
|
|
C.context (Cpp.cppCtx <> C.bsCtx)
|
|
|
|
C.include "imgui.h"
|
|
|
|
C.include "backends/imgui_impl_opengl2.h"
|
|
|
|
Cpp.using "namespace ImGui"
|
|
|
|
|
|
|
|
|
|
|
|
-- | Wraps @ImGui_ImplOpenGL2_Init@.
|
2021-01-26 11:35:09 +00:00
|
|
|
openGL2Init :: MonadIO m => m Bool
|
2021-01-24 18:25:40 +00:00
|
|
|
openGL2Init = liftIO do
|
2021-01-26 11:35:09 +00:00
|
|
|
( 0 /= ) <$> [C.exp| bool { ImGui_ImplOpenGL2_Init() } |]
|
2021-01-24 18:25:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- | Wraps @ImGui_ImplOpenGL2_Shutdown@.
|
|
|
|
openGL2Shutdown :: MonadIO m => m ()
|
|
|
|
openGL2Shutdown = liftIO do
|
|
|
|
[C.exp| void { ImGui_ImplOpenGL2_Shutdown(); } |]
|
|
|
|
|
|
|
|
|
|
|
|
-- | Wraps @ImGui_ImplOpenGL2_NewFrame@.
|
|
|
|
openGL2NewFrame :: MonadIO m => m ()
|
|
|
|
openGL2NewFrame = liftIO do
|
|
|
|
[C.exp| void { ImGui_ImplOpenGL2_NewFrame(); } |]
|
|
|
|
|
|
|
|
|
|
|
|
-- | Wraps @ImGui_ImplOpenGL2_RenderDrawData@.
|
|
|
|
openGL2RenderDrawData :: MonadIO m => DrawData -> m ()
|
|
|
|
openGL2RenderDrawData (DrawData ptr) = liftIO do
|
|
|
|
[C.exp| void { ImGui_ImplOpenGL2_RenderDrawData((ImDrawData*) $( void* ptr )) } |]
|