-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Examples: add Gtk3/OpenGL3 example #2032
Conversation
95015b8
to
dd14b50
Compare
@djdeath Thanks for the PR. Some quick comments:
|
dd14b50
to
5dcc8f9
Compare
Thanks @ocornut, updated, hopefully I didn't miss anything. Your comment about GDK_key_ enum made me realize I could things a bit differently so you can call ImGui::IsKeyPressed(GDK_key_a); for example. |
@ocornut What do you think about this? It works perfectly on my Ubuntu 16.04 machine. |
I mentioned that gtk3 has enabled vsync by default (the Framerate is around 60fps, which is good but uncontrollable. The vsync provided by glfw doesn't work on my machine, making the glfw example becomes about 3000fps and it's extremely CPU-consuming, so I made my own fps locker to control the fps by sleeping the main thread and disabled the default vsync functionality.). Is there a way to disable vsync in your implementation? |
I have to admit, I don't pay too much attention to the vsync. Though one thing I really like, is to not have the application drain 100% of the CPU. Hopefully that's kind of what you're after. |
Thanks for your help. This implementation is already very efficient afaik, thanks again. |
@djdeath I have a minor suggestion: Omar is working on the viewport branch of imgui which requires additional functionality of native backend. Could you please take a look at that branch? You can refer to imgui_impl_glfw.h and imgui_impl_glfw.cpp. But as the comment in imgui_impl_glfw.cpp said, it's optional. |
Yeah, I'll give it a try. Not sure all window manager will handle this right though... |
I gave a try to the GLFW example on the viewport under Gnome (wayland) and it doesn't work so well. I've also wrote the backend viewport code for Gtk+. Unfortunately GtkGLArea uses a GL context per widget and that just doesn't work well with the current OpenGL3 implementation that creates shaders and wants to use them with any viewport. |
Does the SDL one have the same issue? |
It's not as bad, but still pretty jumpy. |
@djdeath
This part you haven't mentioned in #1542 but if the most important thing I'd hope to get details (gif/video) and support on, if you can help ;) Getting the GLFW back-end to work properly on all OS is paramount to the success of mult-viewport.
One problem is that even if imgui_impl_opengl3.cpp handled this, it means that custom textures would be unusable across GL contexts. For now I would prefer to say it is out of scope. At this point the choice to make is
Consider this is only to support an hypothetical use case (mr ice1000 is the one who burdened you with a suggestion but it's not like we have any users who came looking for a multi-viewport compliant GTK+GL back-end? Do we?). Considering that, from my point of view I would always prefer the choice with less maintenance.. If there are indeed GTK+GL users who wants multi-viewport (without textures) then it's possibly to easily maintain a copy of imgui_impl_opengl3.cpp that does that. |
@djdeath An update of the Makefile script is needed due to a recent refactoring of imgui code base: EXE = example_gtk3_opengl3
SOURCES = main.cpp
SOURCES += ../imgui_impl_gtk3.cpp ../imgui_impl_opengl3.cpp
-SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp
+SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp
SOURCES += ../libs/gl3w/GL/gl3w.c
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) |
@djdeath Your |
5dcc8f9
to
d7915a2
Compare
Updated with Makefile change for imgui_widgets.cpp & gl3wInit fix. |
8b83e0a
to
d735066
Compare
b3b85d8
to
0755767
Compare
c817acb
to
8d39063
Compare
I'll close this with some comments:
If your or someone else is using this I reckon it should be pretty easy to update. In the absence of a standalone repo, the update could be posted here for reference. |
I've been using different flavors of Gtk3 bindings on Desktop/Linux so that I can have some level of integration with the window manager (i.e client side decoration on Wayland, retina displays, etc...).
I figured somebody might want to reuse that, so here is a PR that reuses the existing OpenGL3 rendering implementation and just sets up the window system through GTK+.
The makefile only supports Linux but I'm pretty sure someone could add support for MacOS/Windows in a few lines (unfortunately I don't have such systems).