Drawing in Callback-Functions not allowed ??

Hi,

i have a simple problem:

void processMouse (int button, int state, int x, int y)
{
   if (x < 100) {  glPushMatrix ();
           glTranslatef (0.5,0.0,0.0);
           glScalef (0.1,1.0,1.0);
           glutSolidCube(1.0);
           glPopMatrix ();}
}
 

nothing happens :frowning:
i just want to draw this scaled cube if x is smaller than 100.

how does this work ?

greetings calavera

Hi !

Short answer is no, you should always put all OpenGL rendering code in one place because you must draw a complete frame each time.

What you should do is to update some state variable somewhere indicating what you need to do and call something that forces an OpenGL repaint, win32:InvalidateRect() glut:postReDisplay() I think and so on.

Mikael