Beispiel #1
0
// This callback function gets called by the Glut
// system whenever the window is resized by the user.
void reshape(int w, int h)
{
	// Reset our global variables to the new width and height.
	screen_x = w;
	screen_y = h;
	if (current_view == top_view){
		SetTopView(w,h);
	}
	else if ( current_view == perspective_view){
		SetPerspectiveView(w,h);
	}
	else {  // current_view == rat_view
		SetPerspectiveView(w,h);
	}

	// Set the pixel resolution of the final picture (Screen coordinates).
	glViewport(0, 0, w, h);

		// Set the projection mode to 2D orthographic, and set the world coordinates:
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		//pixel coordinates
		//gluOrtho2D(0, w, 0, h);
		//scale of 0-10
		gluOrtho2D(0, 10, 0, 10);
		glMatrixMode(GL_MODELVIEW);

}
Beispiel #2
0
// This callback function gets called by the Glut
// system whenever a key is pressed.
void keyboard(unsigned char c, int x, int y)
{
	switch (c) 
	{
		case 27: // escape character means to quit the program
			exit(0);
			break;
		case 'r':
			current_view = rat_view;
			SetPerspectiveView(screen_x,screen_y);
			break;
		case 't':
			current_view = top_view;
			SetTopView(screen_x,screen_y);
			break;
		case 'p':
			current_view = perspective_view;
			SetPerspectiveView(screen_x,screen_y);
			break;
		case 'b':
			// do something when 'b' character is hit.
			break;
		default:
			return; // if we don't care, return without glutPostRedisplay()
	}

	glutPostRedisplay();
}
Beispiel #3
0
// This callback function gets called by the Glut
// system whenever the window is resized by the user.
void reshape(int w, int h)
{
	// Reset our global variables to the new width and height.
	screen_x = w;
	screen_y = h;

	// Set the pixel resolution of the final picture (Screen coordinates).
	glViewport(0, 0, w, h);

    if(terrain.current_view == terrain.top_view)
    {
        SetTopView(w,h);
    }
    else if(terrain.current_view == terrain.perspective_view)
    {
        SetPerspectiveView(w,h);
    }
    else // current_view == rat_view
    {
        SetPerspectiveView(w,h);
    }

}
Beispiel #4
0
// This callback function gets called by the Glut
// system whenever a key is pressed.
void keyboard(unsigned char c, int x, int y)
{
	switch (c) 
	{
        case 'a':
            slope+=.01;
            break;
        case 'b':
            slope-=.01;
            break;
        case 'c':
            waterLevel+=.01;
            break;
        case 'd':
            waterLevel-=.01;
            break;
        case 'r':
            terrain.current_view = terrain.eye_view;
            SetPerspectiveView(screen_x, screen_y);
            break;
        case 'p':
            terrain.current_view = terrain.perspective_view;
            SetPerspectiveView(screen_x, screen_y);
            break;
        case 't':
            terrain.current_view = terrain.top_view;
            SetTopView(screen_x, screen_y);
            break;
        case 'z':
            right_button_down = false;
            if (left_button_down == true) {
                left_button_down = false;
            }
            else{
            left_button_down = true;
            }
            middle_button_down = false;
            break;
        case 'v':
            left_button_down = false;
            if (right_button_down == true) {
                right_button_down = false;
            }
            else{
                right_button_down = true;
            }
            middle_button_down = false;
            break;
        case 'w':
            left_button_down = false;
            right_button_down = false;
            if (middle_button_down == true) {
                middle_button_down = false;
            }
            else{
                middle_button_down = true;
            }
            break;
        case 'q':
		case 27: // escape character means to quit the program
			exit(0);
			break;

		default:
			return; // if we don't care, return without glutPostRedisplay()
	}

	glutPostRedisplay();
}