LibGame  v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
lg_render.c File Reference

Functions

int lg_mesh_to_drawelements_cmd (LG_Mesh *mesh, int u_tex, LG_DrawElements_Cmd *draw_params)
 
void lg_draw_elements (LG_DrawElements_Cmd *draw_params)
 
void lg_drawelements_info (LG_DrawElements_Cmd *draw_params)
 

Detailed Description

 === Structs and wrapper funcs to efficiently draw mesh data ===

 - Set textures and params to be used by glDrawElements()
 - Make batch calls to glDrawElements()

 LG_DrawElements_Cmd = glDrawElements() command

Function Documentation

◆ lg_mesh_to_drawelements_cmd()

int lg_mesh_to_drawelements_cmd ( LG_Mesh mesh,
int  u_tex,
LG_DrawElements_Cmd draw_params 
)

Here we use:

  • mesh->n_usemtl = num of 'usemtl' tags in OBJ file
  • mesh->materials[N_MAX_USEMTL_PER_OBJ] = materials referenced by 'usemtl' tags

to compute size and shift

LG_N_MAX_DRAWS = N_MAX_MAT_PER_OBJ

Parameters
meshPointer to a LG_Mesh struct
u_texTexture coords uniform to be used by glUniform1i()
draw_paramsPointer to a LG_DrawElements_Cmd struct
Returns
LG_OK if OK

◆ lg_draw_elements()

void lg_draw_elements ( LG_DrawElements_Cmd draw_params)

Call glDrawElements(GL_TRIANGLES, size[i], GL_UNSIGNED_INT, shift[i]) n_draws times

Parameters
draw_paramsPointer to a LG_DrawElements_Cmd struct

◆ lg_drawelements_info()

void lg_drawelements_info ( LG_DrawElements_Cmd draw_params)

Print out LG_DrawElements_Cmd info

Parameters
draw_paramsPointer to a LG_DrawElements_Cmd struct