Skip to content

Commit

Permalink
V2.2.0 (#189)
Browse files Browse the repository at this point in the history
* Upgrade upstream and prepare 2.2.0
* Update vulkan example
  • Loading branch information
dpwiz authored Sep 10, 2023
1 parent eec8b57 commit bab4d76
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 35 deletions.
10 changes: 10 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog for dear-imgui

## [2.2.0]

- `imgui` updated to [1.89.9].
- Update bounds for ghc-9.6.
- Exposed `DearImGui.Raw.Context`.
- Added `getCursorPos``.
- Fix TabItem flags type.

## [2.1.3]

- Fixed off-by-1 in internal Text wrapper.
Expand Down Expand Up @@ -107,7 +115,9 @@ Initial Hackage release based on [1.83].
[2.1.1]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.1.1
[2.1.2]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.1.2
[2.1.3]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.1.3
[2.2.0]: https://github.com/haskell-game/dear-imgui.hs/tree/v2.2.0

[1.89.9]: https://github.com/ocornut/imgui/releases/tag/v1.89.9
[1.87]: https://github.com/ocornut/imgui/releases/tag/v1.87
[1.86]: https://github.com/ocornut/imgui/releases/tag/v1.86
[1.85]: https://github.com/ocornut/imgui/releases/tag/v1.85
Expand Down
22 changes: 11 additions & 11 deletions dear-imgui.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.0

name: dear-imgui
version: 2.1.3
version: 2.2.0
author: Oliver Charles
maintainer: ollie@ocharles.org.uk, aenor.realm@gmail.com
license: BSD-3-Clause
Expand Down Expand Up @@ -370,25 +370,25 @@ executable vulkan
build-depends:
dear-imgui
, bytestring
>= 0.10.10.0 && < 0.12
>= 0.10.10.0 && < 0.13
, containers
^>= 0.6.2.1
>= 0.6.2.1 && < 0.7
, logging-effect
^>= 1.3.12
>= 1.3.12 && < 1.5
, resourcet
^>= 1.2.4.2
>= 1.2.4.2 && < 1.3
, sdl2
^>= 2.5.3.0
, text-short
^>= 0.1.3
>= 2.5.3.0 && < 2.6
, text
>= 1.2.4 && < 2.1
, transformers
>= 0.5.6 && < 0.7
, unliftio
>= 0.2.13 && < 0.2.19
>= 0.2.13 && < 0.3
, unliftio-core
^>= 0.2.0.1
>= 0.2.0.1 && < 0.3
, vector
^>= 0.12.1.2
>= 0.12.1.2 && < 0.14
, vulkan
>= 3.12
, vulkan-utils
Expand Down
41 changes: 18 additions & 23 deletions examples/vulkan/Backend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import Data.Traversable
import Data.Word
( Word32 )
import Foreign.C.String
( CString )
( peekCString )
import Foreign.C.Types
( CInt )
import Foreign.Ptr
Expand All @@ -53,8 +53,6 @@ import Foreign.Ptr
-- bytestring
import Data.ByteString
( ByteString )
import qualified Data.ByteString.Short as ShortByteString
( packCString )

-- containers
import qualified Data.Map.Strict as Map
Expand All @@ -77,11 +75,13 @@ import qualified SDL
import qualified SDL.Raw
import qualified SDL.Video.Vulkan

-- text-short
import Data.Text.Short
( ShortText )
import qualified Data.Text.Short as ShortText
( intercalate, pack, fromShortByteString, toByteString, unpack )
-- text
import Data.Text
( Text )
import qualified Data.Text as Text
( intercalate, pack, unpack )
import Data.Text.Encoding
( encodeUtf8 )

-- transformers
import Control.Monad.IO.Class
Expand Down Expand Up @@ -118,7 +118,7 @@ import Attachments

--------------------------------------------------------------------------------

type LogMessage = WithSeverity ShortText
type LogMessage = WithSeverity Text
class ( MonadUnliftIO m, MonadResource m, MonadLog LogMessage m ) => MonadVulkan m
instance ( MonadUnliftIO m, MonadResource m, MonadLog LogMessage m ) => MonadVulkan m

Expand All @@ -127,9 +127,9 @@ instance ( MonadUnliftIO m, MonadResource m, MonadLog LogMessage m ) => MonadVul

logHandler :: MonadIO m => LogMessage -> m ()
logHandler ( WithSeverity sev mess )
= liftIO . putStrLn . ShortText.unpack $ showSeverity sev <> " " <> mess
= liftIO . putStrLn . Text.unpack $ showSeverity sev <> " " <> mess

showSeverity :: Severity -> ShortText
showSeverity :: Severity -> Text
showSeverity Emergency = "! PANIC !"
showSeverity Alert = "! ALERT !"
showSeverity Critical = "! CRIT !"
Expand Down Expand Up @@ -244,7 +244,7 @@ vulkanInstanceInfo appName = do

case validationLayer of
Nothing -> logInfo "Validation layer unavailable. Is the Vulkan SDK installed?"
Just _ -> logInfo ( "Enabled validation layers " <> ShortText.pack ( show enabledLayers ) )
Just _ -> logInfo ( "Enabled validation layers " <> Text.pack ( show enabledLayers ) )

pure createInfo

Expand Down Expand Up @@ -305,26 +305,23 @@ initialiseWindow ( WindowInfo { height, width, windowName, mouseMode } ) = do
void ( SDL.setMouseLocationMode mouseMode )
window <- logDebug "Creating SDL window" *> createWindow width height windowName
neededExtensions <- logDebug "Loading needed extensions" *> SDL.Video.Vulkan.vkGetInstanceExtensions window
extensionNames <- traverse ( liftIO . peekCString ) neededExtensions
logInfo $ "Needed instance extensions are: " <> ShortText.intercalate ", " extensionNames
pure ( window, map ShortText.toByteString extensionNames )

peekCString :: CString -> IO ShortText
peekCString = fmap ( fromMaybe "???" . ShortText.fromShortByteString ) . ShortByteString.packCString
extensionNames <- traverse ( liftIO . fmap fromString . peekCString ) neededExtensions
logInfo $ "Needed instance extensions are: " <> Text.intercalate ", " extensionNames
pure ( window, map encodeUtf8 extensionNames )

data WindowInfo
= WindowInfo
{ width :: CInt
, height :: CInt
, windowName :: ShortText
, windowName :: Text
, mouseMode :: SDL.LocationMode
}

createWindow :: MonadVulkan m => CInt -> CInt -> ShortText -> m SDL.Window
createWindow :: MonadVulkan m => CInt -> CInt -> Text -> m SDL.Window
createWindow x y title =
snd <$> ResourceT.allocate
( SDL.createWindow
( fromString ( ShortText.unpack title ) )
( fromString ( Text.unpack title ) )
SDL.defaultWindow
{ SDL.windowGraphicsContext = SDL.VulkanContext
, SDL.windowInitialSize = SDL.V2 x y
Expand Down Expand Up @@ -404,8 +401,6 @@ createSwapchain physicalDevice device surface surfaceFormat imageUsage imageCoun

surfaceCapabilities <- Vulkan.getPhysicalDeviceSurfaceCapabilitiesKHR physicalDevice ( Vulkan.SurfaceKHR surface )

( _, presentModes ) <- Vulkan.getPhysicalDeviceSurfacePresentModesKHR physicalDevice ( Vulkan.SurfaceKHR surface )

let
presentMode :: Vulkan.PresentModeKHR
presentMode =
Expand Down
2 changes: 1 addition & 1 deletion imgui
Submodule imgui updated 61 files
+2 −2 .github/workflows/build.yml
+1 −2 .gitignore
+7 −2 backends/imgui_impl_allegro5.cpp
+3 −0 backends/imgui_impl_allegro5.h
+5 −0 backends/imgui_impl_android.cpp
+4 −0 backends/imgui_impl_android.h
+5 −0 backends/imgui_impl_dx10.cpp
+4 −1 backends/imgui_impl_dx10.h
+5 −0 backends/imgui_impl_dx11.cpp
+4 −1 backends/imgui_impl_dx11.h
+5 −0 backends/imgui_impl_dx12.cpp
+3 −0 backends/imgui_impl_dx12.h
+5 −0 backends/imgui_impl_dx9.cpp
+4 −1 backends/imgui_impl_dx9.h
+7 −10 backends/imgui_impl_glfw.cpp
+3 −0 backends/imgui_impl_glfw.h
+5 −0 backends/imgui_impl_glut.cpp
+4 −1 backends/imgui_impl_glut.h
+6 −1 backends/imgui_impl_metal.h
+5 −0 backends/imgui_impl_metal.mm
+5 −4 backends/imgui_impl_opengl2.cpp
+4 −1 backends/imgui_impl_opengl2.h
+5 −4 backends/imgui_impl_opengl3.cpp
+3 −0 backends/imgui_impl_opengl3.h
+3 −0 backends/imgui_impl_osx.h
+5 −0 backends/imgui_impl_osx.mm
+10 −0 backends/imgui_impl_sdl2.cpp
+4 −0 backends/imgui_impl_sdl2.h
+9 −0 backends/imgui_impl_sdl3.cpp
+4 −0 backends/imgui_impl_sdl3.h
+5 −4 backends/imgui_impl_sdlrenderer2.cpp
+3 −0 backends/imgui_impl_sdlrenderer2.h
+5 −4 backends/imgui_impl_sdlrenderer3.cpp
+3 −0 backends/imgui_impl_sdlrenderer3.h
+6 −0 backends/imgui_impl_vulkan.cpp
+2 −0 backends/imgui_impl_vulkan.h
+8 −2 backends/imgui_impl_wgpu.cpp
+4 −0 backends/imgui_impl_wgpu.h
+3 −0 backends/imgui_impl_win32.cpp
+3 −0 backends/imgui_impl_win32.h
+1 −1 docs/BACKENDS.md
+140 −10 docs/CHANGELOG.txt
+12 −11 docs/CONTRIBUTING.md
+6 −34 docs/FAQ.md
+120 −104 docs/FONTS.md
+7 −3 docs/README.md
+13 −10 examples/example_emscripten_wgpu/main.cpp
+4 −12 examples/example_glfw_vulkan/main.cpp
+4 −12 examples/example_sdl2_vulkan/main.cpp
+15 −8 imconfig.h
+299 −275 imgui.cpp
+47 −33 imgui.h
+278 −151 imgui_demo.cpp
+81 −27 imgui_draw.cpp
+46 −28 imgui_internal.h
+52 −16 imgui_tables.cpp
+81 −60 imgui_widgets.cpp
+10 −0 misc/cpp/imgui_stdlib.cpp
+8 −1 misc/freetype/README.md
+147 −2 misc/freetype/imgui_freetype.cpp
+3 −1 misc/freetype/imgui_freetype.h

0 comments on commit bab4d76

Please sign in to comment.