Ejemplo n.º 1
0
bool handleEvents(Window &wnd, LightPtr light)
{
	Event evt;
	while (wnd.pollEvent(evt))
	{
		switch(evt.type)
		{
		case Event::Closed:
			return true;
			break;

		case Event::KeyPressed:
			switch(evt.key.code)
			{
			case Keyboard::Escape:
				return true;
				break;

			case Keyboard::F1:
				DemoSettings::DrawOccluders = !DemoSettings::DrawOccluders;
				break;

			case Keyboard::F2:
				DemoSettings::EnableLightsDebugDraw = !DemoSettings::EnableLightsDebugDraw;
				break;

			case Keyboard::F3:
				DemoSettings::EnableShadowsOutline = !DemoSettings::EnableShadowsOutline;
				break;
			}
			break;

		case Event::MouseMoved:
			if (DemoSettings::EnableManualLight || DemoSettings::EnableOnlyManualLight)
				light->setPosition(Vector2f(static_cast<float>(evt.mouseMove.x),
									        static_cast<float>(evt.mouseMove.y)));
			break;

		case Event::MouseWheelMoved:
			if (DemoSettings::EnableManualLight || DemoSettings::EnableOnlyManualLight)
				light->getRadius() += evt.mouseWheel.delta * DemoSettings::WheelFactorToLightRad;
			break;
		}
	}

	return false;
}