Exemplo n.º 1
0
/**
 * Method for drawing the scene
 */
void Scene::drawScene()
{
	glClear(GL_COLOR_BUFFER_BIT);			// Erase the screen
	glClear(GL_DEPTH_BUFFER_BIT);			// Erase the z-buffer

	for(int i = 0; i < this->objects.size(); i++)
	{
		drawObject(this->objects[i]);
	}

	// Display the reference x y z
	drawRepere();

	glutSwapBuffers();		// switch active window and work window
}
Exemplo n.º 2
0
void display()
{
	glEnable(GL_DEPTH_TEST);
	glDepthMask(GL_TRUE);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	if(dim==DIM2)	glOrtho(-1,1,-1,1,-1,1);
	else{
		gluPerspective( 40, (float)width/height, 1, 100);
		glTranslatef(p_aim.x, p_aim.y, p_aim.z);
		glRotatef(theta, 1, 0, 0);
		glRotatef(phi, 0, 1, 0);
	}

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	// Dessiner ici
	// ...
	if (P_isConvex(P)) {
		//si p est convex couleur rouge
		glColor3d(1,0,0);
	} 
	else {
		//sinon de couleur bleue
		glColor3d(0,0,1);
	}

	if(dim==DIM2) {
		P_draw(P, width, height);
	}
	//en dimension 3
	else {
		M_draw(M);
	}


	// Repere du monde

	drawRepere();

	glutSwapBuffers();
}