Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
shader.h File Reference

Basic shader-like bitmap manipulation.

#include <banjo/api.h>
#include <banjo/bitmap.h>
#include <banjo/linmath.h>
Include dependency graph for shader.h:

Go to the source code of this file.

Macros

#define BJ_SHADER_STANDARD_FLAGS   (BJ_SHADER_INVERT_Y | BJ_SHADER_CLAMP_COLOR | BJ_SHADER_NORMALIZE_COORDS | BJ_SHADER_CENTER_COORDS)
 Flagset alias for bj_bitmap_apply_shader.
 

Typedefs

typedef int(* bj_bitmap_shading_fn_t) (bj_vec3 out_color, const bj_vec2 pixel_coord, void *user_data)
 Function type for a bitmap shading operation.
 
typedef enum bj_shader_flag_t bj_shader_flag
 Shader input control flags.
 

Enumerations

enum  bj_shader_flag_t {
  BJ_SHADER_INVERT_X = 0x01 , BJ_SHADER_INVERT_Y = 0x02 , BJ_SHADER_CLAMP_COLOR = 0x04 , BJ_SHADER_NORMALIZE_COORDS = 0x08 ,
  BJ_SHADER_CENTER_COORDS = 0x10
}
 Shader input control flags. More...
 

Functions

float bj_clamp (float x, float min, float max)
 Clamps a float between a minimum and a maximum value.
 
float bj_step (float edge, float x)
 Returns 0.0 if x < edge, else 1.0.
 
float bj_smoothstep (float edge0, float edge1, float x)
 Performs smooth Hermite interpolation between 0 and 1 over a range.
 
float bj_fract (float x)
 Returns the fractional part of a float.
 
int bj_mod (float x, float y)
 Computes a floor-style modulus between two floats.
 
void bj_bitmap_apply_shader (bj_bitmap *p_bitmap, bj_bitmap_shading_fn_t p_shader, void *p_data, uint8_t flags)
 Applies a shader function to every pixel in a bitmap.