PDA

View Full Version : weird problem



03-23-2003, 08:18 AM
when i try to compile a program using openGL (any program), i get this error:

4 main.cpp
C:/Dev-Cpp/Include/gl/gl.h:1135: syntax error before `void'
1136 c:/dev-cpp/include/gl/gl.h
syntax error before `void'
1137 c:/dev-cpp/include/gl/gl.h
syntax error before `APIENTRY'
1138 c:/dev-cpp/include/gl/gl.h
syntax error before `void'
i get the last error some more with different numbers 1139, 1140 all the way up to 1165.

i know that the fault is not in my program (it's from a tutorial). is this some kind of bug in opengl or so?

p.s. i'm using mingw32 compiler under windows with dev-c++

Iceplode
03-23-2003, 08:24 AM
The gl.h in Windows has a bunch of Windows defines in it. Include windows.h for your Windows builds

03-23-2003, 09:23 AM
ok, now we have an other problem:

31 main.cpp
implicit declaration of function `int glutInit(...)'
32 main.cpp
`GLUT_DOUBLE' undeclared (first use this function)
32 main.cpp
`GLUT_RGB' undeclared (first use this function)
32 main.cpp
implicit declaration of function `int glutInitDisplayMode(...)'
33 main.cpp
implicit declaration of function `int glutInitWindowSize(...)'
34 main.cpp
implicit declaration of function `int glutInitWindowPosition(...)'
35 main.cpp
implicit declaration of function `int glutCreateWindow(...)'
36 main.cpp
implicit declaration of function `int glutDisplayFunc(...)'
38 main.cpp
implicit declaration of function `int glutMainLoop(...)'

i really don't know what the hell this is http://www.opengl.org/discussion_boards/ubb/confused.gif

Iceplode
03-23-2003, 09:24 AM
You need to include GL/glut.h (and link with glut32.lib if you aren't already)

03-23-2003, 09:34 AM
i already did that. that's not the problem

Iceplode
03-23-2003, 09:44 AM
Since you're using glut (in Windows), make sure _WIN32 is in your list of compiler defines (and glut's header will also try and take care of all that windows.h nonsense for you. I haven't checked mingw thoroughly but if you drop the windows.h and let glut try and fix the defines for you, you may need to also define _STDCALL_SUPPORTED).

03-23-2003, 10:14 AM
the problem isn't the compiler either. i've tried borland and it gives the same errors.

anyway here's the program (maybe i'm missing something)



#include <windows.h>
#include <Gl\GL.h>
#include <Gl\GLUT.h>
#include <Gl\GLAUX.h>

void TI_Init(void)
{
glClearColor(1.0,1.0,1.0,0.0);
glColor3f(0.0f,0.0f,0.0f);
glPointSize(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640.0,0.0,480.0);
}

void TI_Display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
glVertex2i(100,50);
glVertex2i(100,130);
glVertex2i(150,130);
glEnd();
glFlush();
}

int main(int argc, char** argv)
{
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(640, 480);
glutInitWindowPosition(100, 100);
glutCreateWindow(".");
glutDisplayFunc(TI_Display);
TI_Init();
glutMainLoop();

return 0;
}


dumbest program in the world.