sebcrozet / kiss3d

Keep it simple, stupid 3d graphics engine for Rust.
http://kiss3d.org
BSD 3-Clause "New" or "Revised" License
1.49k stars 172 forks source link

Feasibility of implementing support for immediate mode GUIs like Nuklear or Imgui #193

Open nshcat opened 4 years ago

nshcat commented 4 years ago

Hello, before I begin my question I want to state that this is not a feature request - I want to inquire whether what I am planning to do is at all feasible.

When prototyping graphical applications, immediate mode GUI libraries like imgui or nuklear often come in handy to me. These libraries are renderer agnostics, they just produce command lists that can be interpreted by any rendering system or library.

My question now is: Is it at all possible to gain access to the internals of the OpenGL state used by this library in order for me to implement rendering of these generated command lists, and therefore establish support for these GUI libraries? Is this worth getting into further?

Cheers

sebcrozet commented 4 years ago

Hi! It turns out we already support an immediate-mode GUI library: conrod. Its integration is implemented there.

Now if you want to do this from a crate separate form kiss3d, you can implemented it through a sruct that implements the Renderer trait.

Then to let the kiss3d window take your renderer into account you can return it by the cameras_and_effect_and_renderer method. You can see the persistent_point_cloud example for an example of setting-up a renderer. In particular, you can see that you can get low-level OpenGL access with the Context::get() method.