12.5 C
New York
Thursday, December 1, 2022

Slow update of GUI elements on window resize – GameDev.net

Please contact us if you have any trouble resetting your password.
Hello Gamedev!
I’m currently working on a project which utilize opengl to render a GUI.
Now when i’m resizing the window i want to resize the gui elements with it. But when i do all elements seem to lag behind. See video.
Why is this?

My framebuffer size callback:
And for example, a rounded rectangle looks like this:
Thanks for help,
Joakim Wennergren

None
joakim.wennergren@databeams.se said:
Why is this?
I’m speculating here a bit but based on the code you shared I would expect this behavior. Did you try putting the Window::Render call as the last call in your size callback? To me it looks like you are updating the camera last after you already rendered, and should be 1 frame at least behind. And does the rendering happen in it’s own thread? I’ve read that when you are using GLFW and not doing the rendering in it’s own thread it can cause slowdown/lag issues.
Here is a post with an adjecent problem and I think it will help, since the events from the message pump are not reliable enough to get smooth resizing. Basically you need to poll it in a loop. It’s better explained with a fix in this post: https://discourse.glfw.org/t/when-responses-to-window-refresh-take-too-long/1899/2
“It’s a cruel and random world, but the chaos is all so beautiful.”
― Hiromu Arakawa
@Ultraporing Thanks for your reply, Ultraporing.
Did you try putting the Window::Render call as the last call in your size callback?
Yes have tried this.

I’ve been messing around with the code and what i believe it boils down to is the resize events.
I have tried putting the resizing of elements in a seperate thread. Though this causes more problems. 🙂

I will look into that thread and see if i can pump the eventmessages somehow!
None
@joakim.wennergren@databeams.se
I think i solved it now.
I replaced glfwPollEvents with glfwWaitEvents().
and replaced my cameralogic and passed the window to the draw functions again!
Voilá:
None

source

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles