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

Regarding SetWindowSize #3

Open
ghost opened this issue Oct 19, 2012 · 4 comments
Open

Regarding SetWindowSize #3

ghost opened this issue Oct 19, 2012 · 4 comments

Comments

@ghost
Copy link

ghost commented Oct 19, 2012

I noticed the following in SetWindowSize in gltest.go.

// Need to wait for the reshape event, otherwise it happens at an arbitrary
// point in the future (some unknown number of SwapBuffers())
//glfw.PollEvents() // Doesn't work
//glfw.WaitEvents() // might be racy (ideally, we'd need to send an event)

Have you tried calling glfw.Disable(glfw.AutoPollEvents) during setup?
By default, glfw implicitely calls PollEvents when you call SwapBuffers. By disabling AutoPollEvents, you get manual control over your calls to PollEvents.

@pwaller
Copy link
Member

pwaller commented Oct 19, 2012

I don't think that will help. The problem is that when you run SetWindowSize, I'm guessing Reshape doesn't get called until the WM notification that there was a resize comes through to glfw. So when doing WaitEvents() if there was any non-resize event that happens to be waiting in the pipeline, SwapBuffers() or PollEvents() (or anything else) might not call Reshape. Hence what I settled on: Sleep (hopefully long enough for the WM to kick in) followed by SwapBuffers (which I've verified then calls Reshape() as I expect). What might be better is if there was a way to trigger the resize, then another event which we can reliably wait for, such as a mouse move event at a specific pixel, or something along those lines (preferably something that wouldn't happen by accident..)

@ghost
Copy link
Author

ghost commented Oct 20, 2012

If I understand you correctly, the purpose of that function is to force a resize and then pause execution of the test/example until the resize has actually propagated to the reshape function?

@pwaller
Copy link
Member

pwaller commented Oct 20, 2012

Exactly. I don't know of a non-complicated, 100% reliable way to do that. I imagine waiting 10ms will get pretty damn close, though, without impacting execution time significantly. If you can think of other non-racy ways to do it I would love to know.

@ghost
Copy link
Author

ghost commented Oct 20, 2012

I'll give it some thought.

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

No branches or pull requests

1 participant