PDA

View Full Version : Glut or Freeglut?



robgeek
01-24-2013, 11:02 AM
Hi.
I started programming with OpenGL, and i made this little program bellow:

#include"keyboard.h"

Keyboard :: Keyboard(void)
{
cout<<"Object created."<<endl;
}

Keyboard :: ~Keyboard(void)
{
cout<<"Object killed with success."<<endl;
}

void Keyboard :: keyPressed(unsigned char key, int x, int y)
{
cout<<"You pressed "<< key <<" button."<<endl;
}

#ifndef __keyboard_h__
#define __keyboard_h__

#include<iostream>
#include<GL/gl.h>
#include<GL/glut.h>
#include<GL/glx.h>

using namespace std;

class Keyboard
{
public:
Keyboard(void);
~Keyboard(void);
void keyPressed (unsigned char key, int x, int y);
};

#endif

#include"keyboard.h"

Keyboard global_keyboard;

void keypress_wrapper(unsigned char key, int x, int y)
{
global_keyboard.keyPressed(key, x, y);
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);

glutInitWindowSize (500, 500);
glutCreateWindow ("My first OpenGL Window");

glutKeyboardFunc(keypress_wrapper);

glutMainLoop();
}

//To compile:
//I'm using Debian Linux.
g++ -o game keyboard.cpp main.cpp -lglut

I'm using glut or freeglut?
I would like to use freeglut, here in this forum, some guy told me Glut is quite old.

Alfonse Reinheart
01-24-2013, 12:22 PM
Never, ever use GLUT for anything. If you want something GLUT-like, use FreeGLUT.

robgeek
01-24-2013, 02:44 PM
Never, ever use GLUT for anything. If you want something GLUT-like, use FreeGLUT.

Ok, understood.
I tried to include freeglut library like bellow:

#include<GL/freeglut.h>
And in my makefile i changed "-lglut" to "-lfreeglut", like bellow:

hist:
g++ -o game keyboard.cpp main.cpp -lfreeglut
and i have this error message:

cannot find -lfreeglut
collect2: ld returned 1 exit status
make: *** [hist] Error 1


What i have to do to use freeglut?