View Full Version : open GL and visual studio 2008

02-26-2009, 08:56 AM
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.

02-26-2009, 10:00 AM
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 (http://www.codeblocks.org) along with MinGW (http://www.mingw.org) 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 (http://www.opengl.org/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.

02-26-2009, 10:28 AM
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 */

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.


02-26-2009, 10:41 AM
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>

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

Thanks again!

02-26-2009, 12:27 PM
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. (http://www.microsoft.com/downloads/details.aspx?FamilyID=E6E1C3DF-A74F-4207-8586-711EBE331CDC&displaylang=en)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!:))...

02-26-2009, 12:40 PM
just saw that the official release of mesa 4 includes this line. You can get the MinGW (http://sourceforge.net/project/downloading.php?group_id=2435&use_mirror=puzzle&filename=w32api-3.13-mingw32-dev.tar.gz&a=14571463) 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.