mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-11-22 08:56:59 +00:00
Fix warnings (#79)
This commit is contained in:
parent
5699f64e95
commit
f49e81c739
34
Main.hs
34
Main.hs
@ -41,20 +41,20 @@ main = do
|
|||||||
openGL3Shutdown
|
openGL3Shutdown
|
||||||
|
|
||||||
|
|
||||||
loop
|
loop
|
||||||
:: Window
|
:: Window
|
||||||
-> IORef Bool
|
-> IORef Bool
|
||||||
-> IORef ImVec3
|
-> IORef ImVec3
|
||||||
-> IORef (Float, Float, Float)
|
-> IORef (Float, Float, Float)
|
||||||
-> IORef Int
|
-> IORef Int
|
||||||
-> IORef ImVec2
|
|
||||||
-> IORef ImVec2
|
-> IORef ImVec2
|
||||||
-> IORef Int
|
-> IORef ImVec2
|
||||||
|
-> IORef Int
|
||||||
-> IORef Bool
|
-> IORef Bool
|
||||||
-> IORef Bool
|
-> IORef Bool
|
||||||
-> IO ()
|
-> IO ()
|
||||||
loop w checked color slider r pos size' selected tab1Ref tab2Ref = do
|
loop window checked color slider r pos size' selected tab1Ref tab2Ref = do
|
||||||
quit <- pollEvents
|
shouldQuit <- checkEvents
|
||||||
|
|
||||||
openGL3NewFrame
|
openGL3NewFrame
|
||||||
sdl2NewFrame
|
sdl2NewFrame
|
||||||
@ -68,7 +68,7 @@ loop w checked color slider r pos size' selected tab1Ref tab2Ref = do
|
|||||||
setNextWindowPos pos ImGuiCond_Once Nothing
|
setNextWindowPos pos ImGuiCond_Once Nothing
|
||||||
setNextWindowSize size' ImGuiCond_Once
|
setNextWindowSize size' ImGuiCond_Once
|
||||||
-- Works, but will make the window contents illegible without doing something more involved.
|
-- Works, but will make the window contents illegible without doing something more involved.
|
||||||
-- setNextWindowContentSize size'
|
-- setNextWindowContentSize size'
|
||||||
-- setNextWindowSizeConstraints size' size'
|
-- setNextWindowSizeConstraints size' size'
|
||||||
setNextWindowCollapsed False ImGuiCond_Once
|
setNextWindowCollapsed False ImGuiCond_Once
|
||||||
|
|
||||||
@ -164,13 +164,15 @@ loop w checked color slider r pos size' selected tab1Ref tab2Ref = do
|
|||||||
glClear GL_COLOR_BUFFER_BIT
|
glClear GL_COLOR_BUFFER_BIT
|
||||||
openGL3RenderDrawData =<< getDrawData
|
openGL3RenderDrawData =<< getDrawData
|
||||||
|
|
||||||
glSwapWindow w
|
glSwapWindow window
|
||||||
|
|
||||||
if quit then return () else loop w checked color slider r pos size' selected tab1Ref tab2Ref
|
if shouldQuit
|
||||||
|
then return ()
|
||||||
|
else loop window checked color slider r pos size' selected tab1Ref tab2Ref
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
pollEvents = do
|
checkEvents = do
|
||||||
ev <- pollEventWithImGui
|
ev <- pollEventWithImGui
|
||||||
|
|
||||||
case ev of
|
case ev of
|
||||||
@ -180,9 +182,9 @@ loop w checked color slider r pos size' selected tab1Ref tab2Ref = do
|
|||||||
QuitEvent -> True
|
QuitEvent -> True
|
||||||
_ -> False
|
_ -> False
|
||||||
|
|
||||||
(isQuit ||) <$> pollEvents
|
(isQuit ||) <$> checkEvents
|
||||||
|
|
||||||
|
|
||||||
whenTrue :: IO () -> Bool -> IO ()
|
whenTrue :: IO () -> Bool -> IO ()
|
||||||
whenTrue io True = io
|
whenTrue io True = io
|
||||||
whenTrue io False = return ()
|
whenTrue _io False = return ()
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
packages: *.cabal
|
packages: *.cabal
|
||||||
package dear-imgui
|
package dear-imgui
|
||||||
flags: +sdl2 +glfw +opengl2 +opengl3 +vulkan +examples
|
flags: +sdl2 +glfw +opengl2 +opengl3 +vulkan +examples
|
||||||
|
ghc-options: -Wall -Wcompat -fno-warn-unused-do-bind
|
||||||
|
@ -24,28 +24,28 @@ main = do
|
|||||||
|
|
||||||
runManaged do
|
runManaged do
|
||||||
-- Create a window using SDL. As we're using OpenGL, we need to enable OpenGL too.
|
-- Create a window using SDL. As we're using OpenGL, we need to enable OpenGL too.
|
||||||
w <- do
|
window <- do
|
||||||
let title = "Hello, Dear ImGui!"
|
let title = "Hello, Dear ImGui!"
|
||||||
let config = defaultWindow { windowGraphicsContext = OpenGLContext defaultOpenGL }
|
let config = defaultWindow { windowGraphicsContext = OpenGLContext defaultOpenGL }
|
||||||
managed $ bracket (createWindow title config) destroyWindow
|
managed $ bracket (createWindow title config) destroyWindow
|
||||||
|
|
||||||
-- Create an OpenGL context
|
-- Create an OpenGL context
|
||||||
glContext <- managed $ bracket (glCreateContext w) glDeleteContext
|
glContext <- managed $ bracket (glCreateContext window) glDeleteContext
|
||||||
|
|
||||||
-- Create an ImGui context
|
-- Create an ImGui context
|
||||||
_ <- managed $ bracket createContext destroyContext
|
_ <- managed $ bracket createContext destroyContext
|
||||||
|
|
||||||
-- Initialize ImGui's SDL2 backend
|
-- Initialize ImGui's SDL2 backend
|
||||||
_ <- managed_ $ bracket_ (sdl2InitForOpenGL w glContext) sdl2Shutdown
|
_ <- managed_ $ bracket_ (sdl2InitForOpenGL window glContext) sdl2Shutdown
|
||||||
|
|
||||||
-- Initialize ImGui's OpenGL backend
|
-- Initialize ImGui's OpenGL backend
|
||||||
_ <- managed_ $ bracket_ openGL2Init openGL2Shutdown
|
_ <- managed_ $ bracket_ openGL2Init openGL2Shutdown
|
||||||
|
|
||||||
liftIO $ mainLoop w
|
liftIO $ mainLoop window
|
||||||
|
|
||||||
|
|
||||||
mainLoop :: Window -> IO ()
|
mainLoop :: Window -> IO ()
|
||||||
mainLoop w = do
|
mainLoop window = do
|
||||||
-- Process the event loop
|
-- Process the event loop
|
||||||
untilNothingM pollEventWithImGui
|
untilNothingM pollEventWithImGui
|
||||||
|
|
||||||
@ -73,9 +73,9 @@ mainLoop w = do
|
|||||||
render
|
render
|
||||||
openGL2RenderDrawData =<< getDrawData
|
openGL2RenderDrawData =<< getDrawData
|
||||||
|
|
||||||
glSwapWindow w
|
glSwapWindow window
|
||||||
|
|
||||||
mainLoop w
|
mainLoop window
|
||||||
|
|
||||||
where
|
where
|
||||||
untilNothingM m = m >>= maybe (return ()) (\_ -> untilNothingM m)
|
untilNothingM m = m >>= maybe (return ()) (\_ -> untilNothingM m)
|
||||||
|
@ -370,7 +370,7 @@ app = do
|
|||||||
freeOldResources
|
freeOldResources
|
||||||
let
|
let
|
||||||
freeOldResources :: m ()
|
freeOldResources :: m ()
|
||||||
freeOldResources = pure ()
|
freeOldResources = pure ()
|
||||||
unless quit $ mainLoop ( AppState {..} )
|
unless quit $ mainLoop ( AppState {..} )
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -12,8 +12,6 @@ module DearImGui.Generator
|
|||||||
-- base
|
-- base
|
||||||
import Control.Arrow
|
import Control.Arrow
|
||||||
( second )
|
( second )
|
||||||
import Data.Coerce
|
|
||||||
( coerce )
|
|
||||||
import Data.Bits
|
import Data.Bits
|
||||||
( Bits )
|
( Bits )
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
@ -54,7 +52,6 @@ import qualified Language.Haskell.TH.Syntax as TH
|
|||||||
|
|
||||||
-- text
|
-- text
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
( isInfixOf, null, unpack, unlines )
|
|
||||||
import qualified Data.Text.IO as Text
|
import qualified Data.Text.IO as Text
|
||||||
( readFile )
|
( readFile )
|
||||||
|
|
||||||
@ -157,11 +154,11 @@ declareEnumeration finiteEnumName countName ( Enumeration {..} ) = do
|
|||||||
<$> TH.appT ( TH.conT countName ) ( TH.conT tyName )
|
<$> TH.appT ( TH.conT countName ) ( TH.conT tyName )
|
||||||
<*> TH.litT ( TH.numTyLit enumSize )
|
<*> TH.litT ( TH.numTyLit enumSize )
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
pure ( finiteEnumInst : )
|
pure ( finiteEnumInst : )
|
||||||
else pure id
|
else pure id
|
||||||
|
|
||||||
synonyms <- for patterns \ ( patternName, patternValue, CommentText patDoc ) -> do
|
synonyms <- for patterns \ ( patternName, patternValue, CommentText _patDoc ) -> do
|
||||||
let
|
let
|
||||||
patNameStr :: String
|
patNameStr :: String
|
||||||
patNameStr = Text.unpack patternName
|
patNameStr = Text.unpack patternName
|
||||||
@ -169,7 +166,7 @@ declareEnumeration finiteEnumName countName ( Enumeration {..} ) = do
|
|||||||
patSynSig <- TH.patSynSigD patName ( TH.conT tyName )
|
patSynSig <- TH.patSynSigD patName ( TH.conT tyName )
|
||||||
pat <-
|
pat <-
|
||||||
#if MIN_VERSION_template_haskell(2,18,0)
|
#if MIN_VERSION_template_haskell(2,18,0)
|
||||||
( if Text.null patDoc
|
( if Text.null _patDoc
|
||||||
then TH.patSynD
|
then TH.patSynD
|
||||||
else
|
else
|
||||||
\ nm args dir pat ->
|
\ nm args dir pat ->
|
||||||
|
Loading…
Reference in New Issue
Block a user