OpenGL in VS with C#

  • Thread starter Thread starter pontifikas
  • Start date Start date
P

pontifikas

I've be struggling for a few days to make Opengl work in VS using C#.

However, all wrappers I've stambled on(CsGL,
CsGL.Basecode,ColinFahey's wgl etc)
do not provide sufficient info on how to do it.They only give their
own classes and "high level" methods and for someone nwe to C# is
impossible to figure out how they do it.

Has anyone used OpenGL with C#?

What I want is to deploy a rendering context on any component I
like(even buttons, but a panel whould be sufficiet).
I can take the handle from the panel, but I dont understand how to
give this handle to the opengl , start the mainloop and play.


Any suggestions whould be highly appreciated.
Thanks in advance :)

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Hi,

you have to write a wrapper for all the OpenGL funcs.
I did it in C++.NET, because this is easier for me... This is actually
the world I grew up in.

This looks like this (excerpt from MSDN):

You can pass members of a class to an unmanaged DLL function, as long as
the class has a fixed member layout. The following example demonstrates
how to pass members of the MySystemTime class, which are defined in
sequential order, to the GetSystemTime in the User32.dll file.
GetSystemTime has the following unmanaged signature:
void GetSystemTime(SYSTEMTIME* SystemTime);
Unlike value types, classes always have at least one level of indirection.

[C#]
[StructLayout(LayoutKind.Sequential)]
public class MySystemTime {
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
}
class Win32API {
[DllImport("Kernel32.dll")]
public static extern void GetSystemTime(MySystemTime st);
}


Try wrapping some simple funcs and then go for Google and the MSDN
search for PInvoke. In the beginning this is hard to understand, but
after you have wrapped a couple simple API-Funcs this gets very clear. I
will post a fully functional Wrapper along with the source code and
dokumentation on my WebSite in a couple of weeks. At the moment I'm
stuck in two projects I have to finish by the end of next week.

Hope this provided some usefull information to you,


Regards,

Martin
 
Well...thanks mate but this makes it more complicated.
I dont have good knowledge of C# and .Net, and the worse is that I
dont have time to aquire it :? :( .

I suppose I have to return to my existing QT implementation in
Linux(which is not bad but for some reasons I wanted to transfer it
to VS and C#) :?

Nevertheless , CsGL appears to be quite a potent wrapper, but it lacks
examples to show you the elementary,i.e Initialize->Begin
Loop->Draw.

In the only example I found(called BaseCode) the creator has
implemented his own classes based on CsGL and makes it even more
obscure.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Back
Top