[Mono-winforms-list] NeHe's OpenGL C# example

Jonathan Gilbert 2a5gjx302 at sneakemail.com
Mon Feb 19 12:12:48 EST 2007


At 09:11 AM 2/19/2007 +0100, Rolf Bjarne Kvinge wrote:
>> -----Original Message-----
>> From: mono-winforms-list-bounces at lists.ximian.com [mailto:mono-
>> winforms-list-bounces at lists.ximian.com] On Behalf Of b4silence
>> Sent: lunes, 19 de febrero de 2007 2:45
>> To: mono-winforms-list at lists.ximian.com
>> Subject: [Mono-winforms-list] NeHe's OpenGL C# example
>> 
>> Hello all,
>> 
[snip]
>> Unhandled Exception: System.EntryPointNotFoundException: GetDC
>>   at (wrapper managed-to-native) OpenGL.WGL:GetDC (uint)
>>   at OpenGL.BaseGLControl.InitializeGL (System.Object sender,
>
>The code is using platform invoke to call directly into GetDC in
>user32.dll, which doesn't exist on Linux. You'll have to change the code
>to not use platform invokes (or find Linux equivalents). I know nothing
>about OpenGL, so there I can't help you :)

I wonder if perhaps the GetHdc() and ReleaseHdc() methods of
System.Graphics would help here. You can get a System.Graphics instance for
any System.Windows.Forms control with the CreateGraphics() method on that
control.

As I understand it, the HDC has no meaning on non-Windows platforms, but
the Handle of a control may give you whatever X11 handle is needed to
initialize OpenGL on UNIX systems. You may find it easier, however, to use
the SDL library. It contains code specifically for initializing an OpenGL
context in a platform-independetn way. SDL is a native library, but it has
been ported to a wide range of platforms and has been wrapped in C# by the
Tao Framework (http://www.mono-project.com/Tao). Heck, now that I look at
the Tao project site, Tao itself contains an OpenGL wrapper too.

I know virtually nothing beyond that about using OpenGL, but good luck with
your project. :-)

Jonathan Gilbert


More information about the Mono-winforms-list mailing list