OpenMiner/source/core/Application.cpp
Quentin Bazin fb3f7f0501 Lot of changes. [...]
[Renderer] Deleted, code moved to Application.
[Transformable] Transformations are now applied to model matrix in applyTransform.
[ResourceHandler|TextureLoader|XMLFile] Added.
[Debug|Exception] Updated.
2018-06-21 05:45:17 +02:00

63 lines
1.3 KiB
C++

/*
* =====================================================================================
*
* Filename: Application.cpp
*
* Description:
*
* Created: 14/12/2014 05:09:21
*
* Author: Quentin Bazin, <quent42340@gmail.com>
*
* =====================================================================================
*/
#include "Application.hpp"
#include "Config.hpp"
#include "Mouse.hpp"
#include "TextureLoader.hpp"
#include "GameState.hpp"
void Application::init() {
CoreApplication::init();
createWindow(SCREEN_WIDTH, SCREEN_HEIGHT, APP_NAME);
m_window.setVerticalSyncEnabled(true);
initOpenGL();
Mouse::setCursorVisible(false);
Mouse::setCursorGrabbed(true);
m_resourceHandler.loadConfigFile<TextureLoader>("resources/config/textures.xml");
m_stateStack.push<GameState>();
}
void Application::initOpenGL() {
#ifdef __MINGW32__
if(glewInit() != GLEW_OK) {
throw EXCEPTION("glew init failed");
}
#endif
// FIXME: Water transparency is fkin buggy...
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glBlendEquation(GL_FUNC_ADD);
// glEnable(GL_ALPHA_TEST);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1, 1);
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
glClearColor(0.196078, 0.6, 0.8, 1.0); // Skyblue
}