Why this little program doesn't work ?

the error of compilations are at the end :

#include <gl>
#include <glut>

void Init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0) ;
}

void Reshape(int w, int h)
{
glMatrixMode(GL_PROJECTION);
glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0) ;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void Display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0 );
glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
glFlush();
}

void main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB);
glutInitWindowSize(300, 300); // Any Window Size will do
glutInitWindowPosition(100, 100); // Again any Window position will do
glutCreateWindow(“Any Name you like”);
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
glutMainLoop();
}

Error: GL.h(833,15) eclaration syntax error
Error: GL.h(834,15):Multiple declaration for ‘WINGDIAPI’
Error: GL.h(833,15):Earlier declaration of ‘WINGDIAPI’
Error: GL.h(834,15) eclaration syntax error
Error: GL.h(835,15):Multiple declaration for ‘WINGDIAPI’
Error: GL.h(834,15):Earlier declaration of ‘WINGDIAPI’
Error: GL.h(835,15) eclaration syntax error
Error: GL.h(836,15):Multiple declaration for ‘WINGDIAPI’
Error: GL.h(835,15):Earlier declaration of ‘WINGDIAPI’
Error: GL.h(836,15) eclaration syntax error
Error: GL.h(837,15):Multiple declaration for ‘WINGDIAPI’
Error: GL.h(836,15):Earlier declaration of ‘WINGDIAPI’
Error: GL.h(837,15) eclaration syntax error
Error: GL.h(838,15):Multiple declaration for ‘WINGDIAPI’
Error: GL.h(837,15):Earlier declaration of ‘WINGDIAPI’
Error: GL.h(838,15) eclaration syntax error
Error: GL.h(839,15):Multiple declaration for ‘WINGDIAPI’
Error: GL.h(838,15):Earlier declaration of ‘WINGDIAPI’
Error: GL.h(839,15) eclaration syntax error
Error: GL.h(840,15):Multiple declaration for ‘WINGDIAPI’
Error: GL.h(839,15):Earlier declaration of ‘WINGDIAPI’
Error: GL.h(840,15) eclaration syntax error
Error: GL.h(841,15):Multiple declaration for ‘WINGDIAPI’
Error: GL.h(840,15):Earlier declaration of ‘WINGDIAPI’
Error: GL.h(841,15) eclaration syntax error
Error: GL.h(841,15):Too many error or warning messages

Include “Windows.h” before you include “gl.h”

Just put glut.h first and leave out gl.h.

glut.h has both windows.h and gl.h already referenced in it.

Here is my include’s that I use.
#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

Originally posted by ARES:
Include “Windows.h” before you include “gl.h”

[This message has been edited by nexusone (edited 03-25-2002).]

[This message has been edited by nexusone (edited 03-25-2002).]

[This message has been edited by nexusone (edited 03-25-2002).]

Hmmm, my glut doesnt have windows referenced in it… And i have the newest one. Weird.

GLUT doesn’t include “windows.h”, it defines the necessary stuff itself. It’s just to prevent namespace pollution.

i haven’t told that i use borland ++ 5.02
does it change something ?

Here is a copy of the start of the glut.h that I have. Somewhere on in the header it say’s version 3.

#ifndef glut_h
#define glut_h

/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. */

/* This program is freely distributable without licensing fees and is
provided without guarantee or warrantee expressed or implied. This
program is -not- in the public domain. */

#if defined(WIN32)
#include <windows.h>
#pragma warning (disable:4244) /* disable bogus conversion warnings */
#endif
#include <GL/gl.h>
#include <GL/glu.h>

Originally posted by Bob:
GLUT doesn’t include “windows.h”, it defines the necessary stuff itself. It’s just to prevent namespace pollution.

Did you try what I suggested?
use glut.h first?
I don’t think it should make to much diffrence being borland C++, as long as you have the compiler setup properly and the linker settings correct to include the opengl library’s…

Also have you been able to compile other programs with your compiler?
Like a non-gl one.

Originally posted by airseb:
i haven’t told that i use borland ++ 5.02
does it change something ?

Hey, this is the same program I posted in response to your earlier thread …

Relace #include <glut> with
#include <glut.h> or #include <GL/glut.h> (There is no such file as “glut” - without the *.h etension). Whichever version you use depends on where you have placed the file glut.h on your system. (I suggest the latter form.)

Remove the directive: #include <gl.h>. It’s not necessary. Why? … because glut.h automatically “takes care” of glu.h which in turn “takes care” of gl.h

Try Reading the Chapters 1 - 4 of the Red Book.

/* GLUT 3.7 now tries to avoid including <windows.h>
to avoid name space pollution, but Win32’s <GL/gl.h>
needs APIENTRY and WINGDIAPI defined properly. */

if 0

/* This would put tons of macros and crap in our clean name space. */

define WIN32_LEAN_AND_MEAN

include <windows.h>

else

See that “#if 0/#else” around <windows.h>?

Below that code, GLUT defines the necessary names from windows.h

[This message has been edited by Bob (edited 03-26-2002).]