SaturnRingLibrary 0.6
SGL wrapper
 
Loading...
Searching...
No Matches
SRL::Scene2D Class Reference

Detailed Description

Rendering of VDP1 sprites and shapes.

#include <srl_scene2d.hpp>

Public Types

enum  ClippingEffect : uint8_t { NoClipping = 0 , ClipOutside = 2 , ClipInside = 3 }
 Clipping effect mode. More...
 
enum  FlipEffect : uint8_t { NoFlip = 0 , HorizontalFlip = 1 , VerticalFlip = 2 }
 Sprite flip effect. More...
 
enum  SpriteEffect : uint8_t {
  Gouraud = 0 , ScreenDoors = 1 , HalfTransparency = 2 , Clipping = 3 ,
  Flip = 4 , OpacityBank = 5
}
 List of all available sprite effects. More...
 

Draw functions

static bool DrawSprite (const uint16_t texture, SRL::CRAM::Palette *texturePalette, const Types::Vector2D points[4], const Types::Fxp depth)
 Draw sprite from 4 points.
 
static bool DrawSprite (const uint16_t texture, const Types::Vector2D points[4], const Types::Fxp depth)
 Draw sprite from 4 points.
 
static bool DrawSprite (const uint16_t texture, SRL::CRAM::Palette *texturePalette, const Types::Vector3D &location, const Types::Angle &angle=Types::Angle::FromRaw(0), const Types::Vector2D &scale=Types::Vector2D(1.0, 1.0))
 Draw simple sprite.
 
static bool DrawSprite (const uint16_t texture, const Types::Vector3D &location, const Types::Angle &angle=Types::Angle::FromRaw(0), const Types::Vector2D &scale=Types::Vector2D(1.0, 1.0))
 Draw simple sprite.
 
static bool DrawSprite (const uint16_t texture, const Types::Vector3D &location, const Types::Vector2D &scale)
 Draw simple sprite.
 
static bool DrawSprite (const uint16_t texture, SRL::CRAM::Palette *texturePalette, const Types::Vector3D &location, const Types::Vector2D &scale)
 Draw simple sprite.
 
static bool DrawLine (const Types::Vector2D &start, const Types::Vector2D &end, const Types::HighColor &color, const Types::Fxp sort)
 Draws a Line.
 
static bool DrawPolygon (const Types::Vector2D points[4], const bool fill, const Types::HighColor &color, const Types::Fxp sort)
 Draws a generic polygon.
 

Sprite effect functions

static bool SetClippingRectangle (const Types::Vector3D &location, const Types::Vector2D &size)
 Set the Clipping rectangle.
 
static void SetEffect (const SpriteEffect effect, const int32_t data=-1)
 Set sprite effect.
 
static int32_t GetEffect (const SpriteEffect effect)
 Get currently set effect value.
 

Member Enumeration Documentation

◆ ClippingEffect

Clipping effect mode.

Enumerator
NoClipping 

Disable sprite clipping.

ClipOutside 

Display sprite only on the inside of the clipping rectangle.

ClipInside 

Display sprite only on the outside of the clipping rectangle.

◆ FlipEffect

enum SRL::Scene2D::FlipEffect : uint8_t

Sprite flip effect.

Enumerator
NoFlip 

Do not flip sprite.

HorizontalFlip 

Flip sprite horizontally.

VerticalFlip 

Flip sprite vertically.

◆ SpriteEffect

List of all available sprite effects.

Enumerator
Gouraud 

Gouraud shading.

Enables/disables gouraud shading for sprites.
Expected parameter is zero based index (uint16_t) to a gouraud shading table to enable shading, or negative or no value to disable it.

// Disable shading
// or
// Enable shading, use 16th entry in the table
static void SetEffect(const SpriteEffect effect, const int32_t data=-1)
Set sprite effect.
Definition srl_scene2d.hpp:468
@ Gouraud
Gouraud shading.
Definition srl_scene2d.hpp:204
ScreenDoors 

Screen doors effect.

Enables/disables screen door effect.
Expects boolean value as parameter.

HalfTransparency 

Half transparency effect.

Enables/disables half transparency effect.
Expects boolean value as parameter.

Clipping 

Sprite clipping effect.

Enables/disables clipping effect.
Expects SRL::Scene2D::ClippingEffect enum.
Use SRL::Scene2D::SetClippingRectangle() function to set the clipping rectangle.

// Disable flip
// or
// Enable flip
@ Clipping
Sprite clipping effect.
Definition srl_scene2d.hpp:246
@ NoClipping
Disable sprite clipping.
Definition srl_scene2d.hpp:158
@ ClipInside
Display sprite only on the outside of the clipping rectangle.
Definition srl_scene2d.hpp:166
Flip 

Flip sprite effect.

Allows to set sprite texture read direction (making sprite flipped)

// Disable flipping
// or
// Enable clipping
// Enable flip in both directions
@ Flip
Flip sprite effect.
Definition srl_scene2d.hpp:263
@ NoFlip
Do not flip sprite.
Definition srl_scene2d.hpp:175
@ HorizontalFlip
Flip sprite horizontally.
Definition srl_scene2d.hpp:179
@ VerticalFlip
Flip sprite vertically.
Definition srl_scene2d.hpp:183
OpacityBank 

VDP2 color calculation effect.

Set sprites Color Calculation Ratio to one of 8 stored opacities (Banks 0-7)

//Set sprite to use ratio stored in opacity bank 1:
@ OpacityBank
VDP2 color calculation effect.
Definition srl_scene2d.hpp:273
Note
Only applies to palette color modes

Member Function Documentation

◆ DrawLine()

static bool SRL::Scene2D::DrawLine ( const Types::Vector2D & start,
const Types::Vector2D & end,
const Types::HighColor & color,
const Types::Fxp sort )
inlinestatic

Draws a Line.

Parameters
startstart point
endend point
colorcolor of the line
sortZ order

◆ DrawPolygon()

static bool SRL::Scene2D::DrawPolygon ( const Types::Vector2D points[4],
const bool fill,
const Types::HighColor & color,
const Types::Fxp sort )
inlinestatic

Draws a generic polygon.

Parameters
pointsPoints of the polygon
fillIndicates whether polygon is filled or if it is just a poly-line
colorPolygon color
sortZ order

◆ DrawSprite() [1/6]

static bool SRL::Scene2D::DrawSprite ( const uint16_t texture,
const Types::Vector2D points[4],
const Types::Fxp depth )
inlinestatic

Draw sprite from 4 points.

Parameters
textureSprite texture
pointsCorners of the sprite in screen coordinates
depthDepth sort value
Returns
True on success

◆ DrawSprite() [2/6]

static bool SRL::Scene2D::DrawSprite ( const uint16_t texture,
const Types::Vector3D & location,
const Types::Angle & angle = Types::Angle::FromRaw(0),
const Types::Vector2D & scale = Types::Vector2D(1.0, 1.0) )
inlinestatic

Draw simple sprite.

Parameters
textureSprite texture
locationLocation of the sprite (Z coordinate is used for sorting)
angleSprite rotation angle
scaleScale of the sprite
Returns
True on success

◆ DrawSprite() [3/6]

static bool SRL::Scene2D::DrawSprite ( const uint16_t texture,
const Types::Vector3D & location,
const Types::Vector2D & scale )
inlinestatic

Draw simple sprite.

Parameters
textureSprite texture
locationLocation of the sprite (Z coordinate is used for sorting)
scaleScale of the sprite
Returns
True on success

◆ DrawSprite() [4/6]

static bool SRL::Scene2D::DrawSprite ( const uint16_t texture,
SRL::CRAM::Palette * texturePalette,
const Types::Vector2D points[4],
const Types::Fxp depth )
inlinestatic

Draw sprite from 4 points.

Parameters
textureSprite texture
texturePaletteSprite texture color palette override
pointsCorners of the sprite in screen coordinates
depthDepth sort value
Returns
True on success

◆ DrawSprite() [5/6]

static bool SRL::Scene2D::DrawSprite ( const uint16_t texture,
SRL::CRAM::Palette * texturePalette,
const Types::Vector3D & location,
const Types::Angle & angle = Types::Angle::FromRaw(0),
const Types::Vector2D & scale = Types::Vector2D(1.0, 1.0) )
inlinestatic

Draw simple sprite.

Parameters
textureSprite texture
texturePaletteSprite texture color palette override
locationLocation of the sprite (Z coordinate is used for sorting)
angleSprite rotation angle
scaleScale of the sprite
Returns
True on success

◆ DrawSprite() [6/6]

static bool SRL::Scene2D::DrawSprite ( const uint16_t texture,
SRL::CRAM::Palette * texturePalette,
const Types::Vector3D & location,
const Types::Vector2D & scale )
inlinestatic

Draw simple sprite.

Parameters
textureSprite texture
texturePaletteSprite texture color palette override
locationLocation of the sprite (Z coordinate is used for sorting)
scaleScale of the sprite
Returns
True on success

◆ GetEffect()

static int32_t SRL::Scene2D::GetEffect ( const SpriteEffect effect)
inlinestatic

Get currently set effect value.

See SRL::Scene2D::SpriteEffect for valid effect data

Parameters
effectEffect id
Returns
Currently set effect value, see SRL::Scene2D::SpriteEffect for expected return values

◆ SetClippingRectangle()

static bool SRL::Scene2D::SetClippingRectangle ( const Types::Vector3D & location,
const Types::Vector2D & size )
inlinestatic

Set the Clipping rectangle.

Parameters
locationRectangle top left corner location in screen coordinates, where top left corner of the screen is (0,0)
sizeRectangle size
Returns
true on success

◆ SetEffect()

static void SRL::Scene2D::SetEffect ( const SpriteEffect effect,
const int32_t data = -1 )
inlinestatic

Set sprite effect.

See SRL::Scene2D::SpriteEffect for valid effect data

Parameters
effectEffect id
dataEffect parameter