PDA

View Full Version : Quirky OpenGL in VB (shudder) Error



Omaha
05-21-2003, 09:27 PM
I feel almost filthy for asking this, but here goes. The other day I was bored so I decided to challenge myself to get a quick OpenGL demo done for a friend in Visual Basic. I do not normally use VB except for when I need a GUI absolutely positively overnight; my medium is C and C++.

Anyway, all was well until it came time to initialize OpenGL. My window was made (in this case, a picturebox control) my pixel format was set, I tested my handles with some quick GDI calls and generous GetLastError() usage--all was well. But then, wglCreateContext would always fail. The error code from GetLastError() was burned into my head--2000, which from MSDN is "invalid pixel format."

My code here was pretty much an exact translation from the C function I use to initialize OpenGL in almost all of my programs. The only difference was this one was in silly Visual Basic.

To make a long story short, the solution I discovered by accident (I hit two buttons in the wrong order) was very odd. Call any OpenGL function before setting the pixel format (the call itself will do nothing), and the calls after the pixel format setting will now succeed fully. Darndest thing.

I'm on an nVidia card/Windows 2000 if that means anything. The problem is not major, I was just wondering if anyone knew anything about this.

There's no place like C/C++, there's no place like C/C++... ClickHeels();

btw, feel free to try the demo right here: http://www.personal.psu.edu/users/d/j/djp211/files/OpenGLTest.exe

[This message has been edited by Omaha (edited 05-21-2003).]