WIP (Really really broken tho)

This commit is contained in:
Tobias Dahl
2014-03-07 19:07:07 +01:00
parent 95a36794e3
commit 1f48279bc6
7 changed files with 88 additions and 129 deletions
+14 -35
View File
@@ -11,53 +11,32 @@
#include "World.h"
class Engine
{
public:
Engine(int argc, char* argv[])
{
// Initialize GLFW
if (!glfwInit()) {
LOG_ERROR("GLFW: Initialization failed");
exit(EXIT_FAILURE);
}
// Create a window
m_Window = glfwCreateWindow(1280, 720, "OpenGL", nullptr, nullptr);
if (!m_Window) {
LOG_ERROR("GLFW: Failed to create window");
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(m_Window);
// GL version info
glGetIntegerv(GL_MAJOR_VERSION, &glVersion[0]);
glGetIntegerv(GL_MINOR_VERSION, &glVersion[1]);
glVendor = (GLchar*)glGetString(GL_VENDOR);
std::stringstream ss;
ss << glVendor << " OpenGL " << glVersion[0] << "." << glVersion[1];
#ifdef DEBUG
ss << " DEBUG";
#endif
LOG_INFO(ss.str().c_str());
glfwSetWindowTitle(m_Window, ss.str().c_str());
// Initialize GLEW
if (glewInit() != GLEW_OK) {
LOG_ERROR("GLEW: Initialization failed");
exit(EXIT_FAILURE);
}
renderer.Initialize();
m_LastTime = glfwGetTime();
}
bool Running() const { return !glfwWindowShouldClose(m_Window); }
bool Running() const { return !glfwWindowShouldClose(renderer.GetWindow()); }
void Tick()
{
double currentTime = glfwGetTime();
double dt = currentTime - m_LastTime;
m_LastTime = currentTime;
//World.Update(dt);
renderer.Draw(dt);
glfwPollEvents();
}
private:
GLFWwindow* m_Window;
GLint glVersion[2];
GLchar* glVendor;
Renderer renderer;
double m_LastTime;
};