Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
light.h
Go to the documentation of this file.
1/*
2** Jo Sega Saturn Engine
3** Copyright (c) 2012-2026, Johannes Fetz (johannesfetz@gmail.com)
4** All rights reserved.
5**
6** Redistribution and use in source and binary forms, with or without
7** modification, are permitted provided that the following conditions are met:
8** * Redistributions of source code must retain the above copyright
9** notice, this list of conditions and the following disclaimer.
10** * Redistributions in binary form must reproduce the above copyright
11** notice, this list of conditions and the following disclaimer in the
12** documentation and/or other materials provided with the distribution.
13** * Neither the name of the Johannes Fetz nor the
14** names of its contributors may be used to endorse or promote products
15** derived from this software without specific prior written permission.
16**
17** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
49
50#ifndef __JO_LIGHT_H__
51# define __JO_LIGHT_H__
52
53#ifdef JO_COMPILE_WITH_3D_SUPPORT
54
56# define JO_MAX_POINT_LIGHTS (8)
58# define JO_MAX_POINT_LIGHT_MESHES (64)
61# define JO_POINT_LIGHT_STRENGTH_DEFAULT (256)
62
72int jo_3d_point_light_add(const jo_pos3D_fixed * const position, const unsigned char r, const unsigned char g,
73 const unsigned char b, const int radius, const int strength);
74
79void jo_3d_point_light_set_intensity(const int id, const int intensity);
80
87void jo_3d_point_light_set_color(const int id, const unsigned char r, const unsigned char g, const unsigned char b);
88
93void jo_3d_point_light_set_position(const int id, const jo_pos3D_fixed * const position);
94
101void jo_3d_point_light_set_spot(const int id, const jo_pos3D_fixed * const direction, const int angle);
102
108void jo_3d_point_light_set_shadows(const int id, const bool shadows);
109
115void jo_3d_point_light_set_sampled(const int id, const bool sampled);
116
121void jo_3d_point_light_enable(const int id, const bool enabled);
122
126void jo_3d_point_lights_enable(const bool enabled);
127
137
143void jo_3d_point_lights_set_mesh_seen(const jo_3d_mesh * const mesh, const bool seen);
144
149void jo_3d_point_lights_set_occlusion(bool (*hit)(const jo_pos3D_fixed * const origin, const jo_pos3D_fixed * const dir,
150 const jo_fixed max_t));
151
155
163void jo_3d_point_lights_sample(const jo_pos3D_fixed * const position, int * const r, int * const g, int * const b);
164
167
168#endif /* !JO_COMPILE_WITH_3D_SUPPORT */
169
170#endif /* !__JO_LIGHT_H__ */
171
172/*
173** END OF FILE
174*/
Mesh structure.
Definition 3d.h:216
bool jo_3d_point_lights_add_mesh(jo_3d_mesh *const mesh)
Add a mesh lit by the point lights: its points in world coordinates (a mesh drawn without a matrix of...
void jo_3d_point_lights_clear(void)
Remove the lights and the meshes (the gouraud tables get their colors back): before the meshes are fr...
void jo_3d_point_light_set_shadows(const int id, const bool shadows)
Shadows of a light (on by default when jo_3d_point_lights_set_occlusion() is set): off for a light th...
int jo_3d_point_light_add(const jo_pos3D_fixed *const position, const unsigned char r, const unsigned char g, const unsigned char b, const int radius, const int strength)
Add a point light.
void jo_3d_point_lights_sample(const jo_pos3D_fixed *const position, int *const r, int *const g, int *const b)
The light of the lights at a point (for an object that moves: a character, a weapon,...
void jo_3d_point_lights_update(void)
Write the gouraud tables changed by the lights (computes the light of the lights added or moved first...
void jo_3d_point_light_set_color(const int id, const unsigned char r, const unsigned char g, const unsigned char b)
Color of a light (cheap).
void jo_3d_point_lights_set_occlusion(bool(*hit)(const jo_pos3D_fixed *const origin, const jo_pos3D_fixed *const dir, const jo_fixed max_t))
Shadows: a function that tells if a ray hits a wall (for instance the walls of the cells,...
void jo_3d_point_lights_set_mesh_seen(const jo_3d_mesh *const mesh, const bool seen)
A mesh is seen or not in this frame (for instance the cells drawn, see jo_cells_prepare()): the light...
void jo_3d_point_light_set_sampled(const int id, const bool sampled)
Light of a light seen by jo_3d_point_lights_sample() (the objects, the weapon of the player): on by d...
void jo_3d_point_light_enable(const int id, const bool enabled)
Switch a light on or off (cheap).
void jo_3d_point_light_set_spot(const int id, const jo_pos3D_fixed *const direction, const int angle)
A spot light (a torch, a lamp with a shade): the light goes in a cone; or all around (a bulb,...
void jo_3d_point_light_set_intensity(const int id, const int intensity)
Intensity of a light (a flicker, a pulse: cheap).
void jo_3d_point_light_set_position(const int id, const jo_pos3D_fixed *const position)
Move a light (its light is computed again on all the meshes: costly).
void jo_3d_point_lights_enable(const bool enabled)
The point lights on or off (off: the meshes get their colors back).
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:48
3D position using fixed numbers
Definition types.h:92