Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Glut or Freeglut?

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    8

    Glut or Freeglut?

    Hi.
    I started programming with OpenGL, and i made this little program bellow:
    Code :
    #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;
    }
    Code :
    #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
    Code :
    #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();
    }
    Code :
    //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.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Never, ever use GLUT for anything. If you want something GLUT-like, use FreeGLUT.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    8
    Never, ever use GLUT for anything. If you want something GLUT-like, use FreeGLUT.
    Ok, understood.
    I tried to include freeglut library like bellow:
    Code :
    #include<GL/freeglut.h>
    And in my makefile i changed "-lglut" to "-lfreeglut", like bellow:
    Code :
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •