This file contains 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
template<class T> | |
class Resource { | |
public: | |
Resource(); | |
~Resource(); | |
public: | |
char* filename; | |
T resource; | |
This file contains 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 <string.h> | |
template<class T> | |
class Loader { | |
public: | |
Loader(); | |
~Loader(); | |
// Load a resource from a filename | |
T Find(char* filename); |
This file contains 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 ShaderLoader : public Loader<int> { | |
public: | |
// Load the shaders (don't give the file extension) | |
int Load(char* shader); | |
public: | |
static ShaderLoader* GetInstance(); | |
}; |
This file contains 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
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 |
This file contains 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
enum { | |
ERROR_NONE, | |
ERROR_DEBUG, | |
ERROR_INFO, | |
ERROR_WARN, | |
ERROR_FATAL | |
}; | |
class Error { | |
public: |
This file contains 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 = ""; |
This file contains 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 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 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 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: |