Tutorial 4
Tutorial 4
IS F311
Computer Graphics
Date: 23/09/14
Objective: Understanding how to build an interactive graphics application. In this tutorial we will see
how one can use the mouse for interacting with the scene.
#include <windows.h>
#include <GL/glut.h>
//struct to store (x,y)
struct GLintPoint{
GLint x,y;
};
//corners of a rectangle
GLintPoint corner[2];
//global variables
bool selected = false;
bool closed = false;
int screenwidth = 640, screenheight = 480;
//setting up projection matrix
void myinit(void)
{
glClearColor(0.7, 0.7, 0.7, 0.0); /* gray background */
glMatrixMode(GL_PROJECTION);
/* In World coordinates: */
glLoadIdentity();
gluOrtho2D( 0, screenwidth, 0, screenheight);
glMatrixMode(GL_MODELVIEW);
}