Jo Engine 2026.11.6
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
sun.h File Reference

Jo Engine sun: the sun in the sky of a 3D view (its halo and its core, sprites behind everything) and its lens flare (pieces on the line from the sun through the middle of the screen, in front of everything). More...

Go to the source code of this file.

Data Structures

struct  jo_sun_flare
 A piece of the lens flare drawn. More...
struct  jo_sun
 The sun (see jo_sun_init(): the default values). More...

Macros

#define JO_SUN_MAX_HALO_STRIPS
 Strips of the halo at most.
#define JO_SUN_FLARE_PIECES
 Pieces of the lens flare (sprites): a ring, a disc, a hexagon (see jo_level/sun.py: FLARE_PIECES).
#define JO_SUN_FLARE_FULL
 The full level of the lens flare (see jo_sun.flare_level).

Functions

void jo_sun_init (jo_sun *const sun, const jo_angle azimuth, const jo_angle elevation)
 The default values of a sun: no sprite, the default lens flare.
void jo_sun_update (jo_sun *const sun, const jo_angle heading, const jo_fixed look_down, bool(*hidden)(void))
 Place the sun on the screen, fade the lens flare (once a frame).
void jo_sun_draw (const jo_sun *const sun)
 Draw the sun (in the frame of the 3D: behind everything).
void jo_sun_draw_flare (const jo_sun *const sun)
 Draw the lens flare (in front of the rest: before the HUD).

Detailed Description

Jo Engine sun: the sun in the sky of a 3D view (its halo and its core, sprites behind everything) and its lens flare (pieces on the line from the sun through the middle of the screen, in front of everything).

Author
Johannes Fetz
  • The sun is where its direction (azimuth, elevation) is seen from the camera: the camera turns around the vertical axis (its heading) and looks down (the tangent of the angle). Out of the view: nothing drawn
  • The halo: strips of sprites drawn from the top (128 x 32 each by default), the core (32 x 32) over its middle; the lens flare: 3 pieces (a ring, a disc, a hexagon), each one drawn at several places and sizes (see jo_sun_flare)
  • The sprites are made by the game: Compiler/COMMON/jo_level/sun.py makes them in 16 colors (the section TX16 of a level file), see-through with the color calculation of the VDP2 (the blend ratios of the sprites, see jo_vdp2_set_sprite_blend_ratios()): the halo is mixed with the sky behind it. Under the horizon (over the water, the ground) the pieces of the lens flare can be drawn half transparent by the VDP1 instead (jo_sun.flare_rgb[]: the same pixels in RGB)
  • The lens flare fades in when the sun is near the middle of the screen and not hidden (the game says if something is between the camera and the sun: see jo_sun_update()), out when it goes away, a step per frame

Usage: jo_sun_init(), then set the sprites (jo_sun.halo[], halo_strips, core, flare[]); at each frame jo_sun_update() after the camera is known, jo_sun_draw() in the frame of the 3D, jo_sun_draw_flare() after the rest

Bug
No known bugs.

Data Structure Documentation

◆ jo_sun_flare

struct jo_sun_flare

A piece of the lens flare drawn.

Data Fields
short piece
short place
short size

◆ jo_sun

struct jo_sun

The sun (see jo_sun_init(): the default values).

Data Fields
jo_angle azimuth
int bias
int core
int core_half
jo_angle elevation
int flare[(3)]
int flare_bias
int flare_count
int flare_level
int flare_rgb[(3)]
int flare_z
const jo_sun_flare * flares
int halo[(8)]
int halo_half
int halo_strips
int horizon_y
bool seen
int strip_height
int x
int y
int z

Macro Definition Documentation

◆ JO_SUN_FLARE_FULL

#define JO_SUN_FLARE_FULL

The full level of the lens flare (see jo_sun.flare_level).

◆ JO_SUN_FLARE_PIECES

#define JO_SUN_FLARE_PIECES

Pieces of the lens flare (sprites): a ring, a disc, a hexagon (see jo_level/sun.py: FLARE_PIECES).

◆ JO_SUN_MAX_HALO_STRIPS

#define JO_SUN_MAX_HALO_STRIPS

Strips of the halo at most.

Function Documentation

◆ jo_sun_draw()

void jo_sun_draw ( const jo_sun *const sun)

Draw the sun (in the frame of the 3D: behind everything).

◆ jo_sun_draw_flare()

void jo_sun_draw_flare ( const jo_sun *const sun)

Draw the lens flare (in front of the rest: before the HUD).

◆ jo_sun_init()

void jo_sun_init ( jo_sun *const sun,
const jo_angle azimuth,
const jo_angle elevation )

The default values of a sun: no sprite, the default lens flare.

Parameters
sunSun
azimuthThe heading toward it
elevationAbove the horizon

◆ jo_sun_update()

void jo_sun_update ( jo_sun *const sun,
const jo_angle heading,
const jo_fixed look_down,
bool(* hidden )(void) )

Place the sun on the screen, fade the lens flare (once a frame).

Parameters
sunSun
headingHeading of the camera
look_downHow much the camera looks down (the tangent of the angle, jo_fixed)
hiddenSomething between the camera and the sun (no lens flare)? Called only when the lens flare could be seen (JO_NULL: never hidden)