Esempio n. 1
0
void GLScene::paintGL ()
{
	//set background color
	//glClearColor(m_background[0], m_background[1], m_background[2], m_background[3]);
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	//NOTE: 
	glMatrixMode(GL_MODELVIEW);		// Drawing perspective
	glLoadIdentity();				// Reset camera position
	
	//Camera Mode Lighting
	glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 1.0f);
	
	// Add ambient light
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, m_ambientColor.c_array());
	
	// Adjust for camera position
	Camera.Render();
	
	//Add light
	const GLfloat lightColor0[] = {0.5f, 0.2f, 0.2f, 1.0f};
	const GLfloat lightPos0[] = {5.0f, 0.0f, -5.0f, 1.0f};
	//GLfloat lightPos0[] = {Camera.Position.x, Camera.Position.y, Camera.Position.z, 1.0f};
	glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0);
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, lightColor0);

	//Add light
	GLfloat lightColor1[] = {0.2f, 0.5f, 0.2f, 1.0f};
	GLfloat lightPos1[] = {10.0f, 10.0f, 5.0f, 1.0f};
	glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1);
	glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, lightColor1);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, lightColor1);
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 20.0f);

	
	// Draw maze
	RenderMaze();
}
Esempio n. 2
0
void GameScene::RenderObjects()
{
	RenderMaze();
	RenderBall();
}