Hello World blues

I am just getting started with OpenGL and need to get the “Hello World” program running.

I have just downloaded the MESA implementation and have no problems running the demos with VS 6.0 on Windows XP. But I want to “start from scratch” so I will understand what’s going on. To do this, I want to create a new project from scratch in its own workspace, unassisted by the MESA demos.

I’ve copied MESA’s include\GL folder to the VC98\Include\GL folder, the MESA lib folder to the VC98 lib folder, and put the DLLs in Windows\System32. I’ve added OpenGL32.lib, glu32.lib, and glut32.lib to Visual Studio’s Project->Settings->Link->Object/Library list. The following program compiles with no errors or warnings, but when I execute it, I get a “failed to create OpenGL rendering context” error in the console output.

Any help getting past this will be gratefully appreciated.

#include <gl/glut.h>

void main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow(“3D Tech- GLUT Tutorial”);
}

The creation of a rendering context is partly dependent upon the pixel formats available from the your currently installed OpenGL board and driver. You probably will want to see what using just GLUT_RGB flag does. This of course presumes your desktop is in a direct-color (non-palette) RGB mode.

It might also be possible that you forgot to add some compiler switch to your DevStudio project if you created it from scratch. Look for #defines like CONSOLE or WINDOWS or such in the Mesa makefiles and add them to DevStudio.

You will probably find out a lot more if you put the source for Mesa and GLUT into DevStudio projects as well. Then you will be able to actually step through the code and see exactly what’s going on.

Well, the answer turns out to be a lot more annoying than that. Doing an option-by-option walk-through of the MESA projects that DO work, I noticed a “Post-build” command that copies all the DLLs from the MESA lib to the executable’s directory. Some directions I saw said just put them in System32, where all good DLLs go, and I did that. But the annoying thing is that on my XP box, they won’t stay put. As soon as I overwrite, say, OpenGL32.DLL in System32, XP sticks its tongue out at me and restores the one that was there before. So I’ve thrown in the towel, copied the DLLs to my executable’s path, and I’m in business. Thanks for the suggestion, though; I suspect it will come in handy some other time.

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