Claire's Game Engine
Full C++ Engine using OpenGL
Loading...
Searching...
No Matches
RendererSDL Class Reference

RendererSDL is an SDL-based renderer that implements IRenderer. It manages the SDL rendering context, handles drawing 2D primitives (like rectangles), and textures (like sprites) using SDL's rendering functions. More...

#include <RendererSDL.h>

Inheritance diagram for RendererSDL:
IRenderer

Public Member Functions

 RendererSDL ()
 Constructor for RendererSDL. Initializes the SDL_Renderer to a nullptr.
 
 RendererSDL (const IRenderer &)=delete
 
IRendereroperator= (const IRenderer &)=delete
 
bool Initialize (Window &rWindow)
 Initializes the SDL renderer with the specified window.
 
void BeginDraw () override
 Begins the drawing process by setting the background color and clearing the screen.
 
void Draw () override
 Draws all render components to the screen.
 
void EndDraw () override
 Ends the drawing process by presenting the rendered frame to the screen.
 
void Close () override
 Closes the SDL renderer and cleans up resources.
 
SDL_Renderer * GetSDLRender ()
 Gets the SDL_Renderer instance used by this renderer.
 
void DrawRect (const Rectangle &rRect, Color pColor) override
 Draws a filled rectangle on the screen with the specified color.
 
void DrawRectLine (const Rectangle &rRect, Color pColor) override
 Draws only the outline (border) of a rectangle on the screen.
 
void DrawSprite (const Actor &rOwner, Texture *rTexture, Rectangle rec, Flip flip=Flip::None) override
 Draws a sprite on the screen using the specified texture and transformation.
 
RendererType GetType () override
 Gets the renderer type, which is SDL.
 
- Public Member Functions inherited from IRenderer
virtual ~IRenderer ()=default
 
virtual void DrawMesh (Mesh *pMesh, int pTextureIndex, const Matrix4 &transform, Vector2 tiling=Vector2::ONE)
 Draws a mesh with a specific texture index and transformation.
 
void AddRenderComponent (RenderComponent *pRenderComponent)
 Adds a render component to the list of components to be rendered.
 
void RemoveRenderComponent (RenderComponent *pRenderComponent)
 Removes a render component from the list of components to be rendered.
 
void AddDebugRender (DebugRenderInterface *pDebugRender)
 Adds a debug render component to the renderer.
 
void RemoveDebugRender (DebugRenderInterface *pDebugRender)
 Removes a debug render component from the renderer.
 
virtual void SetViewMatrix (const Matrix4 &pView)
 Sets the view matrix for the renderer. This is usually used for camera transformations.
 

Additional Inherited Members

- Public Types inherited from IRenderer
enum class  Flip { None = SDL_FLIP_NONE , Horizontal = SDL_FLIP_HORIZONTAL , Vertical = SDL_FLIP_VERTICAL }
 Enum to represent the different flipping modes for rendering sprites. This allows flipping a sprite horizontally or vertically, or no flipping at all. More...
 
enum class  RendererType { SDL , OPENGL }
 Enum representing the type of renderer (either SDL or OpenGL). This helps identify which underlying rendering system is being used. More...
 
- Protected Attributes inherited from IRenderer
std::vector< RenderComponent * > mViewportRenderComponents
 List of render components associated with the viewport.
 
std::vector< RenderComponent * > mWorldRenderComponents
 List of render components associated with the world (3D space)
 
std::vector< DebugRenderInterface * > mDebugRenders
 List of debug render components.
 

Detailed Description

RendererSDL is an SDL-based renderer that implements IRenderer. It manages the SDL rendering context, handles drawing 2D primitives (like rectangles), and textures (like sprites) using SDL's rendering functions.

Constructor & Destructor Documentation

◆ RendererSDL() [1/2]

RendererSDL::RendererSDL ( )

Constructor for RendererSDL. Initializes the SDL_Renderer to a nullptr.

◆ RendererSDL() [2/2]

RendererSDL::RendererSDL ( const IRenderer & )
delete

Member Function Documentation

◆ BeginDraw()

void RendererSDL::BeginDraw ( )
overridevirtual

Begins the drawing process by setting the background color and clearing the screen.

Implements IRenderer.

◆ Close()

void RendererSDL::Close ( )
overridevirtual

Closes the SDL renderer and cleans up resources.

Implements IRenderer.

◆ Draw()

void RendererSDL::Draw ( )
overridevirtual

Draws all render components to the screen.

Implements IRenderer.

◆ DrawRect()

void RendererSDL::DrawRect ( const Rectangle & rRect,
Color pColor )
overridevirtual

Draws a filled rectangle on the screen with the specified color.

Parameters
rRectThe rectangle to be drawn.
pColorThe color of the rectangle.

Implements IRenderer.

◆ DrawRectLine()

void RendererSDL::DrawRectLine ( const Rectangle & rRect,
Color pColor )
overridevirtual

Draws only the outline (border) of a rectangle on the screen.

Parameters
rRectThe rectangle defining the position and size of the rectangle.
pColorThe color of the rectangle's border.

Implements IRenderer.

◆ DrawSprite()

void RendererSDL::DrawSprite ( const Actor & rOwner,
Texture * rTexture,
Rectangle rec,
Flip flip = Flip::None )
overridevirtual

Draws a sprite on the screen using the specified texture and transformation.

Parameters
rOwnerThe actor owning the sprite (used for context, not directly here).
rTexturePointer to the texture to render.
recThe rectangle that defines the position and size of the sprite on screen.
flipSpecifies sprite flipping (horizontal, vertical, etc.).

Implements IRenderer.

◆ EndDraw()

void RendererSDL::EndDraw ( )
overridevirtual

Ends the drawing process by presenting the rendered frame to the screen.

Implements IRenderer.

◆ GetSDLRender()

SDL_Renderer * RendererSDL::GetSDLRender ( )

Gets the SDL_Renderer instance used by this renderer.

Returns
The SDL_Renderer object.

◆ GetType()

IRenderer::RendererType RendererSDL::GetType ( )
overridevirtual

Gets the renderer type, which is SDL.

Returns
RendererType::SDL.

Implements IRenderer.

◆ Initialize()

bool RendererSDL::Initialize ( Window & rWindow)
virtual

Initializes the SDL renderer with the specified window.

Parameters
rWindowThe window to render the graphics onto.
Returns
Returns true if initialization is successful, false otherwise.

Implements IRenderer.

◆ operator=()

IRenderer & RendererSDL::operator= ( const IRenderer & )
delete

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