PDA

View Full Version : moving around in 3d space



ltrain_riders
12-05-2002, 04:40 PM
I have a 3d world created and there is an object, say a ball, I want to move by pressing a button on the keyboard. The problem I keep running into and I can't seem to understand is, when I press 'r' to draw the object at a new position it will only be displayed after I reshape my window. The same applies to my camera movement. When I press the right arrow to rotate around the origin i have to resize my display window for it to take effect. I'm not sure if I'm calling proper functions in the correct place or if my setup is even correct, but I wonder if this is also why my textures disappear when I resize my window. Here's my code: http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=2720

Coriolis
12-05-2002, 05:12 PM
Resizing the window forces a redraw. If you are using glut, you have to do whatever the glut redraw function is. If you are using windows without glut, you need to call InvalidateRect(your window's HWND, NULL, FALSE). If you are using a mac or unix or some other machine, you'll have to do the equivalent thing for that specific hardware.

ltrain_riders
12-05-2002, 05:20 PM
so i would need to call glutDisplayFunc( display ); after each instance I want to move an object ?

ltrain_riders
12-05-2002, 05:32 PM
doesn't glMainLoop( ); keep looping so the function called inside main( ) will continuously be called upon? I have my glutDisplayFunc( display ); inside main( ) and it should keep redrawing? When I press 'r' the coordinates are changed inside display( ), so the ojbect should be automatically redrawn. I even called glutDisplayFun( ) as that should register the redraw function...

zed
12-05-2002, 06:35 PM
to force a screen refresh in glut do
glutPostRedisplay() (or something like that check the help)

also u can make your glut idle callback call the display function