RendererGL is an OpenGL-based renderer that implements IRenderer. It handles OpenGL initialization, shader loading, and drawing of 2D/3D objects, including sprites, meshes, and textures, using OpenGL API.
More...
#include <RendererGL.h>
|
| RendererGL () |
| Constructor for RendererGL. Initializes member variables and sets up OpenGL context.
|
|
virtual | ~RendererGL () |
| Destructor for RendererGL. Cleans up the OpenGL context and VertexArray objects.
|
|
| RendererGL (const RendererGL &)=delete |
|
RendererGL & | operator= (const RendererGL &)=delete |
|
bool | Initialize (Window &rWindow) override |
| Initializes the OpenGL renderer with the given window.
|
|
void | LoadShaders () |
| Loads the shaders used by the renderer for various components.
|
|
void | BeginDraw () override |
| Begins the drawing process, clearing the screen and setting up necessary OpenGL states.
|
|
void | Draw () override |
| Draws all the rendered components (meshes, sprites, etc.).
|
|
void | EndDraw () override |
| Ends the drawing process by swapping the buffers.
|
|
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 the outline of a rectangle on the screen with the specified color.
|
|
void | DrawAllSprites () |
| Draws all sprites currently in the render queue.
|
|
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.
|
|
void | DrawAllMeshes () |
| Draws all meshes currently in the render queue.
|
|
void | DrawMesh (Mesh *pMesh, int pTextureIndex, const Matrix4 &transform, Vector2 tiling=Vector2::ONE) override |
| Draws a mesh with the specified texture index and transformation.
|
|
void | SetViewMatrix (const Matrix4 &pView) override |
| Sets the view matrix used for rendering.
|
|
void | Close () override |
| Closes the OpenGL context and cleans up resources.
|
|
RendererType | GetType () override |
| Returns the type of renderer (OpenGL).
|
|
virtual | ~IRenderer ()=default |
|
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.
|
|
RendererGL is an OpenGL-based renderer that implements IRenderer. It handles OpenGL initialization, shader loading, and drawing of 2D/3D objects, including sprites, meshes, and textures, using OpenGL API.
◆ RendererGL() [1/2]
RendererGL::RendererGL |
( |
| ) |
|
Constructor for RendererGL. Initializes member variables and sets up OpenGL context.
◆ ~RendererGL()
RendererGL::~RendererGL |
( |
| ) |
|
|
virtual |
◆ RendererGL() [2/2]
◆ BeginDraw()
void RendererGL::BeginDraw |
( |
| ) |
|
|
overridevirtual |
Begins the drawing process, clearing the screen and setting up necessary OpenGL states.
Implements IRenderer.
◆ Close()
void RendererGL::Close |
( |
| ) |
|
|
overridevirtual |
Closes the OpenGL context and cleans up resources.
Implements IRenderer.
◆ Draw()
void RendererGL::Draw |
( |
| ) |
|
|
overridevirtual |
Draws all the rendered components (meshes, sprites, etc.).
Implements IRenderer.
◆ DrawAllMeshes()
void RendererGL::DrawAllMeshes |
( |
| ) |
|
Draws all meshes currently in the render queue.
◆ DrawAllSprites()
void RendererGL::DrawAllSprites |
( |
| ) |
|
Draws all sprites currently in the render queue.
◆ DrawMesh()
Draws a mesh with the specified texture index and transformation.
- Parameters
-
pMesh | The mesh to be drawn. |
pTextureIndex | The texture index of the mesh. |
transform | The transformation matrix to apply to the mesh. |
tiling | The tiling factor for the texture. |
Reimplemented from IRenderer.
◆ DrawRect()
Draws a filled rectangle on the screen with the specified color.
- Parameters
-
rRect | The rectangle to be drawn. |
pColor | The color of the rectangle. |
Implements IRenderer.
◆ DrawRectLine()
void RendererGL::DrawRectLine |
( |
const Rectangle & | rRect, |
|
|
Color | pColor ) |
|
overridevirtual |
Draws the outline of a rectangle on the screen with the specified color.
- Parameters
-
rRect | The rectangle to be drawn. |
pColor | The color of the rectangle outline. |
Implements IRenderer.
◆ DrawSprite()
Draws a sprite on the screen using the specified texture and transformation.
- Parameters
-
rOwner | The actor owning the sprite (used for context, not directly here). |
rTexture | Pointer to the texture to render. |
rec | The rectangle that defines the position and size of the sprite on screen. |
flip | Specifies sprite flipping (horizontal, vertical, etc.). |
Implements IRenderer.
◆ EndDraw()
void RendererGL::EndDraw |
( |
| ) |
|
|
overridevirtual |
Ends the drawing process by swapping the buffers.
Implements IRenderer.
◆ GetCubeMesh()
Mesh * RendererGL::GetCubeMesh |
( |
| ) |
|
|
static |
Gets the cube mesh used for rendering.
- Returns
- A pointer to the cube mesh.
◆ GetType()
◆ Initialize()
bool RendererGL::Initialize |
( |
Window & | rWindow | ) |
|
|
overridevirtual |
Initializes the OpenGL renderer with the given window.
- Parameters
-
rWindow | The window to render the graphics onto. |
- Returns
- Returns true if initialization is successful, false otherwise.
Implements IRenderer.
◆ LoadShaders()
void RendererGL::LoadShaders |
( |
| ) |
|
Loads the shaders used by the renderer for various components.
◆ operator=()
◆ SetViewMatrix()
void RendererGL::SetViewMatrix |
( |
const Matrix4 & | pView | ) |
|
|
overridevirtual |
Sets the view matrix used for rendering.
- Parameters
-
pView | The new view matrix. |
Reimplemented from IRenderer.
◆ mGrassShaderProgram
◆ mSandShaderProgram
◆ mSimpleMeshShaderProgram
◆ mTesselationMeshShaderProgram
◆ mWaveShaderProgram
The documentation for this class was generated from the following files: