LibGame v0.4.0
The LG Game Engine - Copyright (C) 2024-2026 ETMSoftware
Loading...
Searching...
No Matches
lg_mesh_lines.c File Reference

Functions

static void build_base_hexagon (vec3_t *hexagon2, vec3_t v1, vec3_t v2, float line_width)
 
LG_MeshLine lg_meshline_new (vec3_t v1, vec3_t v2, int n_seg, float line_width, LG_Color_u c1, LG_Color_u c2, zboolean *is_ok)
 
int lg_meshline_set_data (LG_MeshLine *mesh_line, vec3_t v1, vec3_t v2, LG_Color_u c1, LG_Color_u c2)
 
int lg_meshline_render (LG_MeshLine *mesh_line, mat4_t *model_view_proj_m)
 
void lg_meshline_free (LG_MeshLine *mesh_line)
 

Detailed Description

=== Trying to find a better alternative to glDrawArrays(GL_LINES) ===

Function Documentation

◆ lg_meshline_new()

LG_MeshLine lg_meshline_new ( vec3_t  v1,
vec3_t  v2,
int  n_seg,
float  line_width,
LG_Color_u  c1,
LG_Color_u  c2,
zboolean *  is_ok 
)

Create and return a new LG_MeshLine, ie a hexagon-based mesh line, and initialize its renderer (VAO and shader prog)

 base

   x  x (i = 1)
 x      x (i = 0)
   x  x

 n_seg = 2

       x  x
      /  /  x
     x  x  /
    /  /  x
   x  x  /
 x      x
   x  x

You can/should check the value of is_ok

No GL error checking is performed

Parameters
v1
v2
n_seg
line_width
c1Color of odd segments
c2Color of even segments
is_ok
Returns
A new LG_MeshLine

◆ lg_meshline_set_data()

int lg_meshline_set_data ( LG_MeshLine mesh_line,
vec3_t  v1,
vec3_t  v2,
LG_Color_u  c1,
LG_Color_u  c2 
)

Set vbo_data of an already created LG_MeshLine from v1, v2, c1, and c2

Parameters
v1
v2
c1Color of odd segments
c2Color of even segments
Returns
Always 0 so far

◆ lg_meshline_render()

int lg_meshline_render ( LG_MeshLine mesh_line,
mat4_t model_view_proj_m 
)

Render a LG_MeshLine

Parameters
mesh_linePointer to a LG_MeshLine
model_view_proj_mPointer to a mat4_t transform matrix
Returns
0 if OK, -1 on error

◆ lg_meshline_free()

void lg_meshline_free ( LG_MeshLine mesh_line)

Free a LG_MeshLine renderer resources (VAO, VBO, shader prog, and vbo_data)

Parameters
mesh_linePointer to a LG_MeshLine