ananth.b's picture

Can platform-specific GL contexts be made public?

Hi,
I'm working on a cross-platform GPGPU library for .NET/Mono (http://brahma.ananthonline.net), and I'd like to use OpenTk for initializing/using OpenGL.

I was wondering if there was any specific reason that WinGLContext and X11GLContext are internal classes. As it is, I have the need to initialize OpenGL on a Windows Forms control without ever needing to render anything to the screen (only number-crunching). I'd like to do this in a platform independent way, and I thought OpenTk was the answer.

Also, in case they can't be made public due to any particular design decisions, could I use sections of your code to do the same thing in my library? What would the license implications of this be? I would of course, be sure to give OpenTk credit for any code used.

In case these classes CAN be made public, would it be possible to include overloads for their constructors which accept an already existing rendering context? The idea being: a user can either create a new context or tell my GPGPU provider to use an existing context (in case he wants to share data/visualize computations).

Thanks in advance,
-Ananth


Comments

Comment viewing options

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

Unknown at the moment. It seems as if Fiddler (the maintainer of OpenTK) is not around.

ananth.b's picture

I guess so, thanks! I guess I'll bump the thread in a week or so and continue using Glfw till then.

the Fiddler's picture

As it is, I have the need to initialize OpenGL on a Windows Forms control without ever needing to render anything to the screen (only number-crunching).
In that case, how about creating a normal - but invisible - window? (Windows.Forms provide a Visible property that can be toggled at will). This should work fine (untested) and with minimal fuss - just use GL.ReadPixels once the processing is done.

OpenTK is supposed to abstract away platform-specific code like X11/WinGLContext, pretty much like GLFW. That said, it might make sense to provide a method to create accelerated offscreen contexts through the GraphicsContext class. I'd consider that if the above approach doesn't work or if someone donates the relevant code :D

Regarding OpenTK with existing contexts: the next version will support contexts created outside OpenTK. I'm still looking for the best way to do this, but it is something that has come up before ((your idea about different constructors is quite good actually).

Finally, regarding the MIT/X11 license: you are pretty much free to copy, modify and redistribute any part of the library, provided the copyright and permission notices are "included in all copies or substantial portions of the Software." My interpretation is that you just need to include the text from License.txt somewhere in your distribution (disclaimer: this is not legal advice).

ananth.b's picture

Thanks for the reply.

Yes, using the Visible property is what I do at the moment. However, instead of toggling the Visible property off, I never even show the window that the context is initialized on. This works just fine (on Windows, I haven't tested it on X yet).

In any case, I've ended up writing my own platform-independent context classes, and they are now part of Brahma. They also include the ability to use an existing context. You are welcome to take a look at the implementation (http://sourceforge.net/svn/?group_id=171683), look at Brahma.Platform.OpenGL. If you'd like me to email you the sources, do let me know and I'd be happy to do so.

Thanks for the advice about the X11 license, but I don't think I'll need to use OpenTk source, although I might migrate my OpenGL bindings from Tao to OpenTk ;)

-Ananth

the Fiddler's picture

Thanks. Kanato is making some changes to improve the WinForms integration and this may come in handy.