Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImGui as a generic graphics API #530

Closed
javawag opened this issue Feb 16, 2016 · 7 comments
Closed

ImGui as a generic graphics API #530

javawag opened this issue Feb 16, 2016 · 7 comments

Comments

@javawag
Copy link

javawag commented Feb 16, 2016

Enhancement idea. Forgive me if this has been requested before!

The drawlist functionality of (dear) ImGui is really powerful - i.e. ImDrawList::Add* functions. I've actually thought about using ImGui as a basic renderer for prototyping stuff. All you'd need is access to the root window/desktop/background, and the ability to use a raw ImDrawList to draw your state (polys, circles, images, etc.).

Using this you could write games and even more bespoke UI systems.

Ever considered this? I'm thinking about forking and giving it a go myself, actually.

@ocornut
Copy link
Owner

ocornut commented Feb 16, 2016

I've been actually doing this and using ImDrawList as a base for some simple prototyping (using callbacks to change render states).

You can create a window with 0.0f alpha background and a few flags ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoFocusOnAppearing and you'll pretty much get an empty draw list to use. Use SetNextWindowSize/Pos to make the window fullscreen.
EDIT also add ImGuiWindowFlags_NoBringToFrontOnFocus

Alternatively you can also just create an ImDrawList and pass it to your renderer somehow.
Note that some functions such as the short version of AddText() actually use the ImGui state. Those are exceptions rather than the norm.

@javawag
Copy link
Author

javawag commented Feb 16, 2016

Nice - I tried a while back to "break out" of the window - didn't think of just making the window fullscreen and setting those style flags!

So really I guess it already supports this - though I think a more concise way of opening a fullscreen, invisible window as a canvas could be cool, like ImGui::BeginCanvas() or something - mainly for drawing overlays.

I imagine it's pretty easy to write a BeginCanvas function around the stuff you just mentioned in your comment so I'll try that out I think - feel free to close out if you feel that it's not something that should be added to core ImGui!

@ocornut
Copy link
Owner

ocornut commented Feb 16, 2016

Right now I don't feel anything is needed apart from a little more control over ordering/layering of windows.

Something like BeginCanvas() would make some sense but restricting it to "fullscreen" might be hiding too much of what's going on and the flexibility of doing it per window?

There's also GImGui->OverlayDrawList in imgui_internal.h which is the drawlist used for the mouse cursor and I sometimes use, thinking about exposing it in imgui.h as a convenience.

I suggest you play around with those techniques see if you feel additions are desirable.

@dkrikun
Copy link

dkrikun commented Feb 20, 2016

Could it be possible to have BeginCanvas() to start some generic OpenGL draw area?
I would like to have some "box" to draw stuff using this tool inside >>
https://github.com/glampert/debug-draw

@ocornut
Copy link
Owner

ocornut commented Feb 20, 2016

@dkrikun ImGui is render api agnostic.You can either render your OpenGL stuff in a texture and render that texture in your ImGui window, or add a callback via the ImDrawList api and rendernig your OpenGL stuff when the callback is called.

@dkrikun
Copy link

dkrikun commented Feb 20, 2016

It certainly is, what I meant is whether it could be possible to have some BeginCanvas()/EndCanvas() prepare that render-to-texture as a convenience, so that one could jump and do his custom rendering.

@ocornut
Copy link
Owner

ocornut commented Feb 20, 2016

That render-to-texture wouldn't be a portable thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants