Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
Loading...
Searching...
No Matches
shockwave.c File Reference
#include "shockwave.h"
#include "gl_common.h"
#include "log.h"
#include "shader.h"
#include "utils.h"
#include <cglm/types.h>
#include <cglm/vec3.h>
#include <math.h>
Include dependency graph for shockwave.c:

Functions

bool shockwave_renderer_init (ShockwaveRenderer *renderer)
 Initializes shockwave renderer (shader + GPU resources).
 
void shockwave_renderer_cleanup (ShockwaveRenderer *renderer)
 Releases all GPU resources.
 
void shockwave_emit (ShockwaveRenderer *renderer, const vec3 position, const vec3 color, float velocity, float sim_time)
 Registers a new shockwave at the given position.
 
void shockwave_update (ShockwaveRenderer *renderer, float sim_time)
 Removes expired shockwaves based on current simulation time.
 
static void ensure_grab_texture (ShockwaveRenderer *ren, int width, int height)
 
void shockwave_draw (const ShockwaveRenderer *renderer, mat4 view, mat4 proj, vec3 camera_pos, float sim_time, int screen_w, int screen_h)
 Draws all active shockwaves as billboard quads with lensing.
 

Variables

static const float QUAD_VERTICES []
 
static const int QUAD_VERTEX_COUNT = 4
 
static const int QUAD_FLOATS = 12
 

Function Documentation

◆ ensure_grab_texture()

static void ensure_grab_texture ( ShockwaveRenderer *  ren,
int  width,
int  height 
)
static

◆ shockwave_draw()

void shockwave_draw ( const ShockwaveRenderer *  renderer,
mat4  view,
mat4  proj,
vec3  camera_pos,
float  sim_time,
int  screen_w,
int  screen_h 
)

Draws all active shockwaves as billboard quads with lensing.

Performs a grab pass (copies scene_color_tex to an internal texture) then draws billboard quads that sample the copy and apply radial UV distortion with chromatic aberration.

Should be called after scene geometry, before post-processing.

Parameters
rendererRenderer state.
viewView matrix.
projProjection matrix.
camera_posCamera world position.
sim_timeCurrent simulation time.
screen_wViewport width in pixels.
screen_hViewport height in pixels.
Here is the call graph for this function:

◆ shockwave_emit()

void shockwave_emit ( ShockwaveRenderer *  renderer,
const vec3  position,
const vec3  color,
float  velocity,
float  sim_time 
)

Registers a new shockwave at the given position.

Oldest event is evicted if the buffer is full.

Parameters
swRenderer state.
positionWorld-space impact point.
colorBody albedo color.
velocityRadial velocity at impact (determines intensity).
sim_timeCurrent simulation time.

◆ shockwave_renderer_cleanup()

void shockwave_renderer_cleanup ( ShockwaveRenderer *  renderer)

Releases all GPU resources.

Here is the call graph for this function:

◆ shockwave_renderer_init()

bool shockwave_renderer_init ( ShockwaveRenderer *  renderer)

Initializes shockwave renderer (shader + GPU resources).

Returns
true on success, false on shader load failure.
Here is the call graph for this function:

◆ shockwave_update()

void shockwave_update ( ShockwaveRenderer *  renderer,
float  sim_time 
)

Removes expired shockwaves based on current simulation time.

Variable Documentation

◆ QUAD_FLOATS

const int QUAD_FLOATS = 12
static

◆ QUAD_VERTEX_COUNT

const int QUAD_VERTEX_COUNT = 4
static

◆ QUAD_VERTICES

const float QUAD_VERTICES[]
static
Initial value:
= {
-1.0F, -1.0F, 0.0F,
1.0F, -1.0F, 0.0F,
-1.0F, 1.0F, 0.0F,
1.0F, 1.0F, 0.0F,
}