mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2025-07-13 16:29:55 +02:00
Add image support for vulkan backend (#126)
This commit is contained in:
committed by
GitHub
parent
dc11fad07f
commit
af6ba9e989
@ -19,6 +19,8 @@ module DearImGui.Vulkan
|
||||
, vulkanCreateFontsTexture
|
||||
, vulkanDestroyFontUploadObjects
|
||||
, vulkanSetMinImageCount
|
||||
|
||||
, vulkanAddTexture
|
||||
)
|
||||
where
|
||||
|
||||
@ -32,7 +34,7 @@ import Foreign.Marshal.Alloc
|
||||
import Foreign.Ptr
|
||||
( FunPtr, Ptr, freeHaskellFunPtr, nullPtr )
|
||||
import Foreign.Storable
|
||||
( Storable(poke) )
|
||||
( poke )
|
||||
|
||||
-- inline-c
|
||||
import qualified Language.C.Inline as C
|
||||
@ -92,7 +94,7 @@ withVulkan initInfo renderPass action =
|
||||
( \ ( _, initResult ) -> action initResult )
|
||||
|
||||
-- | Wraps @ImGui_ImplVulkan_Init@.
|
||||
--
|
||||
--
|
||||
-- Use 'vulkanShutdown' to clean up on shutdown.
|
||||
-- Prefer using 'withVulkan' when possible, as it automatically handles cleanup.
|
||||
vulkanInit :: MonadIO m => InitInfo -> Vulkan.RenderPass -> m (FunPtr (Vulkan.Result -> IO ()), Bool)
|
||||
@ -184,3 +186,16 @@ vulkanDestroyFontUploadObjects = liftIO do
|
||||
vulkanSetMinImageCount :: MonadIO m => Word32 -> m ()
|
||||
vulkanSetMinImageCount minImageCount = liftIO do
|
||||
[C.exp| void { ImGui_ImplVulkan_SetMinImageCount($(uint32_t minImageCount)); } |]
|
||||
|
||||
-- | Wraps @ImGui_ImplVulkan_AddTexture@.
|
||||
vulkanAddTexture :: MonadIO m => Vulkan.Sampler -> Vulkan.ImageView -> Vulkan.ImageLayout -> m Vulkan.DescriptorSet
|
||||
vulkanAddTexture sampler imageView imageLayout = liftIO do
|
||||
[C.block|
|
||||
VkDescriptorSet {
|
||||
return ImGui_ImplVulkan_AddTexture(
|
||||
$(VkSampler sampler),
|
||||
$(VkImageView imageView),
|
||||
$(VkImageLayout imageLayout)
|
||||
);
|
||||
}
|
||||
|]
|
||||
|
@ -31,6 +31,10 @@ vulkanTypesTable = Map.fromList
|
||||
, ( C.TypeName "VkRenderPass" , [t| Vulkan.RenderPass |] )
|
||||
, ( C.TypeName "VkResult" , [t| Vulkan.Result |] )
|
||||
, ( C.TypeName "VkSampleCountFlagBits", [t| Vulkan.SampleCountFlagBits |] )
|
||||
, ( C.TypeName "VkSampler" , [t| Vulkan.Sampler |] )
|
||||
, ( C.TypeName "VkImageView" , [t| Vulkan.ImageView |] )
|
||||
, ( C.TypeName "VkImageLayout" , [t| Vulkan.ImageLayout |] )
|
||||
, ( C.TypeName "VkDescriptorSet" , [t| Vulkan.DescriptorSet |] )
|
||||
]
|
||||
|
||||
vulkanCtx :: C.Context
|
||||
|
Reference in New Issue
Block a user