-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add texture drawing example [help needed] #2
base: main
Are you sure you want to change the base?
Conversation
Thanks for diving into this! I haven't used gtk4-glium myself extensively, so I never got around to figuring out texturing. My free time is limited, so I can't promise working on this, but I'd definitely welcome a solution and push a new release to crates.io. |
Ok! I'm not actively debugging this right now. I kind of gave up since I found no pointers as to what was wrong, and I have not found anyone with expertise in the area to ask. I'm currently exploring reworking my app in a different UI framework instead 😂 But if I find a solution I'll surely post it here! |
No worries, it's all volunteer work here! 😃 |
I don't know exactly how or why, but I got it working when I introduced a second dummy texture! https://github.com/remcokranenburg/gtk4-glium/tree/add-texture-drawing-example |
I've tried several combinations of the same and different textures, in different orders. I can't quite figure out the pattern here. It seems like one texture needs to be loaded into a place so that the next one gets loaded correctly to draw with. |
Did you push the working version to that branch? Because I checked it out now, and I still just have a black frame 🤔 EDIT: I'm trying out 7a6ab22 |
An indication that something is awfully wrong, is what happens if I change all the
My diff
I have this exact behavior both in debug builds and release builds on two different Fedora machines running Sway (Wayland). |
Yes there must be going something wrong with the accounting of texture memory. I'm suspecting that some textures are secretly already loaded in from GTK side, but Glium doesn't know, so it allocates the same GPU memory again. Or the other way around. I'll try to do some more debugging soon. |
Haha. Wow, OpenGL global state 🤯 Interesting. At least you are on to something here! I'm not at all an OpenGL expert. I'll try to read up on the topic, but we'll see. I wish you good luck with debugging this! 💪 |
I was hoping it would then work to tell GTK to not render itself with OpenGL, but |
a7a8bd3
to
e4f3f3f
Compare
So, it works if I load the texture inside the |
This fixes the issue of colliding somewhere with GTK
e4f3f3f
to
5fb28ea
Compare
I spent a few moments this weekend exploring the problem and I think it's a mismatch of OpenGL state between Glium and GTK. I haven't tried it yet, but I think we need to print the current state before all of our drawing calls and once more after all of our drawing calls, then we'll probably see that Gtk messes with the texture IDs. It might be messing with more than just the textures. Then, the fix will be to either make Gtk stop messing with the OpenGL context, or to inform Glium of the changes. Glium maintains state so that it doesn't have to send a bunch of commands every frame, so it might be a bit of a performance issue if we just do a complete reset of OpenGL state every frame. Anyway, something to look for at least. |
Do you know how to draw textures with
glium
in agtk4
application? I completely fail doing so and I find no good examples of this being done online. So I thought I'd kill two birds with one stone by submitting an example. This example does not yet work. But if we can figure out what's wrong together and fix it, and merge it, then we have a working example for others to learn from.This example is an adaptation of
glium
's own texture drawing example. That example works! But I can't make the same texture loading + drawing code work in a gtk4 application.I have also asked the same question in the
gtk4-rs
repository. But I thought I can do the same here since this library is supposed to be a smooth overlap betweenglium
andgtk4
.