Hangar's picture

Way to reset the context of the current thread

I've looked at a lot of OpenGL libraries, and I think this one has some potential. One problem I ran into was not being able to reset the context on the current thread so that other threads can use it. (I need this functionality for my threading model.) Any chance of getting a ResetCurrentContext static function?

The implementation would just call:

Wgl.Imports.MakeCurrent(IntPtr.Zero, IntPtr.Zero); for windows.
Glx.MakeCurrent(windowInfo.Display, IntPtr.Zero, IntPtr.Zero); for X.

Also, I'm interested in contributing if I can. I'd like to see an OSX native port and more advanced font layout sometime in the future.


Comment viewing options

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

Welcome to the forum :)

Any chance of getting a ResetCurrentContext static function?
Fiddler is responsible for the OpenGL part and knows the current state of the context wrapper best, but I don't see any reason why this shouldn't be included.

Contributions are always welcome, but I'd recommend talking to Fiddler before starting any serious effort - solely to avoid duplicate work.

The only problem with MacOS is that all current developers are quite busy with their current tasks already, and none of us currently uses MacOS. The only 2 things that really need some care for the port are 1) the input drivers and 2) OpenGL context creation. Everything else is expected to compile with minor adjustments (if any at all).

the Fiddler's picture

Welcome, indeed!

[ResetCurrentContext static function]
You are right, this functionality is missing. Will add!

[Advanced font layout]
What layout kinds do you need? The initial plan was to support left/right/center justification, left-to-right/right-to-left modes and optional grid-fitting (snapping glyphs to pixel boundaries). Fonts are in the back burner however, so I kinda hoped someone would show interest in contributing ;)

Alwin has expressed interest in a native implementation through GLUT. While this will help get an implementation up and running quickly, not all functionality can be replicated this way (e.g. monitor discovery, Windows.Forms integration), so a native Cocoa port would be the long-term goal for OSX.

Ok, you can now reset the current context of any thread through:

GLContext.CurrentContext = null;
Hangar's picture

Thanks for update.

Well, the emphasis is on "sometime in the future." I don't use a Mac either, but I know several people who wouldn't be able to use my programs unless there was a Mac port. At this point, I'm just glad you plan to support it in the future.

[Edited by TheFiddler: let's continue the font discussion at http://www.opentk.com/node/237, otherwise it might get lost!]

jcornwall's picture

This thread is a little old, but I'm bumping because progress hasn't appeared in SVN and I need the functionality.

Fiddler, could you make the patch for resetting the current context available?