ShaderTool
0.1
Live tool for developing OpenGL shaders interactively
|
#include <GL/glew.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/inotify.h>
#include "log.h"
#include "renderer.h"
#include "shaders.h"
Functions | |
int | initialize_shaders (struct renderer_state *state, const char *shader_file, const char *buffer_file, int texture_width, int texture_height) |
Initialize shaders, compile them, and create the required texture for the buffer shader. More... | |
int | compile_shaders (unsigned int *shader_program, const char *const fragment_shader_file) |
Compile shaders from source files. More... | |
char * | read_file (const char *const filename) |
Reads a file in a heap-allocated buffer. More... | |
int compile_shaders | ( | unsigned int * | shader_program, |
const char *const | fragment_shader_file | ||
) |
Compile shaders from source files.
This function reads the source files of the vertex and fragment shaders, compiles them, and links them together in a shader program.
shader_program | Pointer to the ID of the shader program where the shaders will be stored. |
fragment_shader_file | File name of the fragment shader. |
int initialize_shaders | ( | struct renderer_state * | state, |
const char * | shader_file, | ||
const char * | buffer_file, | ||
int | texture_width, | ||
int | texture_height | ||
) |
Initialize shaders, compile them, and create the required texture for the buffer shader.
state | The target renderer state. |
shader_file | The file name of the screen shader. |
buffer_file | The file name of the buffer shader, or NULL if no buffer shader. |
texture_width | The width of the texture for the buffer shader. |
texture_height | The height of the texture for the buffer shader. |
char* read_file | ( | const char *const | filename | ) |
Reads a file in a heap-allocated buffer.
This function computes the length of the file, allocate a buffer of the correct size, and reads the file in the buffer. Returns NULL
on error.
filename | The file to read. |
NULL
if there was an error.