S
S
Salabar2014-01-05 18:26:09
C++ / C#
Salabar, 2014-01-05 18:26:09

Freeglut, keyboard and mouse reading

In short, he does not react to either one or the other.

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA);
    glutInitWindowSize(512, 512);
    glutInitContextVersion(4, 3);
    glutInitContextProfile(GLUT_CORE_PROFILE);
<b>    glutMouseFunc(mousemove);    
    glutKeyboardFunc(keybord);
</b>    glutIdleFunc(IdleFunc);


    glutCreateWindow(argv[0]);

    glewExperimental = GL_TRUE; 
    if (glewInit()) {
        cerr << "Unable to initialize GLEW ...exiting" << endl;
        exit(EXIT_FAILURE);
    }
    init();
    
    glutDisplayFunc(display);

    glutMainLoop();
}

void mousemove(int button, int state, int x, int y){
    printf("I'm here\n");
//И еще чуть-чуть кода, который ничего особо не делает
}

void keybord(unsigned char key,int x, int y){
    printf("Hi");
}

Nothing, as you might guess, does not print. In theory, you just need to register these two functions and everything should work by itself, but FIG. IdleFunc works fine. OS - Elementary OS based on Ubuntu 12, run via optirun.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Salabar, 2014-01-05
@Salabar

And, you won't believe, it was necessary to move the block

glutMouseFunc(mousemove);    
    glutKeyboardFunc(keybord);
    glutIdleFunc(IdleFunc);

After glutCreateWindow(argv[0]);. This doesn't explain why Idle works, but so be it. I hope it will be useful to someone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question