Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
voxel.h File Reference

Jo Engine Voxel renderer. More...

Go to the source code of this file.

Data Structures

struct  __jo_voxel_computation_cache
 Voxel computation cache (internal engine usage). More...
struct  jo_voxel_camera
 Voxel camera definition. More...
struct  jo_voxel
 Voxel main definition. More...

Functions

void jo_voxel_do_angle_computation (jo_voxel *const voxel_data)
 Do computation linked to camera angle.
void jo_voxel_redraw (const jo_voxel *const voxel_data)
 Draw voxels to gfx.
void jo_voxel_run (jo_voxel *const voxel_data)
 Draw voxels to gfx.
void __jo_voxel_redraw (const jo_voxel *const voxel_data, const bool clear)
 Draw voxels to gfx (internal engine usage, see jo_voxel_redraw() and jo_voxel_redraw_and_flush()).
static __jo_force_inline void jo_voxel_redraw_and_flush (const jo_voxel *const voxel_data)
 Draw voxels and flush the buffer.
static __jo_force_inline void jo_voxel_set_scale (jo_voxel *const voxel_data, const jo_fixed scale)
 Set scale (camera.scale).
static __jo_force_inline void jo_voxel_increase_view_distance (jo_voxel *const voxel_data, const jo_fixed distance)
 Increase view distance (camera.zfar).
static __jo_force_inline void jo_voxel_decrease_view_distance (jo_voxel *const voxel_data, const jo_fixed distance)
 Decrease view distance (camera.zfar).
static __jo_force_inline void jo_voxel_horizon_up (jo_voxel *const voxel_data, const jo_fixed distance)
 Increase horizon height (camera.horizon).
static __jo_force_inline void jo_voxel_horizon_down (jo_voxel *const voxel_data, const jo_fixed distance)
 Decrease horizon height (camera.horizon).
static __jo_force_inline void jo_voxel_move_up (jo_voxel *voxel_data, const jo_fixed distance)
 Increase camera height (camera.height).
static __jo_force_inline void jo_voxel_move_down (jo_voxel *const voxel_data, const jo_fixed distance)
 Decrease camera height (camera.height).
static __jo_force_inline void jo_voxel_move_forward (jo_voxel *const voxel_data, const jo_fixed distance)
 Move camera forward (camera.x & camera.y).
static __jo_force_inline void jo_voxel_move_backward (jo_voxel *const voxel_data, const jo_fixed distance)
 Move camera backward (camera.x & camera.y).
static __jo_force_inline void jo_voxel_rotate_left (jo_voxel *const voxel_data, const jo_fixed angle_rad)
 Rotate camera on the left (camera.angle).
static __jo_force_inline void jo_voxel_rotate_right (jo_voxel *const voxel_data, const jo_fixed angle_rad)
 Rotate camera on the right (camera.angle).

Detailed Description

Jo Engine Voxel renderer.

Author
Johannes Fetz
Bug
No known bugs.

Data Structure Documentation

◆ __jo_voxel_computation_cache

struct __jo_voxel_computation_cache

Voxel computation cache (internal engine usage).

Warning
MC Hammer: don't touch this
Data Fields
jo_fixed deltax_0
jo_fixed deltax_incr
jo_fixed deltay_0
jo_fixed deltay_incr
jo_fixed inv_clipping_size_width
jo_fixed inv_zfar
int map_width_minus_1

◆ jo_voxel_camera

struct jo_voxel_camera

Voxel camera definition.

Data Fields
jo_fixed angle
jo_fixed height
jo_fixed horizon
jo_fixed scale
jo_fixed x
jo_fixed y
jo_fixed zfar

◆ jo_voxel

struct jo_voxel

Voxel main definition.

Data Fields
__jo_voxel_computation_cache __cache
jo_voxel_camera camera
jo_software_renderer_gfx * gfx
jo_img_8bits height_img
jo_palette height_pal
jo_img_8bits terrain_img
jo_palette terrain_pal
bool use_zbuffer

Function Documentation

◆ __jo_voxel_redraw()

void __jo_voxel_redraw ( const jo_voxel *const voxel_data,
const bool clear )

Draw voxels to gfx (internal engine usage, see jo_voxel_redraw() and jo_voxel_redraw_and_flush()).

Parameters
voxel_dataVoxel
clearClear the pixels that are not drawn in black

◆ jo_voxel_decrease_view_distance()

__jo_force_inline void jo_voxel_decrease_view_distance ( jo_voxel *const voxel_data,
const jo_fixed distance )
static

Decrease view distance (camera.zfar).

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_do_angle_computation()

void jo_voxel_do_angle_computation ( jo_voxel *const voxel_data)

Do computation linked to camera angle.

Parameters
voxel_dataVoxel
Remarks
Must be called if you change camera.angle manually.

◆ jo_voxel_horizon_down()

__jo_force_inline void jo_voxel_horizon_down ( jo_voxel *const voxel_data,
const jo_fixed distance )
static

Decrease horizon height (camera.horizon).

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_horizon_up()

__jo_force_inline void jo_voxel_horizon_up ( jo_voxel *const voxel_data,
const jo_fixed distance )
static

Increase horizon height (camera.horizon).

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_increase_view_distance()

__jo_force_inline void jo_voxel_increase_view_distance ( jo_voxel *const voxel_data,
const jo_fixed distance )
static

Increase view distance (camera.zfar).

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_move_backward()

__jo_force_inline void jo_voxel_move_backward ( jo_voxel *const voxel_data,
const jo_fixed distance )
static

Move camera backward (camera.x & camera.y).

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_move_down()

__jo_force_inline void jo_voxel_move_down ( jo_voxel *const voxel_data,
const jo_fixed distance )
static

Decrease camera height (camera.height).

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_move_forward()

__jo_force_inline void jo_voxel_move_forward ( jo_voxel *const voxel_data,
const jo_fixed distance )
static

Move camera forward (camera.x & camera.y).

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_move_up()

__jo_force_inline void jo_voxel_move_up ( jo_voxel * voxel_data,
const jo_fixed distance )
static

Increase camera height (camera.height).

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_redraw()

void jo_voxel_redraw ( const jo_voxel *const voxel_data)

Draw voxels to gfx.

Parameters
voxel_dataVoxel
Remarks
You should call jo_software_renderer_flush() at some point

◆ jo_voxel_redraw_and_flush()

__jo_force_inline void jo_voxel_redraw_and_flush ( const jo_voxel *const voxel_data)
static

Draw voxels and flush the buffer.

Parameters
voxel_dataVoxel
Remarks
It's just an helper method

◆ jo_voxel_rotate_left()

__jo_force_inline void jo_voxel_rotate_left ( jo_voxel *const voxel_data,
const jo_fixed angle_rad )
static

Rotate camera on the left (camera.angle).

Parameters
voxel_dataVoxel
angle_radfixed rad value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_rotate_right()

__jo_force_inline void jo_voxel_rotate_right ( jo_voxel *const voxel_data,
const jo_fixed angle_rad )
static

Rotate camera on the right (camera.angle).

Parameters
voxel_dataVoxel
angle_radfixed rad value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_run()

void jo_voxel_run ( jo_voxel *const voxel_data)

Draw voxels to gfx.

Parameters
voxel_dataVoxel
Warning
Must be call before calling jo_voxel_redraw() or jo_voxel_redraw_and_flush()

◆ jo_voxel_set_scale()

__jo_force_inline void jo_voxel_set_scale ( jo_voxel *const voxel_data,
const jo_fixed scale )
static

Set scale (camera.scale).

Parameters
voxel_dataVoxel
scaleScale: fixed value (see also jo_int2fixed() or jo_float2fixed())