Public Member Functions | Protected Attributes | List of all members
nom::Renderer Class Reference

Video subsystem responsible for managing high-level graphics display (think: very fancy back-buffer). More...

#include <Renderer.hpp>

Inheritance diagram for nom::Renderer:
[legend]

Public Member Functions

 Renderer (void)
 Default constructor; initializes instance to sane defaults.
 
virtual ~Renderer (void)
 Lazy destructor with nothing to do.
 
bool initialize (SDL_WINDOW::RawPtr window, int32 rendering_driver=-1, uint32 context_flags=SDL_RENDERER_ACCELERATED)
 
SDL_RENDERER::RawPtr renderer (void) const
 Get a raw pointer to the SDL_Renderer in use.
 
bool renderer_valid (void) const
 Is this object initialized? Valid when NOT nullptr.
 
const Point2i logical_resolution (void) const
 
const Coords viewport (void) const
 
const Point2i scale_factor (void) const
 Obtain the current scale factor.
 
const SDL_BlendMode blend_mode (void) const
 Obtain the blending mode used for drawing.
 
const Point2i size (void) const
 
const Coords bounds (void) const
 
void update (void) const
 Update the renderer surface on the attached window.
 
bool update (SDL_TEXTURE::RawPtr input_texture)
 
bool clear (void) const
 
bool fill (const Color &color=Color::Blue)
 
bool set_logical_resolution (int width, int height)
 
bool set_viewport (const Coords &rect)
 
bool set_color (const Color &color)
 
bool set_blend_mode (const SDL_BlendMode mode)
 
bool set_bounds (const Coords &clip_bounds)
 
void * pixels (void) const
 

Protected Attributes

SDL_RENDERER::UniquePtr renderer_
 

Detailed Description

Video subsystem responsible for managing high-level graphics display (think: very fancy back-buffer).

A nom::Window is lifeless without its attached Renderer buddy!

Definition at line 49 of file Renderer.hpp.

Member Function Documentation

const Coords nom::Renderer::bounds ( void  ) const

Obtain the renderer's clipping rectangle bounds (X, Y, width & height) in pixels

Todo:
Test me!

Definition at line 135 of file Renderer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool nom::Renderer::clear ( void  ) const

Clear the whole rendering object; ignoring the viewport.

(to a rendering color, if set?)

This method is usually called after setting the rendering draw color.

Definition at line 159 of file Renderer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool nom::Renderer::fill ( const Color &  color = Color::Blue)

Fill the rendering target video display with a new color.

This combines two methods into one: set_color() and clear().

Default color fill is "BSOD (TM) Blue".

Definition at line 170 of file Renderer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool nom::Renderer::initialize ( SDL_WINDOW::RawPtr  window,
int32  rendering_driver = -1,
uint32  context_flags = SDL_RENDERER_ACCELERATED 
)

Initialize a Renderer instance with an existing, initialized SDL_Window

Initializes with the first rendering driver supporting our request flags Enables video acceleration when able

Definition at line 47 of file Renderer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const Point2i nom::Renderer::logical_resolution ( void  ) const

Get the current logical resolution size

Todo:
Test me!

Definition at line 84 of file Renderer.cpp.

Here is the call graph for this function:

void * nom::Renderer::pixels ( void  ) const

Obtain pixels buffer of the entire rendering target

Pixels pitch calculation

Definition at line 262 of file Renderer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool nom::Renderer::set_blend_mode ( const SDL_BlendMode  mode)

Set the color blending mode (fill and line).

SDL_BLENDMODE_NONE SDL_BLENDMODE_BLEND SDL_BLENDMODE_ADD SDL_BLENDMODE_MOD

Definition at line 229 of file Renderer.cpp.

Here is the call graph for this function:

bool nom::Renderer::set_bounds ( const Coords &  clip_bounds)

Set new clipping rectangle bounds for the rendering target.

Parameters
clip_boundsPassing nom::Coords::null will disable clipping on the target
Todo:
Test me!

Definition at line 239 of file Renderer.cpp.

Here is the call graph for this function:

bool nom::Renderer::set_logical_resolution ( int  width,
int  height 
)

Set device independent resolution for rendering

Parameters
widthWidth of the new logical resolution
heightHeight of the new logical resolution

Sets both a new view port and any necessary rescaling to fit within a fixed, logical resolution for rendering.

Definition at line 185 of file Renderer.cpp.

Here is the call graph for this function:

bool nom::Renderer::set_viewport ( const Coords &  rect)

Set a new drawing area for rendering

Parameters
rectRepresents the drawing area to update; passing Coords::null to set the viewport to the entire target
Note
When the window is resized, the current viewport is automatically resized to compensate.
Todo:
Test me!

Definition at line 195 of file Renderer.cpp.

Here is the call graph for this function:

const Point2i nom::Renderer::size ( void  ) const

Obtain the renderer's output size (width & height) in pixels

Returns
Point2i::null on ERR

Definition at line 121 of file Renderer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool nom::Renderer::update ( SDL_TEXTURE::RawPtr  input_texture)

Set an input texture source as the new rendering target.

Parameters
input_textureThe targeted texture

Definition at line 149 of file Renderer.cpp.

Here is the call graph for this function:

const Coords nom::Renderer::viewport ( void  ) const

Get the current viewport dimensions

Todo:
Test me!

Definition at line 93 of file Renderer.cpp.

Here is the call graph for this function:

Member Data Documentation

SDL_RENDERER::UniquePtr nom::Renderer::renderer_
protected

This is automatically released after the attached nom::Window has been destroyed.

Definition at line 165 of file Renderer.hpp.


The documentation for this class was generated from the following files: