Open GL and visual studio 2008

I have been trying to create a C program in Microsoft Visual Basic with open gl and glut. The program simply aims to create a blank window. I believe I have the libraries and header files in the right place but each time I try to compile 81 errors occur in the mesa_wgl.h file. I really have no idea what is going on as I haven’t changed this file. Is there a new mesa_wgl.h or are there any other remedies? Any help would be appreciated.

Well, for once don’t use mesa, it’s not hardware accelerated. What I don’t understand is whether mesa is included implicitly by glut or explicity by you. If the latter, simply use the opengl32.lib provided with your compiler instead of mesa. I would recommend using code::blocks along with MinGW since it comes with standard gl and glut(must be downloaded) examples, but if you want to solve the problem on this compiler, a compiler error log would be welcome. Header files you will need are gl.h, wglext.h and glext.h(The two latter can be downloaded from the registry,the first one comes with your compiler) and libraries are opengl32.lib(included with your compiler unless you overwrote it with the mesa version) and glut.lib.

Thanks for the reply. I believe mesa is included implicitly by glut. This is the code:

#include <GL/glut.h>

void display (void) {
/* Called when OpenGL needs to update the display /
glClear (GL_COLOR_BUFFER_BIT); /
Clear the window */
glFlush();
}

int main (int argc, char** argv) {
glutInit (&argc, argv); /* Initialise OpenGL /
glutCreateWindow (“ex1”); /
Create the window /
glutDisplayFunc (display); /
Register the “display” function /
glutMainLoop (); /
Enter the OpenGL main loop */
return 0;
}

I’ve been given this code but I was just using it to get it to work with Visual Studio 2008. Can you see any problems?

The errors are about the code in the mesa_wgl.h:
Error 1 error C2122: ‘int’ : prototype parameter in name list illegal C:\Program Files\Microsoft Visual Studio 9.0\VC\include\GL\mesa_wgl.h 78 test
Error 2 error C2122: ‘const PIXELFORMATDESCRIPTOR *’ : prototype parameter in name list illegal C:\Program Files\Microsoft Visual Studio 9.0\VC\include\GL\GL\mesa_wgl.h 78 test

There are 81 errors.

Thanks.

I have just found that mesa_wgl.h is included by gl.h in the following piece of code:

#if defined(_WIN32) && !defined(WINGDI) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(CYGWIN)
#include <GL/mesa_wgl.h>
#endif

Should I have an alternate version of gl.h for windows specifically or is it ok?

Thanks again!

You have the mesa version of the header.
Looked at my own headers and found this: for mesa “gl.h” version 6.5.1 that I use in ubuntu there is this line that you mention. For my MinGW compiler, mesa version 4.0, it is omitted so no problem. I think your problem is caused by the !defined(WINGDI) condition, which is defined when writing win32 code(you include <windows.h> that defines it). First thing, try to remove this conditional, see if things work. If they don’t, you must download the visual C gl.h file. It can be found at win32 SDK at microsoft.It’s a bit bulky but didn’t find a better way. Of course you can always use MinGW(Oh, I do know I’m a spammer!:))…

just saw that the official release of mesa 4 includes this line. You can get the MinGW win 32 library and copy the gl.h from there,see if it works if the first method fails. They write in the header that it is modified to be more generic.

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