From eedfbbe2728335582c0d954a7c9eaac4fabbf217 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Sat, 5 Nov 2022 13:58:49 +0000 Subject: [PATCH 1/2] Use dear-imgui >= 2.0 text api This change enables building the fir-examples with the latest dear-imgui. --- .../apps/FIR/Examples/Toy/Application.hs | 5 ++++- .../shaders/FIR/Examples/Toy/Shaders.hs | 1 + fir-examples/fir-examples.cabal | 4 +++- fir-examples/src/FIR/Examples/DearImGui.hs | 19 +++++++++++-------- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/fir-examples/examples/apps/FIR/Examples/Toy/Application.hs b/fir-examples/examples/apps/FIR/Examples/Toy/Application.hs index 60f2c14..6788238 100644 --- a/fir-examples/examples/apps/FIR/Examples/Toy/Application.hs +++ b/fir-examples/examples/apps/FIR/Examples/Toy/Application.hs @@ -45,6 +45,9 @@ import Foreign.C.Types import Data.IORef ( IORef, newIORef, readIORef, writeIORef) +-- text +import qualified Data.Text as Text + -- dear-imgui import qualified DearImGui as ImGui import qualified DearImGui.Vulkan as ImGui.Vulkan @@ -787,7 +790,7 @@ toy = runVulkan (ToyRenderState nullInput nullInput) do began <- ImGui.begin "Shader toy!" when began do -- TODO: hide fps when isPaused - ImGui.text $ "FPS: " <> show fps + ImGui.text $ "FPS: " <> Text.pack (show fps) -- TODO: enable pause button with https://gitlab.com/sheaf/fir/-/merge_requests/21 -- ImGui.button (if isPaused then "Play" else "Pause") >>= \case -- False -> return () diff --git a/fir-examples/examples/shaders/FIR/Examples/Toy/Shaders.hs b/fir-examples/examples/shaders/FIR/Examples/Toy/Shaders.hs index 956878b..901941a 100644 --- a/fir-examples/examples/shaders/FIR/Examples/Toy/Shaders.hs +++ b/fir-examples/examples/shaders/FIR/Examples/Toy/Shaders.hs @@ -5,6 +5,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE OverloadedLabels #-} +{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RebindableSyntax #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneKindSignatures #-} diff --git a/fir-examples/fir-examples.cabal b/fir-examples/fir-examples.cabal index 84cf259..000f599 100644 --- a/fir-examples/fir-examples.cabal +++ b/fir-examples/fir-examples.cabal @@ -200,8 +200,9 @@ library fir-examples-dear-imgui build-depends: fir + , text , dear-imgui - >= 1.2 && < 2.2 + >= 2.0 && < 2.2 ---------------------------------------------------------------- -- Examples. @@ -553,4 +554,5 @@ executable Toy build-depends: fir-examples-dear-imgui , toy-shaders + , text , dear-imgui diff --git a/fir-examples/src/FIR/Examples/DearImGui.hs b/fir-examples/src/FIR/Examples/DearImGui.hs index 4eb9300..460bee9 100644 --- a/fir-examples/src/FIR/Examples/DearImGui.hs +++ b/fir-examples/src/FIR/Examples/DearImGui.hs @@ -21,6 +21,9 @@ import Data.Kind import GHC.TypeLits ( Symbol ) +-- text +import Data.Text (Text) + -- dear-imgui import qualified DearImGui @@ -40,7 +43,7 @@ data Controller range dyn where DiscreteSlider :: Controller (Int, Int) Int32 Toggle :: Controller () Int32 -createController :: MonadIO m => String -> Controller range dyn -> range -> IORef dyn -> m () +createController :: MonadIO m => Text -> Controller range dyn -> range -> IORef dyn -> m () createController controllerName controllerType range ref = case controllerType of Slider -> @@ -80,9 +83,9 @@ data ControllerRef = InitValue | Ref | Value type ControllerData :: ControllerRef -> Type -> Type -> Type type family ControllerData ref range dyn where -- | (name, controller, range, initial value) - ControllerData 'InitValue range dyn = ( String, Controller range dyn, range, dyn ) + ControllerData 'InitValue range dyn = ( Text, Controller range dyn, range, dyn ) -- | (name, controller, range, ref value) - ControllerData 'Ref range dyn = ( String, Controller range dyn, range, IORef dyn ) + ControllerData 'Ref range dyn = ( Text, Controller range dyn, range, IORef dyn ) -- | the value ControllerData 'Value _ dyn = dyn @@ -94,7 +97,7 @@ instance ControllerInitValues '[] '[] where controllerInitValues _ = End instance ( ControllerInitValues as bs , k1 ~ k2 - , v ~ ( String, Controller range dyn, range, dyn ) + , v ~ ( Text, Controller range dyn, range, dyn ) , r ~ dyn ) => ControllerInitValues ( ( k1 ':-> v ) ': as ) ( ( k2 ':-> r ) ': bs ) @@ -112,8 +115,8 @@ instance CreateControllerRefs '[] '[] where createControllerRefs _ = pure End instance ( CreateControllerRefs as bs , k1 ~ k2 - , v ~ ( String, Controller range dyn, range, dyn ) - , r ~ ( String, Controller range dyn, range, IORef dyn ) + , v ~ ( Text, Controller range dyn, range, dyn ) + , r ~ ( Text, Controller range dyn, range, IORef dyn ) ) => CreateControllerRefs ( ( k1 ':-> v ) ': as ) ( ( k2 ':-> r ) ': bs ) where @@ -129,7 +132,7 @@ class CreateControllers as where instance CreateControllers '[] where createControllers _ = pure () instance ( CreateControllers as - , r ~ ( String, Controller range dyn, range, IORef dyn ) + , r ~ ( Text, Controller range dyn, range, IORef dyn ) ) => CreateControllers ( ( k ':-> r ) ': as ) where @@ -144,7 +147,7 @@ instance ReadControllers '[] '[] where readControllers _ = pure End instance ( ReadControllers as bs , k1 ~ k2 - , r ~ ( String, Controller range dyn, range, IORef dyn ) + , r ~ ( Text, Controller range dyn, range, IORef dyn ) , b ~ dyn ) => ReadControllers ( ( k1 ':-> r ) ': as ) ( ( k2 ':-> b ) ': bs ) -- GitLab From e1a0d449caa25376c4f533bb3ef27508fc16d64f Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Sat, 5 Nov 2022 13:59:37 +0000 Subject: [PATCH 2/2] Allow vulkan 3.23 for the examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change fix this build failure: src/Vulkan/Pipeline.hs:376:13: error: Not in scope: ‘Vulkan.attachmentCount’ Perhaps you meant one of these: ‘Vulkan.attachment’ (imported from Vulkan), ‘Vulkan.attachment’ (imported from Vulkan), ‘Vulkan.attachments’ (imported from Vulkan) Neither ‘Vulkan’, ‘Vulkan.CStruct.Extends’, ‘Vulkan.Core10.Pipeline’ nor ‘Vulkan.Zero’ exports ‘attachmentCount’. | 376 | , Vulkan.attachmentCount = 1 | ^^^^^^^^^^^^^^^^^^^^^^ --- fir-examples/fir-examples.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fir-examples/fir-examples.cabal b/fir-examples/fir-examples.cabal index 000f599..f124c19 100644 --- a/fir-examples/fir-examples.cabal +++ b/fir-examples/fir-examples.cabal @@ -78,7 +78,7 @@ common vulkan-common , transformers ^>= 0.5.6.2 , vulkan - >= 3.17 && < 3.18 + >= 3.17 && < 3.24 common apps-common -- GitLab