Created
February 2, 2014 07:03
-
-
Save nikki93/8764030 to your computer and use it in GitHub Desktop.
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 "gfx.h" | |
#include <stdlib.h> | |
#include <stdio.h> | |
static void _compile_shader(GLuint shader, const char *filename) | |
{ | |
char *file_contents, log[512]; | |
long input_file_size; | |
FILE *input_file; | |
GLint status; | |
input_file = fopen(filename, "rb"); | |
fseek(input_file, 0, SEEK_END); | |
input_file_size = ftell(input_file); | |
rewind(input_file); | |
file_contents = malloc((input_file_size + 1) * (sizeof(char))); | |
fread(file_contents, sizeof(char), input_file_size, input_file); | |
fclose(input_file); | |
file_contents[input_file_size] = '\0'; | |
printf("text: compiling shader '%s' ...", filename); | |
glShaderSource(shader, 1, (const GLchar **) &file_contents, NULL); | |
glCompileShader(shader); | |
free(file_contents); | |
/* log */ | |
glGetShaderiv(shader, GL_COMPILE_STATUS, &status); | |
printf(status ? " successful\n" : " unsuccessful\n"); | |
glGetShaderInfoLog(shader, 512, NULL, log); | |
printf("%s", log); | |
} | |
GLuint gfx_create_program(const char *vert_path, | |
const char *geom_path, | |
const char *frag_path) | |
{ | |
GLuint vert, geom, frag; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment