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
void RenderSystem::Update(float elapsed) { | |
// Clear the screen | |
glClearColor(0.0, 0.0f, 0.0f, 1.0f); | |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
// Update our camera info | |
glm::mat4 view = glm::lookAt(m_camera->translation, m_camera->translation + m_camera->look, m_camera->up); | |
glm::mat4 projection = glm::perspective(glm::radians(m_camera->fov), m_camera->aspect, m_camera->fnear, m_camera->ffar); | |
// Loop through all of our renderables and render them |
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
#define GLM_FORCE_RADIANS | |
#include <glm/glm.hpp> | |
#include <glm/gtc/quaternion.hpp> | |
#include <glm/gtx/quaternion.hpp> | |
#include <camera.h> | |
Camera::Camera() { | |
translation = glm::vec3(0.0f, 0.0f, 0.0f); |
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
class Camera { | |
public: | |
Camera(); | |
~Camera(); | |
public: | |
// Change translation | |
void SetTranslation(float x, float y, float z); | |
void Move(float x, float y, float z); | |
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
// Once we get here, it's time to figure out which attributes and uniforms we have | |
GLint activeAttribs = 0; | |
GLint activeUniforms = 0; | |
glGetProgramiv(p, GL_ACTIVE_ATTRIBUTES, &activeAttribs); | |
glGetProgramiv(p, GL_ACTIVE_UNIFORMS, &activeUniforms); | |
// Start with the uniform variables | |
for(int i = 0; i < activeUniforms; i++) { | |
int size = 0; | |
int length = 0; |
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 <shaderprogram.h> | |
#include <GL/glew.h> | |
#include <GLFW/glfw3.h> | |
#include <string.h> | |
#include <stdlib.h> | |
ShaderProgram::ShaderProgram() { | |
program = 0; | |
m_list = 0; | |
} |
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
struct ShaderVariable { | |
char* name; | |
int location; | |
bool uniform; | |
ShaderVariable* next; | |
}; | |
class ShaderProgram { | |
public: |
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
int main(int argc, char** argv) { | |
/* INITIALIZATION */ | |
g_renderSystem = new RenderSystem(); | |
g_renderSystem->Initialize(); | |
g_renderSystem->CreateWindow(800, 600, "Evolution", false); | |
/* START CODE TO CREATE TRIANGLE - THIS WILL HAPPEN IN A LOADER LATER */ | |
// Let's create our first renderable entity |
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
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]) { | |
// Cast to a Renderable we can use | |
Renderable* component = (Renderable*)m_components[i]; | |
// Bind the vertex attribute object, which will bind the buffers and attributes for us | |
glBindVertexArray(component->vertexAttribObject); | |
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
class Renderable : public Component { | |
public: | |
Renderable(); | |
~Renderable(); | |
public: | |
// Position in world space | |
glm::vec3 position; | |
// Local rotation |
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
Error::Error() { | |
} | |
Error::~Error() { | |
} | |
void Error::Create(unsigned short type, char *message) { | |
std::string output = ""; |