-
Notifications
You must be signed in to change notification settings - Fork 80
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
Rotation texture ID is static/internal global variable. #98
Comments
https://www.opengl.org/resources/libraries/glut/spec3/node16.html says each GLUT window has its own context. https://www.opengl.org/resources/libraries/glut/spec3/node17.html says the same for subwindows. Going by this, GLUI's rotation texture will only work on the first window or subwindow that includes one, unless I'm missing something? |
It's typical to share contexts in multi-window scenarios, especially for the purpose of textures, buffers and display lists. |
Does GLUT control that? Or is it an option to provide to GLUT? Or is it implementation dependent? |
I looked and only found some claims that vanilla GLUT doesn't have any context sharing mechanisms. Below is the code I developed for the Rotation texture.
The constructor from glui.cpp follows. EDITED: I had to modify things to be able to get the size out of the exported function when initializing the
You get the idea. I don't know if it's possible to make a GLUI window that uses the same texture names as the user's drawing area. I've added a canvas feature though for drawing over the UI. But that's a different matter. Anyway, I used
|
EDITED: I edited this code twice. (I don't know how soon GitHub sends out email notifications.)
|
glGenTextures might be preferable for this. |
I don't think you're conceptualizing the problem correctly. The The purpose of GLUI is in sore need of a disciplinarian. At best it's raw material in its present state. I'm whipping it into something that sane people might find useful. Take it or leave it. |
So the problem you're aiming to solve is having more than one copy of the same texture for each OpenGL context? I don't recall if there is a GLUT wrapper for |
It's like TLS but for the UI objects. It's a simple system. I wouldn't make it any more complicated. A library has to have a strong sense of identity. That includes what it is, and what it is not. If more controls used textures it would be worthwhile to centralize their management, but I wouldn't likely export that framework to users... I'd leave them to implement their own if they are doing custom stuff with textures. For the record, I don't think GLUT is a multi-thread paradigm. It has one main-loop. So neither would GLUI ever be so. I did mention making the possibility of making it thread-safe, but that's just an afterthought I had to cleanup the function signature for posterity sake. The |
DELETED: I wrote from experience (GLUI Example #5) the contexts were leaking, so probably shared, but I realized glutSetWindow is basically changing contexts, and so I needed to use it to initialize my main OpenGL window. (I'm injecting the examples into an existing GLUT app for simplicity.) Seems obvious in hindsight. |
Scrollbar |
Yeah, storing the texture ID per Assuming that the lifetime of a GLUI_Rotation is limited to one OpenGL context.
|
I'm just filing this away here. I don't know how big of a problem this is. If GLUT spreads an OpenGL context over every window then it might be less of a problem. If not, it's a big problem, obviously.
A simple fix is stashing the texture ID in the top-level
GLUI
container, since that is per GLUT window, unless I'm wrong about that.But that would not be a solution that extends to other controls. I guess there would need to be a texture slot registration process to arrive at something extensible.
The text was updated successfully, but these errors were encountered: