OpenGL in VB .NET

D

Dragon

Hello,

I wonder if there's a way to use OpenGL directly from VB .NET, without any
C++ code, or CsGL library. I've tried to convert NeHe's first tutorial
(http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01) to VB .NET, but
it seems to behave improperly somewhere in this fragment:
~
PixelFormat = ChoosePixelFormat(hDC, pfd)

If PixelFormat = 0 Then

MessageBox(0, "Can't find a suitable PixelFormat.", "Error", MB_OK Or
MB_ICONERROR)

PostQuitMessage(0)

Exit Select

End If

If SetPixelFormat(hDC, PixelFormat, pfd) = 0 Then

MessageBox(0, "Can't set PixelFormat", "Error", MB_OK Or MB_ICONERROR)

PostQuitMessage(0)

Exit Select

End If

hRC = wglCreateContext(hDC)

~

In WinME, ChoosePixelFormat returns 0.

In WinXP, ChoosePixelFormat returns 5; but the trouble is with
SetPixelFormat: it returns 1, but actually it does nothing, because
wglCreateContext returns 0 with error code 2000 (invalid pixel format).

Any suggestions? Maybe there is another OpenGL example in VB .NET only?

Thanks in advance.
 
B

bastawhiz

You really should use DirectX. It takes full advantage of the GPU, and
in will work a lot better.
 
D

doug00

I'd use the Tao Framework. It really is the best wrapper for OpenGL.

But if for whatever reason you don't want that, then see also Colin
Fahey's wrapper:
http://www.colinfahey.com/opengl/csharp.htm
which just consists of 6 C# files that you include with your sources.
You'd have to translate his source files into VB.NET. Maybe you can
use one of those online C# to VB translators to help make that easier.

And like the other person said, there is always Managed DirectX, too.
 
H

Herfried K. Wagner [MVP]

I'd use the Tao Framework. It really is the best wrapper for OpenGL.

But if for whatever reason you don't want that, then see also Colin
Fahey's wrapper:
http://www.colinfahey.com/opengl/csharp.htm
which just consists of 6 C# files that you include with your sources.
You'd have to translate his source files into VB.NET. Maybe you can
use one of those online C# to VB translators to help make that easier.

Some more wrappers:

Using OpenGL in .NET applications
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=opengl&lang=en>
 
D

Dragon

Ahh, thanks you all.

It seems that I finally made my code work. However, I got a very weird
error. At the beginning, it asks about running in fullscreen mode. If you
say "no" it spits an error message. On WinXP, it says "Can't Create A GL
Rendering Context.", and error code is 2000. But on 98 and ME systems, error
is "Can't Find A Suitable PixelFormat." (error code 126)! But... if you
choose yes, it sets up fullscreen mode and runs fine, and then if you press
F1 to change mode, it switches back to window and keeps running without any
problems!

I attached my code. If someone pointed me at my mistake, I would be very
grateful.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top