Jo Engine  2024.04.28
Jo Sega Saturn Engine
Data Structures | Enumerations | Functions
software_renderer.h File Reference

Fast Triangle based software renderer using fixed number. More...

Go to the source code of this file.

Data Structures

struct  jo_software_renderer_gfx
 This is the main struct that handle everything for drawing. More...
 
struct  jo_software_renderer_vertex
 Vertex. More...
 
struct  jo_software_renderer_triangle
 Triangle definition. More...
 

Enumerations

enum  jo_software_renderer_draw_mode { JO_SR_DRAW_TEXTURED, JO_SR_DRAW_FLAT, JO_SR_DRAW_WIREFRAME }
 Draw mode. More...
 
enum  jo_software_renderer_face_culling_mode { JO_SR_BACK_FACE_CULLING, JO_SR_FRONT_FACE_CULLING, JO_SR_NO_FACE_CULLING }
 Face culling mode. More...
 
enum  jo_software_renderer_depth_mode {
  JO_SR_DEPTH_IGNORE, JO_SR_DEPTH_LESS, JO_SR_DEPTH_LESS_OR_EQUAL, JO_SR_DEPTH_GREATER_OR_EQUAL,
  JO_SR_DEPTH_GREATER, JO_SR_DEPTH_NOT_EQUAL, JO_SR_DEPTH_EQUAL
}
 Z-BUFFER Computation mode. More...
 

Functions

jo_software_renderer_gfxjo_software_renderer_create_ex (unsigned short width, unsigned short height, const jo_scroll_screen screen, const bool enable_zbuffer)
 Create a full-color rendering surface. More...
 
static __jo_force_inline jo_software_renderer_gfxjo_software_renderer_create (unsigned short width, unsigned short height, const jo_scroll_screen screen)
 Create a full-color rendering surface. More...
 
void jo_software_renderer_free (jo_software_renderer_gfx *const gfx)
 Free the rendering surface. More...
 
void jo_software_renderer_flush (jo_software_renderer_gfx *const gfx)
 Copy the buffer into VDP1/2 VRAM. More...
 
void jo_software_renderer_clear (const jo_software_renderer_gfx *const gfx, const jo_color color)
 Clear the buffer with the given color. More...
 
void jo_software_renderer_draw_pixel2D (const jo_software_renderer_gfx *const gfx, const jo_fixed x, const jo_fixed y, const jo_color color)
 Draw a pixel without handling the Z-Buffer. More...
 
void jo_software_renderer_draw_pixel3D (const jo_software_renderer_gfx *const gfx, const jo_fixed x, const jo_fixed y, const jo_fixed z, const jo_color color)
 Draw a pixel. More...
 
void jo_software_renderer_draw_line3D (const jo_software_renderer_gfx *const gfx, jo_fixed x0, jo_fixed y0, jo_fixed z0, jo_fixed x1, jo_fixed y1, jo_fixed z1, const jo_color color0, const jo_color color1)
 Draw a line. More...
 
void jo_software_renderer_draw_triangle (const jo_software_renderer_gfx *const gfx, const jo_software_renderer_triangle *const triangle, const jo_matrix *const transform_matrix)
 
static __jo_force_inline void jo_software_renderer_draw_triangle_wireframe (const jo_software_renderer_gfx *const gfx, const jo_software_renderer_triangle *const triangle)
 Draw a triangle in wireframe. More...
 

Detailed Description

Fast Triangle based software renderer using fixed number.

Author
Johannes Fetz
Bug:
No known bugs.
Todo:
Lights, Texture mapping, 8 bits mode, etc.

Data Structure Documentation

◆ jo_software_renderer_gfx

struct jo_software_renderer_gfx

This is the main struct that handle everything for drawing.

Data Fields
jo_size clipping_size
jo_color * color_buffer
unsigned int color_buffer_size
jo_fixed * depth_buffer
unsigned int depth_buffer_dword_size
jo_software_renderer_depth_mode depth_mode_testing
jo_software_renderer_draw_mode draw_mode
jo_software_renderer_face_culling_mode face_culling_mode
int sprite_id
void * vram
jo_size vram_size

◆ jo_software_renderer_vertex

struct jo_software_renderer_vertex

Vertex.

Data Fields
jo_color color
jo_vector4_fixed pos
jo_vector2_fixed uv_texture_mapping

◆ jo_software_renderer_triangle

struct jo_software_renderer_triangle

Triangle definition.

Data Fields
int sprite_id
jo_software_renderer_vertex v0
jo_software_renderer_vertex v1
jo_software_renderer_vertex v2

Enumeration Type Documentation

◆ jo_software_renderer_depth_mode

Z-BUFFER Computation mode.

Enumerator
JO_SR_DEPTH_IGNORE 
JO_SR_DEPTH_LESS 
JO_SR_DEPTH_LESS_OR_EQUAL 
JO_SR_DEPTH_GREATER_OR_EQUAL 
JO_SR_DEPTH_GREATER 
JO_SR_DEPTH_NOT_EQUAL 
JO_SR_DEPTH_EQUAL 

◆ jo_software_renderer_draw_mode

Draw mode.

Enumerator
JO_SR_DRAW_TEXTURED 
JO_SR_DRAW_FLAT 
JO_SR_DRAW_WIREFRAME 

◆ jo_software_renderer_face_culling_mode

Face culling mode.

Enumerator
JO_SR_BACK_FACE_CULLING 
JO_SR_FRONT_FACE_CULLING 
JO_SR_NO_FACE_CULLING 

Function Documentation

◆ jo_software_renderer_clear()

void jo_software_renderer_clear ( const jo_software_renderer_gfx *const  gfx,
const jo_color  color 
)

Clear the buffer with the given color.

Parameters
gfxSoftware Rendering Graphics
colorColor

◆ jo_software_renderer_create()

static __jo_force_inline jo_software_renderer_gfx* jo_software_renderer_create ( unsigned short  width,
unsigned short  height,
const jo_scroll_screen  screen 
)
static

Create a full-color rendering surface.

Parameters
widthSurface width
heightSurface height
screenDrawing destination. Only JO_SPRITE_SCREEN and JO_NBG1_SCREEN are supported today
Returns
Software Rendering Graphics

◆ jo_software_renderer_create_ex()

jo_software_renderer_gfx* jo_software_renderer_create_ex ( unsigned short  width,
unsigned short  height,
const jo_scroll_screen  screen,
const bool  enable_zbuffer 
)

Create a full-color rendering surface.

Parameters
widthSurface width
heightSurface height
screenDrawing destination. Only JO_SPRITE_SCREEN and JO_NBG1_SCREEN are supported today
enable_zbufferEnable Z buffer (use a lot of RAM depending on the size of the surface)
Returns
Software Rendering Graphics

◆ jo_software_renderer_draw_line3D()

void jo_software_renderer_draw_line3D ( const jo_software_renderer_gfx *const  gfx,
jo_fixed  x0,
jo_fixed  y0,
jo_fixed  z0,
jo_fixed  x1,
jo_fixed  y1,
jo_fixed  z1,
const jo_color  color0,
const jo_color  color1 
)

Draw a line.

Parameters
gfxSoftware Rendering Graphics
x0X0 Fixed position (point A)
y0Y0 Fixed position (point A)
z0Z0 Fixed position (point A)
x1X2 Fixed position (point B)
y1Y2 Fixed position (point B)
z1Z2 Fixed position (point B)
color0First color (point A)
color1Second color (point B)

◆ jo_software_renderer_draw_pixel2D()

void jo_software_renderer_draw_pixel2D ( const jo_software_renderer_gfx *const  gfx,
const jo_fixed  x,
const jo_fixed  y,
const jo_color  color 
)

Draw a pixel without handling the Z-Buffer.

Parameters
gfxSoftware Rendering Graphics
xX Fixed position
yY Fixed position
colorPixel color

◆ jo_software_renderer_draw_pixel3D()

void jo_software_renderer_draw_pixel3D ( const jo_software_renderer_gfx *const  gfx,
const jo_fixed  x,
const jo_fixed  y,
const jo_fixed  z,
const jo_color  color 
)

Draw a pixel.

Parameters
gfxSoftware Rendering Graphics
xX Fixed position
yY Fixed position
zZ Fixed position
colorPixel color

◆ jo_software_renderer_draw_triangle()

void jo_software_renderer_draw_triangle ( const jo_software_renderer_gfx *const  gfx,
const jo_software_renderer_triangle *const  triangle,
const jo_matrix *const  transform_matrix 
)

◆ jo_software_renderer_draw_triangle_wireframe()

static __jo_force_inline void jo_software_renderer_draw_triangle_wireframe ( const jo_software_renderer_gfx *const  gfx,
const jo_software_renderer_triangle *const  triangle 
)
static

Draw a triangle in wireframe.

Parameters
gfxSoftware Rendering Graphics
triangleTriangle

◆ jo_software_renderer_flush()

void jo_software_renderer_flush ( jo_software_renderer_gfx *const  gfx)

Copy the buffer into VDP1/2 VRAM.

Parameters
gfxSoftware Rendering Graphics

◆ jo_software_renderer_free()

void jo_software_renderer_free ( jo_software_renderer_gfx *const  gfx)

Free the rendering surface.

Parameters
gfxSoftware Rendering Graphics
Warning
This doesn't free the sprite behind (JO_SPRITE_SCREEN) but you can replace it with jo_sprite_replace()