Hi all,
I’m a beginner to openGL. I’m using latest version of ubuntu to run my openGL code and I have nvidia Gefore 8600M GT card and I have the drivers installed. Here is the code that I’m using.
#include <stdlib.h>
/* opengl and glut includes */
#if defined(CYGWIN) /* CYGWIN */
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
#elif defined(LINUX) /* LINUX */
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif
/* prototypes */
void init(void);
void display(void);
/---------------/
/* main function */
/---------------/
int main(int argc,char **argv)
{
/* GLUT management */
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(600,600);
glutInitWindowPosition(100,100);
glutCreateWindow(“Hello CSI703”);
/* call the initialization function */
init();
/* drawing function */
glutDisplayFunc(display);
/* get in the infinite loop */
glutMainLoop();
return 0;
}
/-------------------------/
/* initialization function */
/-------------------------/
void init(void)
{
/* set backgroung color RGB plus alpha */
glClearColor(0.1,0.1,0.1,0.0);
/* selects the projection matrix to work */
glMatrixMode(GL_PROJECTION);
/* loads the identity */
glLoadIdentity();
/* specifies the projection type => ortho */
/* left right bottom top near far */
glOrtho( 0.0, 3.0, 0.0, 3.0, -1.0, 1.0);
return;
}
/------/
/* draw */
/------/
void display(void)
{
/* clean all pixels */
glClear(GL_COLOR_BUFFER_BIT);
/* set color for polygon */
glColor3f(0.5,0.5,0.0);
/* draw polygon */
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();
/* set color for triangle */
glColor3f(0.1,0.5,0.0);
/* draw a triangle */
glBegin(GL_TRIANGLES);
glVertex3f(1.00,1.00,0.0);
glVertex3f(2.00,1.00,0.0);
glVertex3f(1.00,0.25,0.0);
glEnd();
glFlush();
return;
}
I’m getting the following error…
gcc -c -Wall -pedantic -O3 -D_LINUX_ open_window.c
open_window.c:26:21: error: GL/glut.h: No such file or directory
open_window.c: In function ‘main’:
open_window.c:41: warning: implicit declaration of function ‘glutInit’
open_window.c:42: warning: implicit declaration of function ‘glutInitDisplayMode’
open_window.c:42: error: ‘GLUT_SINGLE’ undeclared (first use in this function)
open_window.c:42: error: (Each undeclared identifier is reported only once
open_window.c:42: error: for each function it appears in.)
open_window.c:42: error: ‘GLUT_RGB’ undeclared (first use in this function)
open_window.c:43: warning: implicit declaration of function ‘glutInitWindowSize’
open_window.c:44: warning: implicit declaration of function ‘glutInitWindowPosition’
open_window.c:45: warning: implicit declaration of function ‘glutCreateWindow’
open_window.c:51: warning: implicit declaration of function ‘glutDisplayFunc’
open_window.c:54: warning: implicit declaration of function ‘glutMainLoop’
make: *** [open_window.o] Error 1
This code runs perfectly on other linux machine but not on my laptop. I have been trying to fix this for the past one week, but I couldn’t able to find a solution.I have mesa-common-dev, freeglu installed.
This is the make file that I’m using…
SRC1=open_window.c
OBJ1=open_window.o
EXE1=open_window
----------------------------------
CC=gcc
DEBUG= -g
OPT= -O3
CFLAGS= -c -Wall -pedantic $(OPT) -D_LINUX_
LFLAGS= $(OPT) -lglut -lGLU -lGL
LFLAGS_NO_OPENGL= $(OPT)
all: $(EXE1)
$(EXE1): $(OBJ1)
$(CC) $(OBJ1) $(LFLAGS) -o $(EXE1)
$(OBJ1): $(SRC1)
$(CC) $(CFLAGS) $(SRC1)
clean:
rm -f *.o *.exe $(EXE1)
It will be nice if you guys can help me out to fix this issue.
Looking forward for reply from you guys.
Thanks in advance.
Arun