Exemple #1
0
void ReshapeGL (int width, int height)									// Reshape The Window When It's Moved Or Resized
{
	glViewport (0, 0, (GLsizei)(width), (GLsizei)(height));				// Reset The Current Viewport
	glMatrixMode (GL_PROJECTION);										// Select The Projection Matrix
	glLoadIdentity ();													// Reset The Projection Matrix
	gluPerspective (45.0f, (GLfloat)(width)/(GLfloat)(height),			// Calculate The Aspect Ratio Of The Window
					1.0f, 100.0f);		
	glMatrixMode (GL_MODELVIEW);										// Select The Modelview Matrix
	glLoadIdentity ();													// Reset The Modelview Matrix

    ArcBall.setBounds((GLfloat)width, (GLfloat)height);                 //*NEW* Update mouse bounds for arcball
}
Exemple #2
0
GLvoid ReSizeGLScene(GLsizei width, GLsizei height)		// Resize And Initialize The GL Window
{
	double ymax, ymin, xmax, xmin = 0;
	if (height==0)										// Prevent A Divide By Zero By
	{
		height=1;										// Making Height Equal One
	}

	glViewport(0,0,width,height);						// Reset The Current Viewport

	glMatrixMode(GL_PROJECTION);						// Select The Projection Matrix
	glLoadIdentity();		
	
	ymax = 0.1f * tan(45.0f * M_PI / 360.0);
	ymin = -ymax;
	xmin = ymin * (GLfloat)width/(GLfloat)height;
	xmax = ymax * (GLfloat)width/(GLfloat)height;
	glFrustum(xmin, xmax, ymin, ymax, 0.1f, 5000.0f);
	//glFrontFace(GL_CW);
	glMatrixMode(GL_MODELVIEW);							// Select The Modelview Matrix
	glLoadIdentity();									// Reset The Modelview Matrix
	ArcBall.setBounds(width, height);
}