OpenGL, Managed C++.NET, Windows Forms

I see from the discussion that a few have figured out how to utilized OpenGL using Managed C++.NET and Windows Forms. I would appreciate if someone could provide an example. I have studied the Win32 port on the Microsoft MSDN web site. I tried to port it to Managed C++.NET, but it always generates a runtime type error. Is there an obivious way to do it?

I would like to utilize the wgl interface directly from C++. I am able to get the window handle to the form, but not its device context. The problem is when the program gets the device context for the form the graphics class becones undefined and you get a runtime error. I wrote a C++ wrapper for everything else, but am unable to get the device contact. Can someone help with this or explain how they solved the problem?
Thanks to all in advance.

Try the following:

[DllImport(“user32”, EntryPoint = “GetDC”)]
public unsafe static extern IntPtr GetDC( IntPtr hWnd );

where hWnd is the handle to your form.

there should be no problem, your form class got a handle property which is a pointer.

in c++ managed, it should look something like that:

HDC hDC = GetDC(myForm->Handle.ToInt32());

im not at my pc at the moment so this is from my memory - tell me how it goes, i’ll check the code later.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.