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

Go to the source code of this file.

Functions

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. 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.

◆ 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.