Example #1
0
	virtual void onKeyboardButtonPressed(Keyboard& source, const KeyboardEvent& e) {
		if(e.getButton() == KeyboardButtonType::KEY_F1) {
			std::cout << "Camera Position:" << std::endl <<
						 "          X: " << camera->position.x << std::endl <<
						 "          Y: " << camera->position.y << std::endl <<
						 "          Z: " << camera->position.z << std::endl <<
						 " X Rotation: " << camera->rotation.x << std::endl <<
						 " Y Rotation: " << camera->rotation.y << std::endl;
		}

		if(e.getButton() == KeyboardButtonType::KEY_F) {
			if(cameraLight->diffuse.r == 0) {
				cameraLight->diffuse = Color(1, 1, 1, 1);
			} else {
				cameraLight->diffuse = Color(0, 0, 0, 0);
			}
		}
		

		if(source.isPressed(KeyboardButtonType::KEY_CONTROL)) {
			if(e.getButton() == KeyboardButtonType::KEY_ADD) {
				this->setSize(this->getWidth() + 16, this->getHeight() + 12);
				std::cout << "Window enlarged!" << std::endl;

			} else if(e.getButton() == KeyboardButtonType::KEY_SUBTRACT) {
				this->setSize(this->getWidth() - 16, this->getHeight() - 12);
				std::cout << "Window shrinked!" << std::endl;

			} else if(e.getButton() == KeyboardButtonType::KEY_R) {
				this->setResizable(!this->isResizable());
				std::cout << "This window is " <<
					(this->isResizable() ? "now resizable." : "not resizable anymore.") <<
					std::endl;

			} else if(e.getButton() == KeyboardButtonType::KEY_I) {
				this->showWindowInformation();

			} else if(e.getButton() == KeyboardButtonType::KEY_Q) {
				showHelp();

			} else if(e.getButton() == KeyboardButtonType::KEY_X) {
				this->close();
				std::cout << "Window closed!" << std::endl;

			} else if(e.getButton() == KeyboardButtonType::KEY_H) {
				if(other == NULL) {
					std::cout <<
						"Can't hide the window, reason: There is no other window!" << std::endl <<
						"Use CTRL+X to close this window." << std::endl;
				} else if(!other->isVisible()) {
					std::cout <<
						"Can't hide the window, reason: The other window is not visible!" <<
						std::endl << "Use CTRL+S to show the other window." << std::endl;
				} else {
					this->hide();
					std::cout << "Window hidden!" << std::endl;
				}

			} else if(e.getButton() == KeyboardButtonType::KEY_S) {
				if(other == NULL) {
					std::cout << "Can't show the other window, reason: There is no other window!" <<
						std::endl;
				} else {
					other->show();
					std::cout << "Showing the other window!" << std::endl;
				}
			}
		}
	}