djk's picture

Wgl access

What is the OpenTK way to access the wglsharelists function? I am looking to share displaylists accross several glcontext's.

djk

AttachmentSize
opentk-0.9.1-WIP3.7z599.7 KB
SelectionExample.zip112.53 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

There is a class called OpenTK.Platform.Windows.Wgl, but access was removed in 0.9.0 (if there is a need, I can re-enable it in 0.9.1). However, I am working on some updates in context creation for 0.9.1, among which is better handling of multiple contexts. It already is possible to share lists by constructing a GLContext with the GLContext.CreateContext(bool, GLContext) method, but I'd suggest waiting a couple of days for the update.

Edit: I will upload a WIP build with shared context support tonight (about 20:00 GMT).

djk's picture

Thanks, I know I am pushing things. The fast pace of OpenTK has re-ignited the drive to finish the graphics development branch of our own project.

the Fiddler's picture

No problem, actually ;) It happens that multiple OpenGL contexts have been a design goal from the beginning, so resource sharing is already supported internally; only the public API is missing.

Since you are the first to ask for this functionality, I'd appreciate some input on the API design. My current intention is to add a global toggle for context sharing: if GLContext.ShareContexts is true, any new context (e.g. through new GLControl()) will share resources with the rest. This option will be set to true by default, and toggling it will not affect existing contexts, only new ones. I think this covers about 99% of the common use cases (you either want context sharing, or you don't).

Do you think this is enough, or would you prefer to see more fine grained control (e.g. a GLControl constructor that specifies which GLContext to share).

Edit: Please, check the attached archive. It contains a WIP debug build of OpenTK 0.9.1, with support for multiple contexts.

djk's picture

Our app is an MDI app so each time the user opens a new view (that contains an GLControl) it needs to be able to share the displaylists. In Hoops3d we used to issue an include_segment command to access a part of the scene graph for sharing.

If I understand what you have implemented in the WIP you have more than accomplished goal I have.

I need to clean up my sample app that I used for selections and clipping, then I can test the context sharing. I will post the updated version so you can see where I'm heading.

djk

djk's picture

very preliminary, the shared context public api seems to be working. more latter.

djk

djk's picture

It looks like a partial success. I am now able to display, displaylist data in multiple views. The issue is that I have two graphical operators, select and orbit.

When there is only one view open and populated with either sample geometrys, they work as intended.

When the second view is create and populated the operators will start acting wierd after switching views and operators.

I have attached a cleaner version of the sample app I have been using, at this point I am not sure if I going down the wrong path or if there is something not right in OpenTK.

If you have the time to critic the sample app I would appreciate it.

djk

the Fiddler's picture

I've taken a quick look at the project and can confirm the strange behaviour, but I haven't been able to find out where the problem lies. The logic looks solid enough. I'd suggest using GLIntercept or GLSL Devil or an equivalent utility to check for GL errors - enabling/disabling pick mode sometimes results in slowdowns which might indicate there is a GL error.

djk's picture

I will check the utilities out, Thanks.
djk

djk's picture

Here is the begining of the errors from GLIntercept:

DisplayListManager::Destructor - OpenGL id 1 is still active. (DisplayList Memory leak?)
GL ERROR - Function glPopMatrix() generated error GL_STACK_UNDERFLOW
GL ERROR - Function glSelectBuffer(512,0xb4c6f4) generated error GL_INVALID_OPERATION
GL ERROR - Function glPopMatrix() generated error GL_STACK_UNDERFLOW
GL ERROR - Function glSelectBuffer(512,0xb4c6f4) generated error GL_INVALID_OPERATION
GL ERROR - Function glPopMatrix() generated error GL_STACK_UNDERFLOW
GL ERROR - Function glSelectBuffer(512,0xb4c6f4) generated error GL_INVALID_OPERATION
...
...
...

This started when second view was opened and I enabled selection, Do I need to do anything special when one of the views gets the current focus?

I am going to check out the second tool and see what it gives. These tools are a gold mine, thank for pointing them out. Looks like a little light reading is in store for tonight.

djk

djk's picture

Debugging under GLSL Devil does not produce any errors and the sample application works fine. It does show that the extension function GL_VERSION_1_1 is executed 4 times as much as all the other openGL calls combined.

djk