libglui / glui

GLUI is a GLUT-based C++ user interface library which provides controls such as buttons, checkboxes, radio buttons, and spinners to OpenGL applications. It is window-system independent, using GLUT or FreeGLUT.
Other
194 stars 82 forks source link

Finding/fix: glutPostRedisplay inside mouse event workaround for Nvidia GLUT #103

Closed m-7761 closed 5 years ago

m-7761 commented 5 years ago

The Nvidia GLUT library zombifies subwindows when glutPostRedisplay is sent inside of mouse events. Or as near as I can tell.

It happens primarily with the deactivate_control and activate_control pattern that GLUI's events use. Plus, requesting redrawing is a common recourse inside of mouse events.

GLUI is built on a house of sand in GLUT.

Anyway, I determined this was the problem, and before trying to restructure things, what works is to wrap it in a glutTimerFunc so GLUT can schedule it.

Internally it must not simply flag the window like any sane implementation would.

This is the original GLUT going by its history of Mark Kilgard's working for Nvidia. I would use it as a benchmark instead of later GLUT replacements.

GLUI should probably try to completely wrap a basic subset of GLUT as a way to protect users from its failings. I don't know how much GLUT one needs to implement software, but to my mind it feels like all that's mainly involved is the callbacks.

nigels-com commented 5 years ago

Which particular Windows GLUT binary exhibits this, by the way?

There were some minor fixes that were done in the course of Cg runtime development, available here: https://developer.nvidia.com/cg-toolkit-download

I'm not sure if there are newer binary releases of GLUT, but the source is also available here: https://github.com/markkilgard/glut

Probably not a bug for GLUI to be concerned with unless it can't or won't be fixed in GLUT.

m-7761 commented 5 years ago

See subject line. It's from Cg. I forgot Mark's GLUT was open source. I don't know if it's the same as Nvidia's today. But that can help me to confirm some things as I am finishing up its emulation.

nigels-com commented 5 years ago

The reason I ask is that the last time I looked, there were a few different Windows binaries in circulation.

I'm not certain that the fixes made to the Cg GLUT binaries (back in the day) were up-streamed. If you do happen to notice that bugs fixed in Cg GLUT are still there in the github code, I'll ping Mark about that.

nigels-com commented 5 years ago

If you can clarify what you're referring to as "Nvidia GLUT", and where those source or binaries came from, it would be helpful. The history of GLUT goes back to SGI times, various people have modified it over the years. The Cg GLUT binaries were based on Mark's copy (as I recall) but there was some maintenance in the course of that also.

I don't tend to do much Windows development recently, and GLUT subwindows don't seem to me all that compelling, unless perhaps they're somehow advantageous for multi-threading.

The GLUI stance has generally been that GLUT bugs ought to be fixed in GLUT, rather than worked around in GLUI, unless absolutely necessary.

m-7761 commented 5 years ago

Mark was working for Nvidia if I'm not mistaken. Nvidia hosts Cg, and Nvidia was the source of the closed source binaries as far as I know, back when GLUT was in common use.

There is no strict definition of how GLUT operates. So code just has to be flexible, or else it has to declare allegiance to one particular implementation of GLUT.

I don't tend to do much Windows development recently, and GLUT subwindows don't seem to me all that compelling, unless perhaps they're somehow advantageous for multi-threading.

That's dandy for you, but code on GitHub is public code, and projects are ostensibly for the public. All software libraries are putting themselves out as building blocks. So if you feel like this, I would recommend stepping down as a maintainer, and hosting your pet version of GLUI on you home page.

nigels-com commented 5 years ago

I've already declined to step down. I'm inclined to close this issue as something that ought to be fixed elsewhere.

nigels-com commented 5 years ago

This issue seems to concern GLUT, but not the GLUI here. Closing.

m-7761 commented 5 years ago

This issue seems to concern GLUT, but not the GLUI here. Closing.

Uh? Which GLUT does GLUI endorse then???

nigels-com commented 5 years ago

The assertion here is that GLUT on Windows doesn't properly handle glutPostRedisplay for subwindows.

If so, in the first instance take a closer look at the GLUT internals to establish the specifics. If possible, fix GLUT handling of glutPostRedisplay for subwindows. Failing all of that I'd consider a Windows-specific workaround in GLUI.