haskell-game / dear-imgui.hs

Haskell bindings to Dear ImGui, an immediate mode GUI toolkit
BSD 3-Clause "New" or "Revised" License
142 stars 31 forks source link

Added image wrapper #74

Closed jpwidera closed 3 years ago

jpwidera commented 3 years ago

Hi, I created an wrapper for the image function.

I'm not sure, if I should also provide a test-routine - I've tested it but did not clean the code for this yet. Maybe adding this to the examples would be test enough (It has it's own tutorial on the project page ?

Maybe you have an idea, how to improve the void-ptr-method in image :: (MonadIO m) => Ptr ()-> CFloat -> CFloat -> m())? * The Ptr() is a texture-ptr and has to be universal for (DirectX,) OpenGL, Vulkan and I have absolutely no clue, how these ptrs are represented in DirectX or Vulkan. For OpenGL it would be safe to pass an GLuint. My ideas for this:

  1. Create an universal texture-pointer that will be depend on the implementation
  2. Use compiler-directive aka #ifdef to enable function signatures for OpenGL/Vulkan. But I never did this before. Is it straight ahead as in C-likes?
  3. Leave it like it is

Cheers

Edit: ()The original Ptr() is described as: `typedef void ImTextureID; // User data for rendering backend to identify a texture. This is whatever to you want it to be! read the FAQ about ImTextureID for details.`

dpwiz commented 3 years ago

Do you have a minimal example project that's using this?

dpwiz commented 3 years ago

I'm pondering if backends should provide those image handles for the wrapped version...

jpwidera commented 3 years ago

Do you have a minimal example project that's using this?

Sure, I uploaded to examples/sdl/Image.hs.

I'm pondering if backends should provide those image handles for the wrapped version...

Do you mean the Image handler at all, adding these AddImage functions, or that the Image is calling Raw.Image?

jpwidera commented 3 years ago

Oh no, I added the imgui submodule. I have to find out, how to remove it from the branch - I'll check this in the next days. I'm quite busy at the moment. Cheers

ocharles commented 3 years ago

This looks worth bringing in to me. Shall we merge this, @dpwiz?

dpwiz commented 3 years ago

I somehow missed the recent activity. Definitely worth a merge.