Skip to content

Instantly share code, notes, and snippets.

@gszauer
Last active August 29, 2015 14:04
Show Gist options
  • Save gszauer/1e527f7a0c866bb6c984 to your computer and use it in GitHub Desktop.
Save gszauer/1e527f7a0c866bb6c984 to your computer and use it in GitHub Desktop.
ShaderForge Base
struct ShaderObject {
GLuint shaderObject;
SateBlock stateBlock;
std::vector<ShaderProp> publicProperties;
};
char* CompileShader(char* string) {
int numTokens = 0;
char** tokens = new char[][];
// Remove #version!
int i = 0, len = strlen(string);
while (i < len) {
if (string[i] == '#') { // Skip lines starting with #
// TODO: #include, #define?
while(string[i] != '\n') // Read to end of line
string[i++] = '\0'; // Clear character
string[i++] = '\0'; // Clear newline
}
// Eliminate any seperator characters, record where every token starts
if (string[i] == ' ' || string[i] == ',' || string[i] == '\t' || string[i] == '\n') {
while (string[i] == ' ' || string[i] == ',' || string[i] == '\t' || string[i] == '\n')
string[i++] = '\0';
tokens[numTokens++] = string[i] + 1;
}
}
// TODO: Process meta-tokens (IE @ symbols)
// List of meta-tokens:
// @enable: enable / disable state machine feature (zwrite, depth test, blend func, etc...)
// @blendFunc: set the blend function
// @queue: integer, what render queue does this shader belong to
// @light: what function will the lighting be mapped to
// @ps_main: what function will the pixel shader be mapped to
// @vs_main: what function will the vertex shader be mapped to
// @public: marks a uniform as editable, followed by a type (range, texture, etc...)
// TODO: Build final custom shader (allocate memory, skip trough strings, etc...)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment