[Mono-osx] [MonoMac] OpenGL OpenTK proposal / compromise
Geoff Norton
gnorton at novell.com
Mon Feb 14 12:07:13 EST 2011
Kenneth,
I'd like to see this code. I have a opentk repo on github:
http://github.com/kangaroo/opentk
Could you fork it and land your patches?
Thanks
-g
On 2011-02-13, at 9:47 AM, kjpou wrote:
> Hello all
>
> Have spent the last two days working on the OpenTK. Ended in
> frustration basically.
>
> Here is what I have:
>
> OpenTK.Graphics.CoreOpenGL
>
> Basically all the mappings, delegates, helper methods, ErrorHelper. It
> was a copy from the windows OpenTK.Graphics.OpenGL. The bindings are
> all there and can load them all from a CglContext which is a new
> Platform backend OpenGL context I created.
>
> There are something like 2700 method bindings that are delivered with
> the Windows OpenGL implementation of which only about 600 are used on
> the mac.
>
> I have a platform backend hacked together. When I say hacked I mean
> hacked but it all loads fine. No GUI implementation as it uses the
> current context created from NSOpenGLContext. That part works.
>
> OpenTK.Platform.MacOS
>
> -> CocoaBindings
> ---> Cgl
>
> -> CglContext
> -> CocoaApplication
> -> CocoaGLNative
> -> CocoaWindowInfo
>
> You can create a context.
>
> OpenTK.Platform.IWindowInfo windowInfo
> =
> OpenTK.Platform.Utilities.CreateMacOSCocoaWindowInfo( mGLContext.Handle );
>
> OpenTK.ContextHandle handle = new
> OpenTK.ContextHandle( mGLContext.Handle );
>
> OpenTK.Graphics.GraphicsContext context =
> new
> OpenTK.Graphics.GraphicsContext(handle, windowInfo);
>
> context.MakeCurrent( windowInfo );
>
> When it starts calling the Delegates for example.
>
> ErrorCode theError = ErrorCode.NoError;
> theError = GL.GetError ();
> GL.ReadBuffer (ReadBufferMode.Front);
>
> It is erroring out with errors for the native bindings which I can not
> figure out because of the all the Delegate calls. If you call the
> GLCore methods directly it all works fine but using the OpenTK Delegate
> way it is not working.
>
> If someone wants to take what I have and try to get it all working you
> are more than welcome. Either way those 600 +/- OpenGL calls are going
> to have to be gone through and culled out.
>
> In about one hour I ripped all the mappings from the OpenTK for Cocoa
> that I wrote and placed them in a separate project with some small
> modifications and got two MonoMac OpenGL samples working. One hour vs
> two days hummmm really a no brainer there for where I would prefer to
> spend my time.
>
> I am in the process of going through by hand and only implementing those
> 600 or so methods by hand to get a MonoMac.CoreOpenGL bindings working
> based on that one hours work. Basing it on what I learned from the
> OpenTK I can have it mapping exactly the same way so if someone gets the
> OpenTK working it should be just a change of library. What I mean by
> that is that all one would have to do to use the OpenTK is include it in
> the project because the naming of the parameters will be exactly the
> same as those you will already be using for the MonoMac.CoreOpenGL bindings.
>
> So the following code below would work with OpenTK as well as the
> MonoMac.CoreOpenGL bindings. Technically the same code would work for
> any other OpenTK based program as well.
>
> ErrorCode theError = ErrorCode.NoError;
>
> // select front buffer as our source for pixel data
> GL.ReadBuffer (ReadBufferMode.Front);
>
> //Read OpenGL context pixels directly.
>
> // For extra safety, save & restore OpenGL
> states that are changed
> GL.PushClientAttrib
> (ClientAttribMask.ClientPixelStoreBit);
>
> GL.PixelStore
> (PixelStoreParameter.PackAlignment, 4); /* Force 4-byte alignment */
> GL.PixelStore
> (PixelStoreParameter.PackRowLength, 0);
> GL.PixelStore
> (PixelStoreParameter.PackSkipRows, 0);
> GL.PixelStore
> (PixelStoreParameter.PackSkipPixels, 0);
> // Read a block of pixels from the frame buffer
> GL.ReadPixels (0, 0, bufferWidth, bufferHeight,
> PixelFormat.Bgra, PixelType.UnsignedInt8888Reversed, buffer);
>
> GL.PopClientAttrib ();
>
> theError = GL.GetError ();
> if (theError != ErrorCode.NoError)
> Console.WriteLine ("OpenGL error {0}",
> theError);
>
>
> Now before I go through with this would like to know if this is an
> acceptable compromise and would it be worth the effort to be included
> within the MonoMac bindings.
>
> If you want the code that I have begun for OpenTK let me know.
>
> Kenneth
>
>
>
>
>
>
>
>
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
More information about the Mono-osx
mailing list