2014-12-15 16:47:30 +01:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* 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_shader.loadFromFile("shaders/game.v.glsl", "shaders/game.f.glsl");
|
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
Shader::bind(&m_shader);
|
2014-12-15 16:47:30 +01:00
|
|
|
|
2014-12-23 16:15:44 +01:00
|
|
|
m_projectionMatrix = glm::perspective(45.0f, 640.0f / 480.0f, 0.1f, float(World::renderDistance * Chunk::width));
|
2014-12-18 07:02:48 +01:00
|
|
|
m_viewMatrix = m_camera.update();
|
2014-12-15 16:47:30 +01:00
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
m_shader.setUniform("u_tex", 0);
|
2014-12-15 16:47:30 +01:00
|
|
|
|
|
|
|
Shader::bind(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
GameState::~GameState() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameState::update() {
|
2014-12-18 07:02:48 +01:00
|
|
|
m_viewMatrix = m_camera.processInputs();
|
2014-12-15 16:47:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GameState::draw() {
|
|
|
|
Shader::bind(&m_shader);
|
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
m_world.draw(m_shader, m_projectionMatrix * m_viewMatrix);
|
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
Shader::bind(nullptr);
|
|
|
|
}
|
|
|
|
|