ShaderTool  0.1
Live tool for developing OpenGL shaders interactively
Functions
shaders.h File Reference
#include "renderer.h"
Include dependency graph for shaders.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int initialize_shaders (struct renderer_state *state, const char *shader_file, const char *buffer_file, int window_width, int window_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...
 

Function Documentation

◆ compile_shaders()

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.

Parameters
shader_programPointer to the ID of the shader program where the shaders will be stored.
fragment_shader_fileFile name of the fragment shader.
Returns
0 on success, 1 on error.

◆ initialize_shaders()

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.

Parameters
stateThe target renderer state.
shader_fileThe file name of the screen shader.
buffer_fileThe file name of the buffer shader, or NULL if no buffer shader.
texture_widthThe width of the texture for the buffer shader.
texture_heightThe height of the texture for the buffer shader.
Returns
0 on success, 1 on error.

◆ read_file()

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.

Parameters
filenameThe file to read.
Returns
A buffer containing the contents of the file, or NULL if there was an error.