OpenMiner/source/states/GameState.cpp
2014-12-26 00:39:10 +01:00

53 lines
1.2 KiB
C++

/*
* =====================================================================================
*
* Filename: GameState.cpp
*
* Description:
*
* Version: 1.0
* Created: 15/12/2014 03:51:55
* Revision: none
* Compiler: gcc
*
* Author: Quentin BAZIN, <quent42340@gmail.com>
* Company:
*
* =====================================================================================
*/
#define GLM_FORCE_RADIANS
#include <glm/gtc/matrix_transform.hpp>
#include "GameState.hpp"
GameState::GameState() : m_camera(Camera::getInstance()) {
m_shader.loadFromFile("shaders/game.v.glsl", "shaders/game.f.glsl");
Shader::bind(&m_shader);
m_projectionMatrix = glm::perspective(45.0f, 640.0f / 480.0f, 0.1f, 1000.0f);
m_viewMatrix = m_camera.update();
m_shader.setUniform("u_tex", 0);
Shader::bind(nullptr);
}
GameState::~GameState() {
}
void GameState::update() {
m_viewMatrix = m_camera.processInputs();
}
void GameState::draw() {
Shader::bind(&m_shader);
m_skybox.draw(m_shader, m_projectionMatrix * m_viewMatrix);
m_world.draw(m_shader, m_projectionMatrix * m_viewMatrix);
Shader::bind(nullptr);
}