[SOLVED]Problem with mainloop.
Hello guys.
I'm a newbie in OpenGL and i'm trying to make a program with keyboard events, just to make some tests.
I'm using Linux Debian e g++ to compile the code which i'm making with c++.
The problem is when i run my program, what i see is:
Quote:
Object created.
Object killed with success.
I thought the "main" method would be waiting i push a button on the keyboard. I'm saying this because of "glutMainLoop();".
Why it doesn't happen, and the "glutMainLoop();" method does not enter in loop?
Code :
//keyboard.h
#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 :
//keyboard.cpp
#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)
{
switch(key)
{
case 'j': cout<<"Nothing, just testing."<<endl;
break;
}
}
Code :
//main.cpp
#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);
glutKeyboardFunc(keypress_wrapper);
glutMainLoop();
}
To compile:
Quote:
g++ -o test main.cpp keyboard.cpp -lglut
What i'm doing wrong?