PDA

View Full Version : implementing an up arrow w/GLUT in 3d...



cg-hci_novice
10-15-2003, 12:06 AM
Hi,

I am trying to implement an up arrow with GLUT and this only causes the image to shake when that key is pressed. I was wondering if someone could tell me if my approach is ok? Or, thoughts on what could be wrong?

Here is what I have:

In processSpecialKeys routine:

switch(key)
{
case GLUT_KEY_UP:
if (up_key_pressed==FALSE)
{
up_key_pressed=TRUE;
scroll_val=5;
}
}

where up_key_pressed is a boolean (global int).


In update routine:

if (up_key_pressed==TRUE)
{
trans_y=trans_y-scroll_val;
up_key_pressed=FALSE;
}

In display routine:

glPushMatrix();
glRotatef(180, 1.0, 0.0, 0.0);
glRotatef(-90, 0.0, 0.0, 1.0);
glTranslatef(trans_x, trans_y, 0);

if (mult_islands==FALSE)
draw_land(0);
else
{
for (i=0; i<num_of_islands; i++)
draw_mland(i);
}
glPopMatrix();

where trans_y is initially set to be a value that will place the vertical center of the land/mland at 0.

Thanks very much.