Esempio n. 1
0
GLUSboolean updateGame(GLUSfloat deltaTime)
{
	if (!updateEngine(deltaTime))
	{
		return GLUS_FALSE;
	}

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	ProgramManagerProxy::setCameraByType(ProgramManager::DEFAULT_PROGRAM_TYPE, CameraManager::getInstance()->getDefaultPerspectiveCamera(), Point4(), Quaternion());

	GeneralEntity::setCurrentValues(ProgramManager::DEFAULT_PROGRAM_TYPE, CameraManager::getInstance()->getDefaultPerspectiveCamera(), deltaTime, false);

	GeneralEntityManager::getInstance()->update();
	GeneralEntityManager::getInstance()->sort();

	PostProcessor2DSP postProcessor = PostProcessor2DManager::getInstance()->getPostProcessor("PostProcessor");
	postProcessor->use(true);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	SkyManager::getInstance()->getActiveSky()->render(CameraManager::getInstance()->getDefaultPerspectiveCamera()->getEye());
	GeneralEntityManager::getInstance()->render();

	postProcessor->render();

	FpsPrinter::printer.print(deltaTime);

	//

	FontSP font = FontManager::getInstance()->getFont("CourierNew");
	font->print(700.0f, 10.0f, Color::RED, "Toggle bloom:       [n]");
	font->print(700.0f, 25.0f, Color::RED, "Bloom:              %s", postProcessor->isUseBloom() ? "On" : "Off");
	font->print(700.0f, 40.0f, Color::RED, "Toggle blur:        [b]");
	font->print(700.0f, 55.0f, Color::RED, "Blur:               %s", postProcessor->isUseBlur() ? "On" : "Off");
	font->print(700.0f, 70.0f, Color::RED, "Toggle exposure:    [e]");
	font->print(700.0f, 85.0f, Color::RED, "Dec./Inc. exposure: [r]/[t]");
	font->print(700.0f, 100.0f, Color::RED, "Exposure:           %s %.1f", postProcessor->isUseExposure() ? "On" : "Off", postProcessor->getExposure());
	font->print(700.0f, 115.0f, Color::RED, "Toggle gamma:       [g]");
	font->print(700.0f, 130.0f, Color::RED, "Dec./Inc. gamma:    [h]/[j]");
	font->print(700.0f, 145.0f, Color::RED, "Gamma correction:   %s %.1f", postProcessor->isUseGamma() ? "On" : "Off", postProcessor->getGamma());
	font->print(700.0f, 160.0f, Color::RED, "Set environment:    [1][2][3]");

	return GLUS_TRUE;
}
Esempio n. 2
0
GLUSboolean updateGame(GLUSfloat deltaTime)
{
	if (!updateEngine(deltaTime))
	{
		return GLUS_FALSE;
	}

	updateInput(deltaTime);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	ProgramManagerProxy::setCameraByType(ProgramManager::DEFAULT_PROGRAM_TYPE, CameraManager::getInstance()->getDefaultPerspectiveCamera());

	ModelEntity::setCurrentValues(ProgramManager::DEFAULT_PROGRAM_TYPE, CameraManager::getInstance()->getDefaultPerspectiveCamera(), deltaTime, false);

	ModelEntityManager::getInstance()->updateMetrics();
	ModelEntityManager::getInstance()->sort();
	ModelEntityManager::getInstance()->update();

	//
	PostProcessorSP postProcessor;

	if (useMultisample)
	{
		postProcessor = PostProcessor2DMultisampleManager::getInstance()->getPostProcessor("PostProcessorMultisample");
	}
	else
	{
		postProcessor = PostProcessor2DManager::getInstance()->getPostProcessor("PostProcessor");
	}

	postProcessor->use(true);

	glEnable(GL_MULTISAMPLE);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	// Debug output of the ground plane
	groundPlane.draw(CameraManager::getInstance()->getDefaultPerspectiveCamera()->getEye(), Color::GREY);

	SkyManager::getInstance()->getActiveSky()->render(CameraManager::getInstance()->getDefaultPerspectiveCamera()->getEye());
	ModelEntityManager::getInstance()->render();

	postProcessor->render();

	// No MSAA for the text

	glDisable(GL_MULTISAMPLE);

	FpsPrinter::printer.print(deltaTime);

	//

	FontSP font = FontManager::getInstance()->getFont("CourierNew");
	font->print(690.0f, 10.0f, Color::RED, "Toggle MSAA:              [m]");
	font->print(690.0f, 25.0f, Color::RED, "MSAA:                     %s", useMultisample ? "On" : "Off");
	font->print(690.0f, 40.0f, Color::RED, "Toggle DoF:               [f]");
	font->print(690.0f, 55.0f, Color::RED, "Depth of Field:           %s", useDepthOfField ? "On" : "Off");
	font->print(690.0f, 70.0f, Color::RED, "Dec./Inc. aperture:       [1]/[2]");
	font->print(690.0f, 85.0f, Color::RED, "Aperture:                 %.1f", aperture);
	font->print(690.0f, 100.0f, Color::RED, "Dec./Inc. focal:          [3]/[4]");
	font->print(690.0f, 115.0f, Color::RED, "Focal:                    %.1f", focal);
	font->print(690.0f, 130.0f, Color::RED, "Dec./Inc. focused object: [5]/[6]");
	font->print(690.0f, 145.0f, Color::RED, "Focused object:           %.1f", focusedObject);

	return GLUS_TRUE;
}
Esempio n. 3
0
GLUSboolean updateGame(GLUSfloat deltaTime)
{
	//string currentProgramType = ProgramManager::RENDER_TO_SHADOWMAP_PROGRAM_TYPE;
	string currentProgramType = ProgramManager::DEFAULT_PROGRAM_TYPE;

	if (!updateEngine(deltaTime))
	{
		return GLUS_FALSE;
	}

	// Update everything

	GeneralEntityManager::getInstance()->update();

	//
	// Shadow part
	//

	GeneralEntity::setCurrentValues(ProgramManager::RENDER_TO_SHADOWMAP_PROGRAM_TYPE, orthographicCameraShadowMap2D->getOrthographicCamera(), deltaTime, false);

	// Camera

	modelEntity->setOrthographicShadowCamera("Lamp", orthographicCameraShadowMap2D);

	orthographicCameraShadowMap2D->updateShadowMatrix();

	// Lights, not used, so set to zero lights.

	ProgramManagerProxy::setNumberLightsByType(ProgramManager::RENDER_TO_SHADOWMAP_PROGRAM_TYPE, 0);
	ProgramManagerProxy::setAmbientLightColorByType(ProgramManager::RENDER_TO_SHADOWMAP_PROGRAM_TYPE);
	ProgramManagerProxy::setNoShadowByType(ProgramManager::RENDER_TO_SHADOWMAP_PROGRAM_TYPE);

	//

	GeneralEntityManager::getInstance()->sort();

	//

	orthographicCameraShadowMap2D->use(true);

	glClear(GL_DEPTH_BUFFER_BIT);

	// All the primitves

    glEnable(GL_POLYGON_OFFSET_FILL);
    glFrontFace(GL_CW);

	GeneralEntityManager::getInstance()->render();

    glDisable(GL_POLYGON_OFFSET_FILL);
    glFrontFace(GL_CCW);

	orthographicCameraShadowMap2D->use(false);

	//
	// Color rendering
	//

	ViewportSP defaultViewport = ViewportManager::getInstance()->getDefaultViewport();
	defaultViewport->use();

	GeneralEntity::setCurrentValues(currentProgramType, currentCamera, deltaTime, false);

	// Camera

	if (User::defaultUser.getUserCamera().get())
	{
		ProgramManagerProxy::setCameraByType(currentProgramType, currentCamera, Point4(), Quaternion());
	}
	else
	{
		modelEntity->setCamera("Camera");
	}

	// Lights

	int32_t numberLights = 0;
	numberLights = modelEntity->setLights(numberLights);
	ProgramManagerProxy::setNumberLightsByType(currentProgramType, numberLights);
	ProgramManagerProxy::setAmbientLightColorByType(currentProgramType);
	ProgramManagerProxy::setNoShadowByType(currentProgramType);

	ProgramManagerProxy::setShadowByType(currentProgramType, 0, orthographicCameraShadowMap2D->getShadowMap2D(), orthographicCameraShadowMap2D->getShadowMatrix(), 0);

	//

	GeneralEntityManager::getInstance()->sort();

	//

	glClearColor(0.9f, 0.9f, 0.9f, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	// All the primitves

	GeneralEntityManager::getInstance()->render();

	//
	// Debug
	//

	if (drawDebug)
	{
		CameraManager::getInstance()->getDefaultPerspectiveCamera()->debugDraw(Point4(), Quaternion());
	}

	//

	// Debug plane

	groundPlane.draw(currentCamera->getEye(), Color::GREY);

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	// FPS

	FpsPrinter::printer.print(deltaTime);

	// Debug Menu

	FontSP font = FontManager::getInstance()->getFont("CourierNew");
	font->print(760.0f, 10.0f, Color::RED, "Toggle camera:    [c]");

	return GLUS_TRUE;
}