Skip to content

Instantly share code, notes, and snippets.

View terryjsmith's full-sized avatar

Terry Smith terryjsmith

View GitHub Profile
@terryjsmith
terryjsmith / resource.h
Created September 28, 2014 19:12
Evolution Resource class
template<class T>
class Resource {
public:
Resource();
~Resource();
public:
char* filename;
T resource;
@terryjsmith
terryjsmith / loader.h
Created September 28, 2014 19:17
Loader base class
#include <string.h>
template<class T>
class Loader {
public:
Loader();
~Loader();
// Load a resource from a filename
T Find(char* filename);
@terryjsmith
terryjsmith / shaderloader.h
Created September 28, 2014 19:22
Evolution ShaderLoader class
class ShaderLoader : public Loader<int> {
public:
// Load the shaders (don't give the file extension)
int Load(char* shader);
public:
static ShaderLoader* GetInstance();
};
@terryjsmith
terryjsmith / shaderloader.cpp
Created September 28, 2014 19:26
Evolution ShaderLoader implementation
ShaderLoader* ShaderLoader::GetInstance() {
if(!m_instance) {
m_instance = new ShaderLoader();
}
return((ShaderLoader*)m_instance);
}
int ShaderLoader::Load(char* shader) {
// Try to find the shader program in our resource cache first
@terryjsmith
terryjsmith / error.h
Created September 28, 2014 19:57
Evolution Error class
enum {
ERROR_NONE,
ERROR_DEBUG,
ERROR_INFO,
ERROR_WARN,
ERROR_FATAL
};
class Error {
public:
@terryjsmith
terryjsmith / error.cpp
Created September 28, 2014 19:58
Evolution Error implementation
Error::Error() {
}
Error::~Error() {
}
void Error::Create(unsigned short type, char *message) {
std::string output = "";
@terryjsmith
terryjsmith / renderable.h
Created September 28, 2014 20:25
Evolution Renderable class v1.1
class Renderable : public Component {
public:
Renderable();
~Renderable();
public:
// Position in world space
glm::vec3 position;
// Local rotation
@terryjsmith
terryjsmith / rendersystem.cpp
Created September 28, 2014 20:27
Evolution RenderSystem 1.1
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);
@terryjsmith
terryjsmith / main.cpp
Created September 28, 2014 20:30
Evolution 1.1 Main Loop
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
@terryjsmith
terryjsmith / shaderprogram.h
Created October 5, 2014 23:19
Evolution ShaderProgram class
struct ShaderVariable {
char* name;
int location;
bool uniform;
ShaderVariable* next;
};
class ShaderProgram {
public: