mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2025-07-06 04:58:48 +02:00
Added image wrapper (#74)
Raw.image and sdl2/gl example "image" Wrappers should be backend-specific due to different handling of `userTextureIDPtr`.
This commit is contained in:
@ -105,6 +105,7 @@ module DearImGui.Raw
|
||||
, smallButton
|
||||
, invisibleButton
|
||||
, arrowButton
|
||||
, image
|
||||
, checkbox
|
||||
, progressBar
|
||||
, bullet
|
||||
@ -558,6 +559,31 @@ arrowButton strIdPtr dir = liftIO do
|
||||
(0 /=) <$> [C.exp| bool { ArrowButton($(char* strIdPtr), $(ImGuiDir dir)) } |]
|
||||
|
||||
|
||||
-- | Image Area to draw a texture
|
||||
--
|
||||
-- Wraps @ImGui::Image()
|
||||
--
|
||||
-- For OpenGL: The userTextureIDPtr points to the texture memory (eg. 0x0x0000000000000001), it is the number from glBindTexture.
|
||||
-- Eg:
|
||||
-- glBindTexture GL_TEXTURE_2D $ textureID texture
|
||||
-- -- fill textureID
|
||||
-- image (intPtrToPtr $ fromIntegral textureID) (ImVec2 500 500)(ImVec2 0 0)(ImVec2 1 1)(ImVec4 1 1 1 1)(ImVec4 0 0 0 0)
|
||||
--
|
||||
-- See https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples#About-texture-coordinates and under examples/sdl/Image.hs
|
||||
image :: (MonadIO m) => Ptr ()-> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec2 -> Ptr ImVec4 -> Ptr ImVec4 -> m()
|
||||
image userTextureIDPtr sizePtr uv0Ptr uv1Ptr tintColPtr borderColPtr = liftIO do
|
||||
[C.exp| void {
|
||||
Image(
|
||||
$(void* userTextureIDPtr),
|
||||
*$(ImVec2* sizePtr),
|
||||
*$(ImVec2* uv0Ptr),
|
||||
*$(ImVec2* uv1Ptr),
|
||||
*$(ImVec4* tintColPtr),
|
||||
*$(ImVec4* borderColPtr)
|
||||
)
|
||||
} |]
|
||||
|
||||
|
||||
-- | Wraps @ImGui::Checkbox()@.
|
||||
checkbox :: (MonadIO m) => CString -> Ptr CBool -> m Bool
|
||||
checkbox labelPtr boolPtr = liftIO do
|
||||
|
Reference in New Issue
Block a user