#undef EXIT_WITH_ERROR_IF
}
-/*
-static const char* sgl__parse_name(const char* string, sgl_arg_p option) {
- const char* c = string;
- if (c == NULL || *c == '\0')
- return NULL;
-
- // Skip whitespaces
- while( sgl__is_whitespace(*c) )
- c++;
-
- // Read the name into the name buffer and add the zero-terminator
- size_t offset = 0;
- while ( sgl__is_name(*c) ) {
- if (offset >= sizeof(option->name) - 1) {
- option->error_at = c;
- option->error_message = "Name is to long";
- return NULL;
- }
- option->name[offset++] = *c++;
- }
- option->name[offset] = '\0';
-
- // Only return the end position if we actually succeeded in reading a name. That is:
- // - We read more than 0 characters and
- // - the current end pos points to a whitespace or zero terminator
- // Otherwise we're stuck inside or at the start of a name and got an invalid character.
- if ( offset > 0 && (sgl__is_whitespace(*c) || *c == '\0') )
- return c;
- else {
- option->error_at = c;
- option->error_message = "Got invalid character in name";
- return NULL;
- }
-}
-
-static const char* sgl__parse_directive(const char* string, sgl_arg_p option) {
- const char* c = string;
- if (c == NULL)
- return NULL;
-
- // Skip whitespaces
- while( sgl__is_whitespace(*c) )
- c++;
-
- if (*c == ';') {
- option->type = *c++;
- return c;
- } else if (*c == '%') {
- c++;
- // Read all following chars as modifiers (including the last one for now)
- size_t offset = 0;
- while ( !(sgl__is_whitespace(*c) || *c == '\0') ) {
- if (offset >= sizeof(option->modifiers)) {
- option->error_at = c;
- option->error_message = "To many modifiers for directive";
- return NULL;
- }
- option->modifiers[offset++] = *c++;
- }
-
- if (offset < 1) {
- option->error_at = c;
- option->error_message = "At least one character is necessary after a '%'";
- return NULL;
- }
-
- // The last char in the modifiers buffer is our type so put it into the type field. Then overwrite the last char
- // with the zero terminator.
- option->type = option->modifiers[offset-1];
- option->modifiers[offset-1] = '\0';
-
- return c;
- } else {
- option->error_at = c;
- option->error_message = "Expected '%' at start of directive or a ';' directive";
- return NULL;
- }
-}
-*/
-
-
-/*
-GLuint sgl_program_new(const char* args, ...) {
- directive_t directive;
-
- while ( (args = next_directive(args, &directive)) != NULL ) {
-
- }
-
- char *c = args, *start = NULL, *end = NULL;
- while(*c != '\0') {
- switch(*c) {
- case '%':
- c++;
- start = c;
- while()
- break;
- case ' ': case '\f': case '\n': case '\r': case '\t': case '\v':
- // Ignore whitespaces
- break;
- default:
- // error: unknown character in args parameter
- break;
- }
- c++;
- }
-}
-*/
GLuint sgl_program_from_files(const char* vertex_shader_file, const char* fragment_shader_file, char** compiler_errors) {
char* vertex_shader_code = sgl_fload(vertex_shader_file, NULL);