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

Functions

Vertex lg_vertex (float x, float y, float z)
 
Vertex lg_vertex_from_vec3 (vec3_t v)
 
Vertex_uv lg_vertex_uv (float x, float y, float z, uint16_t u, uint16_t v)
 
Vertex_n lg_vertex_n (float x, float y, float z, int16_t n_x, int16_t n_y, int16_t n_z)
 
Vertex_uv_n lg_vertex_uv_n (float x, float y, float z, uint16_t u, uint16_t v, int16_t n_x, int16_t n_y, int16_t n_z)
 
Vertex_rgba lg_vertex_rgba (float x, float y, float z, LG_Color_u c)
 
Vertex_rgba lg_vertex_rgba_from_vec3 (vec3_t v, LG_Color_u c)
 
Vertex_rgba_n lg_vertex_rgba_n (float x, float y, float z, LG_Color_u c, int16_t n_x, int16_t n_y, int16_t n_z)
 
LG_Color_u lg_color_u (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
 
LG_Color_f lg_color_f (float r, float g, float b, float a)
 
LG_Color_u lg_color_u_from_f (LG_Color_f c)
 
LG_Color_f lg_color_f_from_u (LG_Color_u c)
 
void lg_vertex_sizes_info ()
 

Detailed Description

 === VBO vertex struct for interleaved data ===

 Storage format:
 - 3 float's for 3D spatial coords

 (optionally)
 - 2 uint16_t for tex coords
 - 3 int16_t for normals
 - 4 uint8_t for each color component

 All struct's are packed and aligned

 Aside from padding, flag1 can be used for extra purposes if necessary
 (max value of uint16_t = 65535)

Function Documentation

◆ lg_vertex()

Vertex lg_vertex ( float  x,
float  y,
float  z 
)

Create a new Vertex (spatial coords)

Parameters
xSpatial coord x
ySpatial coord y
zSpatial coord z
Returns
A new Vertex

◆ lg_vertex_from_vec3()

Vertex lg_vertex_from_vec3 ( vec3_t  v)

Create a new Vertex (spatial coords) from a vec3_t

Parameters
vA vec3_t
Returns
A new Vertex

◆ lg_vertex_uv()

Vertex_uv lg_vertex_uv ( float  x,
float  y,
float  z,
uint16_t  u,
uint16_t  v 
)

Create a new Vertex_uv (spatial coords + tex uv)

Parameters
xSpatial coord x
ySpatial coord y
zSpatial coord z
uTexture mapping u
vTexture mapping v
Returns
A new Vertex_uv

◆ lg_vertex_n()

Vertex_n lg_vertex_n ( float  x,
float  y,
float  z,
int16_t  n_x,
int16_t  n_y,
int16_t  n_z 
)

Create a new Vertex_n (spatial coords + normals)

Parameters
xSpatial coord x
ySpatial coord y
zSpatial coord z
n_xNormal vector x
n_yNormal vector y
n_zNormal vector z
Returns
A new Vertex_n

◆ lg_vertex_uv_n()

Vertex_uv_n lg_vertex_uv_n ( float  x,
float  y,
float  z,
uint16_t  u,
uint16_t  v,
int16_t  n_x,
int16_t  n_y,
int16_t  n_z 
)

Create a new Vertex_uv_n (spatial coords + tex uv + normals)

The most used/useful vertex struct, appropriate for LG_Mesh's VBOs

Parameters
xSpatial coord x
ySpatial coord y
zSpatial coord z
uTexture mapping u
vTexture mapping v
n_xNormal vector x
n_yNormal vector y
n_zNormal vector z
Returns
A new Vertex_uv_n

◆ lg_vertex_rgba()

Vertex_rgba lg_vertex_rgba ( float  x,
float  y,
float  z,
LG_Color_u  c 
)

Create a new Vertex_rgba (spatial coords + RGBA color)

Very useful vertex struct, appropriate for Lines3D_VB's vb_array/vb_ptr

Parameters
xSpatial coord x
ySpatial coord y
zSpatial coord z
cColor as a LG_Color_u
Returns
A new Vertex_rgba

◆ lg_vertex_rgba_from_vec3()

Vertex_rgba lg_vertex_rgba_from_vec3 ( vec3_t  v,
LG_Color_u  c 
)

Create a new Vertex_rgba (spatial coords vec3_t + RGBA color)

Parameters
vSpatial coords as a vec3_t
cColor as a LG_Color_u
Returns
A new Vertex_rgba

◆ lg_vertex_rgba_n()

Vertex_rgba_n lg_vertex_rgba_n ( float  x,
float  y,
float  z,
LG_Color_u  c,
int16_t  n_x,
int16_t  n_y,
int16_t  n_z 
)

Create a new Vertex_rgba_n (spatial coords + RGBA color as 4 unsigned bytes + normals)

Parameters
xSpatial coord x
ySpatial coord y
zSpatial coord z
cColor as a LG_Color_u
n_xNormal vector x
n_yNormal vector y
n_zNormal vector z
Returns
A new Vertex_rgba_n

◆ lg_color_u()

LG_Color_u lg_color_u ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a 
)

Create a new LG_Color_u, ie a RGBA color as 4 unsigned bytes (in range [0, 255])

Parameters
rRed
gGreen
bBlue
aAlpha
Returns
A new LG_Color_u

◆ lg_color_f()

LG_Color_f lg_color_f ( float  r,
float  g,
float  b,
float  a 
)

Create a new LG_Color_f, ie a RGBA color as 4 normalized float's (in range [0.0, 1.0])

Parameters
rRed
gGreen
bBlue
aAlpha
Returns
A new LG_Color_f

◆ lg_color_u_from_f()

LG_Color_u lg_color_u_from_f ( LG_Color_f  c)

Convert a LG_Color_f color to a a LG_Color_u color, ie a RGBA color as 4 unsigned bytes (in range [0, 255])

Parameters
rRed
gGreen
bBlue
aAlpha
Returns
A new LG_Color_u

◆ lg_color_f_from_u()

LG_Color_f lg_color_f_from_u ( LG_Color_u  c)

Convert a LG_Color_u color to a LG_Color_f color, ie a RGBA color as 4 normalized float's (in range [0.0, 1.0])

Parameters
rRed
gGreen
bBlue
aAlpha
Returns
A new LG_Color_f

◆ lg_vertex_sizes_info()

void lg_vertex_sizes_info ( )

Print out Vertex sizes and alignement requirements