Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
shader.h
Go to the documentation of this file.
1
25
26#pragma once
27
28#include <banjo/api.h>
29#include <banjo/bitmap.h>
30#include <banjo/linmath.h>
31
45typedef int (*bj_bitmap_shading_fn_t)(bj_vec3 out_color, const bj_vec2 pixel_coord, void* user_data);
46
55BANJO_EXPORT float bj_clamp(
56 float x,
57 float min,
58 float max
59);
60
70BANJO_EXPORT float bj_step(
71 float edge,
72 float x
73);
74
83BANJO_EXPORT float bj_smoothstep(
84 float edge0,
85 float edge1,
86 float x
87);
88
95BANJO_EXPORT float bj_fract(
96 float x
97);
98
106BANJO_EXPORT int bj_mod(
107 float x,
108 float y
109);
110
198
209#define BJ_SHADER_STANDARD_FLAGS (BJ_SHADER_INVERT_Y | BJ_SHADER_CLAMP_COLOR | BJ_SHADER_NORMALIZE_COORDS | BJ_SHADER_CENTER_COORDS)
210
224BANJO_EXPORT void bj_bitmap_apply_shader(
225 bj_bitmap* p_bitmap,
226 bj_bitmap_shading_fn_t p_shader,
227 void* p_data,
228 uint8_t flags
229);
230
General-purpose definitions for Banjo API.
Header file for Bitmap type.
struct bj_bitmap_t bj_bitmap
Typedef for the bj_bitmap struct.
Definition bitmap.h:22
bj_real_t bj_vec3[3]
Defines a 3D vector type.
Definition linmath.h:54
bj_real_t bj_vec2[2]
Defines a 2D vector type.
Definition linmath.h:43
bj_shader_flag_t
Shader input control flags.
Definition shader.h:119
float bj_clamp(float x, float min, float max)
Clamps a float between a minimum and a maximum value.
int bj_mod(float x, float y)
Computes a floor-style modulus between two floats.
float bj_smoothstep(float edge0, float edge1, float x)
Performs smooth Hermite interpolation between 0 and 1 over a range.
float bj_step(float edge, float x)
Returns 0.0 if x < edge, else 1.0.
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.
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.
Definition shader.h:45
enum bj_shader_flag_t bj_shader_flag
Shader input control flags.
float bj_fract(float x)
Returns the fractional part of a float.
@ BJ_SHADER_CENTER_COORDS
Center pixel coordinates around the origin.
Definition shader.h:195
@ BJ_SHADER_CLAMP_COLOR
Clamp the output color to the range [0.0, 1.0].
Definition shader.h:160
@ BJ_SHADER_INVERT_Y
Invert the Y coordinate of the input pixel.
Definition shader.h:149
@ BJ_SHADER_NORMALIZE_COORDS
Normalize pixel coordinates to the [0.0, 1.0] range.
Definition shader.h:174
@ BJ_SHADER_INVERT_X
Invert the X coordinate of the input pixel.
Definition shader.h:134