Last active
August 29, 2015 14:06
-
-
Save terryjsmith/79031ddc95f8266d813b to your computer and use it in GitHub Desktop.
RenderSystem Implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <GL/glew.h> | |
#include <GLFW/glfw3.h> | |
#include <glm/glm.hpp> | |
#include <glm/gtc/quaternion.hpp> | |
#include <error.h> | |
#include <component.h> | |
#include <system.h> | |
#include <rendersystem.h> | |
#include <renderable.h> | |
RenderSystem::RenderSystem() { | |
m_window = 0; | |
} | |
RenderSystem::~RenderSystem() { | |
} | |
void RenderSystem::Initialize() { | |
// Initialize GLEW | |
GLenum err = glewInit(); | |
if (GLEW_OK != err) { | |
Error::Create(ERROR_FATAL, "Unable to initialize GLEW"); | |
return; | |
} | |
// Hint at the version we should be using | |
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); | |
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); | |
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); | |
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); | |
// Initialize GLFW | |
if (!glfwInit()) { | |
Error::Create(ERROR_FATAL, "Unable to initialize GLFW."); | |
return; | |
} | |
} | |
void RenderSystem::Shutdown() { | |
glfwTerminate(); | |
} | |
void RenderSystem::CreateWindow(unsigned int width, unsigned int height, char* name, bool fullscreen) { | |
// Save state | |
m_windowWidth = width; | |
m_windowHeight = height; | |
m_fullscreen = fullscreen; | |
// Create our window using GLFW | |
m_window = glfwCreateWindow(width, height, name, fullscreen ? glfwGetPrimaryMonitor() : NULL, NULL); | |
if(!m_window) { | |
Error::Create(ERROR_FATAL, "Unable to create main application window."); | |
return; | |
} | |
// Get ready to use OpenGL | |
glfwMakeContextCurrent(m_window); | |
} | |
void RenderSystem::Update(float elapsed) { | |
// Loop through all of our renderables and render them | |
for(int i = 0; i < m_bucketSize; i++) { | |
if(m_components[i]) { | |
} | |
} | |
// Swap OpenGL buffers | |
glfwSwapBuffers(m_window); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment