I've been using this simple program and make file to test if the gl, glu, and glut libraries are present (by just trying to make).
main.cpp
#ifndef MAIN_CPP
#define MAIN_CPP
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <iostream>
using std::cout;
void init()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_DEPTH_TEST);
}
void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_LINES);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 1.0, 0.0);
glEnd();
glutSwapBuffers();
}
void keyboardfunc(unsigned char c, int x, int y)
{
switch (c)
{
case 't':
glRotatef(4.0, 0.0, 0.0, 1.0);
break;
case 'y':
glRotatef(-4.0, 0.0, 0.0, 1.0);
break;
case 'u':
glRotatef(4.0, 0.0, 1.0, 0.0);
break;
case 'i':
glRotatef(-4.0, 0.0, 1.0, 0.0);
break;
case 'o':
glRotatef(4.0, 1.0, 0.0, 0.0);
break;
case 'p':
glRotatef(-4.0, 1.0, 0.0, 0.0);
break;
case 'w':
glTranslatef(0.0, 1.0, 0.0);
break;
case 'a':
glTranslatef(-1.0, 0.0, 0.0);
break;
case 's':
glTranslatef(0.0, -1.0, 0.0);
case 'd':
glTranslatef(1.0, 0.0, 0.0);
break;
}
renderScene();
}
void changeSize(int w, int h)
{
//currentWindowWidth = w;
//currentWindowHeight = h;
float angle=0.0;
float x=0.0f,y=1.75f,z=5.0f;
float lx=0.0f,ly=0.0f,lz=-1.0f;
float ratio=1.0;
// Prevent a divide by zero, when window is too short
// (you cant make a window of zero width).
if(h == 0)
h = 1;
ratio = 1.0f * w / h;
// Reset the coordinate system before modifying
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set the viewport to be the entire window
glViewport(0, 0, w, h);
// Set the clipping volume
gluPerspective(45,ratio,1,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(x, y, z,
x + lx,y + ly,z + lz,
0.0f,1.0f,0.0f);
}
int main(int argc, char **argv)
{
cout << "In main()\n";
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(300,300);
glutCreateWindow("simple beginning");
init();
glutKeyboardFunc(keyboardfunc);
//glutMouseFunc(mousefunc);
glutDisplayFunc(renderScene);
//glutIdleFunc(renderScene);
glutReshapeFunc(changeSize);
glutMainLoop();
return(0);
}
#endif
Makefile
INCLUDE = -I/usr/X11R6/include/ LIBDIR = -L/usr/X11R6/lib -L/usr/lib COMPILERFLAGS = -Wall CC = g++ CFLAGS = $(COMPILERFLAGS) $(INCLUDE) LIBRARIES = -lX11 -lXi -lglut -lGL -lGLU -lm All: main main: main.o $(CC) $(CFLAGS) -o $@ $(LIBDIR) $< $(LIBRARIES)

New Topic/Question
This topic is locked



MultiQuote




|