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

IRenderer is an abstract base class for rendering systems. It defines methods for initializing, drawing, and managing graphics resources, which must be implemented by specific renderer classes (e.g., OpenGL, SDL). More...

#include <IRenderer.h>

Inheritance diagram for IRenderer:
RendererGL RendererSDL

Public Types

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...
 

Public Member Functions

virtual ~IRenderer ()=default
 
virtual bool Initialize (Window &rWindow)=0
 Initializes the renderer with the provided window.
 
virtual void BeginDraw ()=0
 Prepares for drawing, called before rendering starts.
 
virtual void Draw ()=0
 Draws the rendered objects to the screen. This should be called after all draw calls have been issued.
 
virtual void EndDraw ()=0
 
virtual void Close ()=0
 Closes the renderer and releases any allocated resources.
 
virtual RendererType GetType ()=0
 Gets the type of the renderer being used.
 
virtual void DrawRect (const Rectangle &rRect, Color pColor)=0
 Draws a filled rectangle on the screen.
 
virtual void DrawRectLine (const Rectangle &rRect, Color pColor)=0
 Draws only the outline (border) of a rectangle on the screen.
 
virtual void DrawSprite (const Actor &rOwner, Texture *rTexture, Rectangle rec, Flip flip=Flip::None)=0
 Draws a 2D sprite on the screen using the provided texture and rectangle.
 
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.
 

Protected Attributes

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

IRenderer is an abstract base class for rendering systems. It defines methods for initializing, drawing, and managing graphics resources, which must be implemented by specific renderer classes (e.g., OpenGL, SDL).

Member Enumeration Documentation

◆ Flip

enum class IRenderer::Flip
strong

Enum to represent the different flipping modes for rendering sprites. This allows flipping a sprite horizontally or vertically, or no flipping at all.

Enumerator
None 
Horizontal 
Vertical 

◆ RendererType

enum class IRenderer::RendererType
strong

Enum representing the type of renderer (either SDL or OpenGL). This helps identify which underlying rendering system is being used.

Enumerator
SDL 
OPENGL 

Constructor & Destructor Documentation

◆ ~IRenderer()

virtual IRenderer::~IRenderer ( )
virtualdefault

Member Function Documentation

◆ AddDebugRender()

void IRenderer::AddDebugRender ( DebugRenderInterface * pDebugRender)

Adds a debug render component to the renderer.

Parameters
pDebugRenderThe debug render interface to be added.

◆ AddRenderComponent()

void IRenderer::AddRenderComponent ( RenderComponent * pRenderComponent)

Adds a render component to the list of components to be rendered.

Parameters
pRenderComponentThe render component to be added.

◆ BeginDraw()

virtual void IRenderer::BeginDraw ( )
pure virtual

Prepares for drawing, called before rendering starts.

Implemented in RendererGL, and RendererSDL.

◆ Close()

virtual void IRenderer::Close ( )
pure virtual

Closes the renderer and releases any allocated resources.

Implemented in RendererGL, and RendererSDL.

◆ Draw()

virtual void IRenderer::Draw ( )
pure virtual

Draws the rendered objects to the screen. This should be called after all draw calls have been issued.

Implemented in RendererGL, and RendererSDL.

◆ DrawMesh()

virtual void IRenderer::DrawMesh ( Mesh * pMesh,
int pTextureIndex,
const Matrix4 & transform,
Vector2 tiling = Vector2::ONE )
inlinevirtual

Draws a mesh with a specific texture index and transformation.

Parameters
pMeshThe mesh to be drawn.
pTextureIndexIndex of the mesh's texture to use.
transformWorld transformation matrix.
tilingTexture tiling to apply.

Reimplemented in RendererGL.

◆ DrawRect()

virtual void IRenderer::DrawRect ( const Rectangle & rRect,
Color pColor )
pure virtual

Draws a filled rectangle on the screen.

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

Implemented in RendererGL, and RendererSDL.

◆ DrawRectLine()

virtual void IRenderer::DrawRectLine ( const Rectangle & rRect,
Color pColor )
pure virtual

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.

Implemented in RendererGL, and RendererSDL.

◆ DrawSprite()

virtual void IRenderer::DrawSprite ( const Actor & rOwner,
Texture * rTexture,
Rectangle rec,
Flip flip = Flip::None )
pure virtual

Draws a 2D sprite on the screen using the provided texture and rectangle.

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

Implemented in RendererGL, and RendererSDL.

◆ EndDraw()

virtual void IRenderer::EndDraw ( )
pure virtual

@briefCompletes the drawing process.

Implemented in RendererGL, and RendererSDL.

◆ GetType()

virtual RendererType IRenderer::GetType ( )
pure virtual

Gets the type of the renderer being used.

Returns
The renderer type (SDL or OpenGL).

Implemented in RendererGL, and RendererSDL.

◆ Initialize()

virtual bool IRenderer::Initialize ( Window & rWindow)
pure virtual

Initializes the renderer with the provided window.

Parameters
rWindowThe window that the renderer will be associated with.
Returns
True if the initialization was successful, false otherwise.

Implemented in RendererGL, and RendererSDL.

◆ RemoveDebugRender()

void IRenderer::RemoveDebugRender ( DebugRenderInterface * pDebugRender)

Removes a debug render component from the renderer.

Parameters
pDebugRenderThe debug render interface to be removed.

◆ RemoveRenderComponent()

void IRenderer::RemoveRenderComponent ( RenderComponent * pRenderComponent)

Removes a render component from the list of components to be rendered.

Parameters
pRenderComponentThe render component to be removed.

◆ SetViewMatrix()

virtual void IRenderer::SetViewMatrix ( const Matrix4 & pView)
inlinevirtual

Sets the view matrix for the renderer. This is usually used for camera transformations.

Parameters
pViewThe view transformation matrix (e.g., camera position and orientation).

Reimplemented in RendererGL.

Member Data Documentation

◆ mDebugRenders

std::vector<DebugRenderInterface*> IRenderer::mDebugRenders
protected

List of debug render components.

◆ mViewportRenderComponents

std::vector<RenderComponent*> IRenderer::mViewportRenderComponents
protected

List of render components associated with the viewport.

◆ mWorldRenderComponents

std::vector<RenderComponent*> IRenderer::mWorldRenderComponents
protected

List of render components associated with the world (3D space)


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