LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
|
Functions | |
LG_ShaderProg | LG_ShaderProg_create (const char **vertex_shader_code, const char **fragment_shader_code, LG_VAP_params *params) |
void | LG_ShaderProg_delete (LG_ShaderProg *shader_prog) |
void | LG_ShaderProg_use (LG_ShaderProg *shader_prog, zboolean gl_checking) |
int | LG_ShaderProg_get_attrib_loc (LG_ShaderProg *shader_prog, const char *attrib_name) |
int | LG_ShaderProg_get_uniform_loc (LG_ShaderProg *shader_prog, const char *uniform_name) |
uint32_t | lg_load_shader (int type, const char **shader_code) |
int | lg_check_gl_errors (long long log_time, const char *file, int line, const char *func) |
void | lg_shader_info_log (uint32_t shader) |
=== Wrapper functions to more easily create and manage shader progs === LG_VAP_params = Vertex Attrib Pointer params
LG_ShaderProg LG_ShaderProg_create | ( | const char ** | vertex_shader_code, |
const char ** | fragment_shader_code, | ||
LG_VAP_params * | params | ||
) |
Create shader prog from vertex and fragment shader source code
Also set vertex attrib pointer params if params != NULL
Shader prog id set to LG_INVALID_SHADER_PROG_ID on error
vertex_shader_code | GLSL source code |
fragment_shader_code | GLSL source code |
params | An array of LG_VAP_params, may be NULL - VAP stands for Vertex Attrib Pointer |
Example code:
void LG_ShaderProg_delete | ( | LG_ShaderProg * | shader_prog | ) |
Delete shader prog
shader_prog | Addr of shader prog |
void LG_ShaderProg_use | ( | LG_ShaderProg * | shader_prog, |
zboolean | gl_checking | ||
) |
Use shader prog
shader_prog | Addr of shader prog |
gl_checking | Enable (TRUE) / disable (FALSE) GL checking |
int LG_ShaderProg_get_attrib_loc | ( | LG_ShaderProg * | shader_prog, |
const char * | attrib_name | ||
) |
Get the location of an attribute variable in the shader prog
Return -1 on error
shader_prog | |
attrib_name |
int LG_ShaderProg_get_uniform_loc | ( | LG_ShaderProg * | shader_prog, |
const char * | uniform_name | ||
) |
Get the location of a uniform variable in the shader prog
Return -1 on error
shader_prog | |
uniform_name |
uint32_t lg_load_shader | ( | int | type, |
const char ** | shader_code | ||
) |
Load and compile shader from source
type | GL_VERTEX_SHADER or GL_FRAGMENT_SHADER |
shader_code | GLSL source code |
int lg_check_gl_errors | ( | long long | log_time, |
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Check GL errors
log_time | lg_log_time() |
file | __ FILE __ (without spaces) |
line | __ LINE __ (without spaces) |
func | __ func __ (without spaces) |
void lg_shader_info_log | ( | uint32_t | shader | ) |
Print out shader compilation log
shader |