PDA

View Full Version : .NET to write OpenGL codes



garuka
11-09-2005, 01:05 AM
Hi,
I just start to learn OpenGL. I'm working on windows environment and just finish installing the setup.
I try to use .NET as my development IDE but i'm getting errors saying can't locate header files.
I include gl.h and glu.h into the sln but stil seems to be somehting missing.
Do i have to do some more configurations to use .NET as my IDE for OpenGL??
If i can't use .NET to write OpenGL what are the good IDEs?
thanks in advance...

McTuble
11-09-2005, 06:19 AM
I'd suggest visual studio 6.

Zulfiqar Malik
11-09-2005, 09:19 AM
There is nothing wrong with the IDE and NO, using VC 6.0 won't make your problems go away. This is more of a C++ question. Including a file in solution will not make a difference, you have to using the #include pre-processor directive to include the file. So e.g. if your gl.h and glu.h are located in C:\gl\ directory then you will have to do
#include "C:\gl\gl.h"
but i assume you are using the default headers provided with the IDE, then i suggest you do the following
#include <gl/gl.h> and
#include <gl/glu.h>

Sheesh man ... i don't even know why i am answering this question :D .

11-18-2005, 07:52 PM
You can't build OpenGL apps under .NET (managed C++, C#, etc) without a bit of grunt work. The problem is that you can't use a standard Form for viewing. There are frameworks that attempt to consolidate much of the native wrapping, but by and large I think the necessity for this stinks.

shelll
11-19-2005, 12:20 PM
it is very simple to use open gl with .net :) you use standard ogl headers <gl/gl.h> a then in your code tou just need to get handle of the window..


mHWND = (HWND)this->Panel1>Handle.ToPointer();
mDC = GetDC(mHWND);and then use it as in non-manged c++

11-19-2005, 12:48 PM
That doesn't work :) And even if it did, it's not managed, the very core of the .NET framework is gone. Whereas with d3d, the integration is seemless.

BTW, if you did somehow manage to get this to work, I'd like to see the code :)

FuzzCube
11-20-2005, 06:16 AM
Hi

As far as I know if you want to use OpenGL with managed code your only option the .NET interOp.
The reason is that OpenGL is not a managed DLL.

In order to use OpenGL in managed c++:
1) Include the OpenGL headers.
2) Obtain the HDC for the window that you created. (This is the actual Win32 handle to to your window.)
3) Create a rendering context (wglCreateContext) o n the HDC.
4) Make it current.
5) Start drawing with OpenGL into the window.

Remeber that any OpenGL calls you make are not managed they use the interOp to call the OpenGL DLL.

As far as implementation goes my suggestion is to create
1) Your own OpenGLWindow class that will encapsulate all the window creation unmanaged code.
2) A class (or set of classes) to encapsulate any other OpenGL calls you make.

11-20-2005, 07:29 AM
And use the Form Load event to init OpenGL; don't try it in the constructor, for example.

Google for CsGL for C# glue.

11-20-2005, 07:34 AM
And you may need to #undef GetObject and MessageBox, among other things, because of the inclusion of windows.h.

This is really ugly, IMHO, and totally defeats the platform/implementation independence of .NET, which is really the point in the first place.