Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
AeonGames::OpenGLRenderer Class Reference

OpenGL rendering backend implementing the Renderer interface. More...

#include <C:/Code/AeonEngine/engine/renderers/opengl/OpenGLRenderer.hpp>

Inheritance diagram for AeonGames::OpenGLRenderer:
Inheritance graph
Collaboration diagram for AeonGames::OpenGLRenderer:
Collaboration graph

Public Member Functions

 OpenGLRenderer (void *aWindow)
 Construct from a native window handle.
void LoadMesh (const Mesh &aMesh) final
 Loads mesh data into GPU memory.
void UnloadMesh (const Mesh &aMesh) final
 Unloads mesh data from GPU memory.
void * GetContext () const
 Get the platform-specific OpenGL rendering context.
GLuint GetVertexArrayObject () const
 Get the shared vertex array object.
GLuint GetOverlayProgram () const
 Get the overlay shader program identifier.
GLuint GetOverlayQuad () const
 Get the overlay screen-quad buffer.
void BindMesh (const Mesh &aMesh)
 Bind a mesh for subsequent draw calls.
void BindPipeline (const Pipeline &aPipeline)
 Bind a pipeline (shader program) for rendering.
void SetMaterial (const Material &aMaterial)
 Set the active material for rendering.
void SetSkeleton (const BufferAccessor &aSkeletonBuffer) const
 Upload skeleton joint matrices for skinned rendering.
void SetMatrices (const OpenGLBuffer &aMatricesBuffer) const
 Bind the matrices uniform buffer for the current draw.
void LoadPipeline (const Pipeline &aPipeline) final
 Loads a rendering pipeline (shaders and state) into the renderer.
void UnloadPipeline (const Pipeline &aPipeline) final
 Unloads a rendering pipeline from the renderer.
void LoadMaterial (const Material &aMaterial) final
 Loads material data into the renderer.
void UnloadMaterial (const Material &aMaterial) final
 Unloads material data from the renderer.
void LoadTexture (const Texture &aTexture) final
 Loads a texture into GPU memory.
void UnloadTexture (const Texture &aTexture) final
 Unloads a texture from GPU memory.
GLuint GetTextureId (const Texture &aTexture)
 Get the OpenGL texture identifier for a loaded texture.
void AttachWindow (void *aWindowId) final
 Attach a Window as a rendering surface.
void DetachWindow (void *aWindowId) final
 Detach a Window as a rendering surface.
void SetProjectionMatrix (void *aWindowId, const Matrix4x4 &aMatrix) final
 Sets the projection matrix for a specific window surface.
void SetViewMatrix (void *aWindowId, const Matrix4x4 &aMatrix) final
 Sets the view matrix for a specific window surface.
void SetClearColor (void *aWindowId, float R, float G, float B, float A) final
 Sets the color to be used to clear the window background.
void ResizeViewport (void *aWindowId, int32_t aX, int32_t aY, uint32_t aWidth, uint32_t aHeight) final
 Resizes the specific window surface's viewport.
void BeginRender (void *aWindowId) final
 Begins a render pass for the given window surface.
void EndRender (void *aWindowId) final
 Ends the current render pass for the given window surface.
void Render (void *aWindowId, const Matrix4x4 &aModelMatrix, const Mesh &aMesh, const Pipeline &aPipeline, const Material *aMaterial=nullptr, const BufferAccessor *aSkeleton=nullptr, Topology aTopology=Topology::TRIANGLE_LIST, uint32_t aVertexStart=0, uint32_t aVertexCount=0xffffffff, uint32_t aInstanceCount=1, uint32_t aFirstInstance=0) const final
 Issues a draw call for a mesh with the given pipeline and optional material.
const FrustumGetFrustum (void *aWindowId) const final
 Returns the view frustum for the given window surface.
BufferAccessor AllocateSingleFrameUniformMemory (void *aWindowId, size_t aSize) final
 Allocates uniform buffer memory that is valid for a single frame.
Public Member Functions inherited from AeonGames::Renderer
virtual DLL ~Renderer ()=0
 Virtual destructor.

Protected Member Functions

void InitializeOverlay ()
 Initialize overlay shader program and quad buffer.
void FinalizeOverlay ()
 Release overlay shader program and quad buffer.

Protected Attributes

GLuint mVertexArrayObject {}
 General VAO.
GLuint mOverlayProgram {}
 Raw overlay shader program.
OpenGLBuffer mOverlayQuad {}
 Overlay quadrilateral.
OpenGLPipelinemCurrentPipeline {nullptr}
 Currently bound pipeline.
std::unordered_map< size_t, OpenGLPipelinemPipelineStore {}
 Loaded pipeline cache.
std::unordered_map< size_t, OpenGLMaterialmMaterialStore {}
 Loaded material cache.
std::unordered_map< size_t, OpenGLMeshmMeshStore {}
 Loaded mesh cache.
std::unordered_map< size_t, OpenGLTexturemTextureStore {}
 Loaded texture cache.
std::unordered_map< void *, OpenGLWindowmWindowStore {}
 Attached window map.

Detailed Description

OpenGL rendering backend implementing the Renderer interface.

Definition at line 44 of file OpenGLRenderer.hpp.

Member Function Documentation

◆ AllocateSingleFrameUniformMemory()

BufferAccessor AeonGames::OpenGLRenderer::AllocateSingleFrameUniformMemory ( void * aWindowId,
size_t aSize )
finalvirtual

Allocates uniform buffer memory that is valid for a single frame.

Parameters
aWindowIdPlatform dependent window handle.
aSizeSize in bytes of the requested allocation.
Returns
A BufferAccessor to the allocated memory.

Implements AeonGames::Renderer.

Definition at line 780 of file OpenGLRenderer.cpp.

◆ AttachWindow()

void AeonGames::OpenGLRenderer::AttachWindow ( void * aWindowId)
finalvirtual

Attach a Window as a rendering surface.

Parameters
aWindowIdPlatform depended window handle.

Implements AeonGames::Renderer.

Definition at line 669 of file OpenGLRenderer.cpp.

◆ BeginRender()

void AeonGames::OpenGLRenderer::BeginRender ( void * aWindowId)
finalvirtual

Begins a render pass for the given window surface.

Parameters
aWindowIdPlatform dependent window handle.

Implements AeonGames::Renderer.

Definition at line 732 of file OpenGLRenderer.cpp.

◆ BindMesh()

void AeonGames::OpenGLRenderer::BindMesh ( const Mesh & aMesh)

Bind a mesh for subsequent draw calls.

Definition at line 524 of file OpenGLRenderer.cpp.

◆ BindPipeline()

void AeonGames::OpenGLRenderer::BindPipeline ( const Pipeline & aPipeline)

Bind a pipeline (shader program) for rendering.

Definition at line 557 of file OpenGLRenderer.cpp.

◆ DetachWindow()

void AeonGames::OpenGLRenderer::DetachWindow ( void * aWindowId)
finalvirtual

Detach a Window as a rendering surface.

Parameters
aWindowIdPlatform depended window handle.

Implements AeonGames::Renderer.

Definition at line 683 of file OpenGLRenderer.cpp.

◆ EndRender()

void AeonGames::OpenGLRenderer::EndRender ( void * aWindowId)
finalvirtual

Ends the current render pass for the given window surface.

Parameters
aWindowIdPlatform dependent window handle.

Implements AeonGames::Renderer.

Definition at line 741 of file OpenGLRenderer.cpp.

◆ FinalizeOverlay()

void AeonGames::OpenGLRenderer::FinalizeOverlay ( )
protected

Release overlay shader program and quad buffer.

Definition at line 482 of file OpenGLRenderer.cpp.

◆ GetContext()

void * AeonGames::OpenGLRenderer::GetContext ( ) const

Get the platform-specific OpenGL rendering context.

Definition at line 791 of file OpenGLRenderer.cpp.

◆ GetFrustum()

const Frustum & AeonGames::OpenGLRenderer::GetFrustum ( void * aWindowId) const
finalvirtual

Returns the view frustum for the given window surface.

Parameters
aWindowIdPlatform dependent window handle.
Returns
A const reference to the current view frustum.

Implements AeonGames::Renderer.

Definition at line 770 of file OpenGLRenderer.cpp.

◆ GetOverlayProgram()

GLuint AeonGames::OpenGLRenderer::GetOverlayProgram ( ) const

Get the overlay shader program identifier.

Definition at line 659 of file OpenGLRenderer.cpp.

◆ GetOverlayQuad()

GLuint AeonGames::OpenGLRenderer::GetOverlayQuad ( ) const

Get the overlay screen-quad buffer.

Definition at line 664 of file OpenGLRenderer.cpp.

◆ GetTextureId()

GLuint AeonGames::OpenGLRenderer::GetTextureId ( const Texture & aTexture)

Get the OpenGL texture identifier for a loaded texture.

Definition at line 643 of file OpenGLRenderer.cpp.

◆ GetVertexArrayObject()

GLuint AeonGames::OpenGLRenderer::GetVertexArrayObject ( ) const

Get the shared vertex array object.

Definition at line 654 of file OpenGLRenderer.cpp.

◆ InitializeOverlay()

void AeonGames::OpenGLRenderer::InitializeOverlay ( )
protected

Initialize overlay shader program and quad buffer.

Definition at line 406 of file OpenGLRenderer.cpp.

◆ LoadMaterial()

void AeonGames::OpenGLRenderer::LoadMaterial ( const Material & aMaterial)
finalvirtual

Loads material data into the renderer.

Parameters
aMaterialThe material to load.

Implements AeonGames::Renderer.

Definition at line 610 of file OpenGLRenderer.cpp.

◆ LoadMesh()

void AeonGames::OpenGLRenderer::LoadMesh ( const Mesh & aMesh)
finalvirtual

Loads mesh data into GPU memory.

Parameters
aMeshThe mesh to load.

Implements AeonGames::Renderer.

Definition at line 504 of file OpenGLRenderer.cpp.

◆ LoadPipeline()

void AeonGames::OpenGLRenderer::LoadPipeline ( const Pipeline & aPipeline)
finalvirtual

Loads a rendering pipeline (shaders and state) into the renderer.

Parameters
aPipelineThe pipeline to load.

Implements AeonGames::Renderer.

Definition at line 539 of file OpenGLRenderer.cpp.

◆ LoadTexture()

void AeonGames::OpenGLRenderer::LoadTexture ( const Texture & aTexture)
finalvirtual

Loads a texture into GPU memory.

Parameters
aTextureThe texture to load.

Implements AeonGames::Renderer.

Definition at line 626 of file OpenGLRenderer.cpp.

◆ Render()

void AeonGames::OpenGLRenderer::Render ( void * aWindowId,
const Matrix4x4 & aModelMatrix,
const Mesh & aMesh,
const Pipeline & aPipeline,
const Material * aMaterial = nullptr,
const BufferAccessor * aSkeleton = nullptr,
Topology aTopology = Topology::TRIANGLE_LIST,
uint32_t aVertexStart = 0,
uint32_t aVertexCount = 0xffffffff,
uint32_t aInstanceCount = 1,
uint32_t aFirstInstance = 0 ) const
finalvirtual

Issues a draw call for a mesh with the given pipeline and optional material.

Parameters
aWindowIdPlatform dependent window handle.
aModelMatrixModel transformation matrix.
aMeshMesh to render.
aPipelinePipeline (shaders/state) to use.
aMaterialOptional material to bind.
aSkeletonOptional skeleton buffer for skinned meshes.
aTopologyPrimitive topology (default: TRIANGLE_LIST).
aVertexStartFirst vertex index.
aVertexCountNumber of vertices to draw (default: all).
aInstanceCountNumber of instances to draw.
aFirstInstanceIndex of the first instance.

Implements AeonGames::Renderer.

Definition at line 750 of file OpenGLRenderer.cpp.

◆ ResizeViewport()

void AeonGames::OpenGLRenderer::ResizeViewport ( void * aWindowId,
int32_t aX,
int32_t aY,
uint32_t aWidth,
uint32_t aHeight )
finalvirtual

Resizes the specific window surface's viewport.

Parameters
aWindowIdPlatform dependent window handle.
aXX coordinate of the viewport.
aYY coordinate of the viewport.
aWidthWidth of the viewport.
aHeightHeight of the viewport.

Implements AeonGames::Renderer.

Definition at line 722 of file OpenGLRenderer.cpp.

◆ SetClearColor()

void AeonGames::OpenGLRenderer::SetClearColor ( void * aWindowId,
float R,
float G,
float B,
float A )
finalvirtual

Sets the color to be used to clear the window background.

Parameters
aWindowIdPlatform depended window handle.
RRed component of the clear color.
GGreen component of the clear color.
BBlue component of the clear color.
AAlpha component of the clear color.

Implements AeonGames::Renderer.

Definition at line 713 of file OpenGLRenderer.cpp.

◆ SetMaterial()

void AeonGames::OpenGLRenderer::SetMaterial ( const Material & aMaterial)

Set the active material for rendering.

Definition at line 570 of file OpenGLRenderer.cpp.

◆ SetMatrices()

void AeonGames::OpenGLRenderer::SetMatrices ( const OpenGLBuffer & aMatricesBuffer) const

Bind the matrices uniform buffer for the current draw.

Definition at line 596 of file OpenGLRenderer.cpp.

◆ SetProjectionMatrix()

void AeonGames::OpenGLRenderer::SetProjectionMatrix ( void * aWindowId,
const Matrix4x4 & aMatrix )
finalvirtual

Sets the projection matrix for a specific window surface.

Parameters
aWindowIdPlatform depended window handle.
aMatrixThe projection matrix.

Implements AeonGames::Renderer.

Definition at line 693 of file OpenGLRenderer.cpp.

◆ SetSkeleton()

void AeonGames::OpenGLRenderer::SetSkeleton ( const BufferAccessor & aSkeletonBuffer) const

Upload skeleton joint matrices for skinned rendering.

Definition at line 582 of file OpenGLRenderer.cpp.

◆ SetViewMatrix()

void AeonGames::OpenGLRenderer::SetViewMatrix ( void * aWindowId,
const Matrix4x4 & aMatrix )
finalvirtual

Sets the view matrix for a specific window surface.

Parameters
aWindowIdPlatform depended window handle.
aMatrixThe view matrix.

Implements AeonGames::Renderer.

Definition at line 703 of file OpenGLRenderer.cpp.

◆ UnloadMaterial()

void AeonGames::OpenGLRenderer::UnloadMaterial ( const Material & aMaterial)
finalvirtual

Unloads material data from the renderer.

Parameters
aMaterialThe material to unload.

Implements AeonGames::Renderer.

Definition at line 619 of file OpenGLRenderer.cpp.

◆ UnloadMesh()

void AeonGames::OpenGLRenderer::UnloadMesh ( const Mesh & aMesh)
finalvirtual

Unloads mesh data from GPU memory.

Parameters
aMeshThe mesh to unload.

Implements AeonGames::Renderer.

Definition at line 515 of file OpenGLRenderer.cpp.

◆ UnloadPipeline()

void AeonGames::OpenGLRenderer::UnloadPipeline ( const Pipeline & aPipeline)
finalvirtual

Unloads a rendering pipeline from the renderer.

Parameters
aPipelineThe pipeline to unload.

Implements AeonGames::Renderer.

Definition at line 550 of file OpenGLRenderer.cpp.

◆ UnloadTexture()

void AeonGames::OpenGLRenderer::UnloadTexture ( const Texture & aTexture)
finalvirtual

Unloads a texture from GPU memory.

Parameters
aTextureThe texture to unload.

Implements AeonGames::Renderer.

Definition at line 636 of file OpenGLRenderer.cpp.

Member Data Documentation

◆ mCurrentPipeline

OpenGLPipeline* AeonGames::OpenGLRenderer::mCurrentPipeline {nullptr}
protected

Currently bound pipeline.

Definition at line 134 of file OpenGLRenderer.hpp.

◆ mMaterialStore

std::unordered_map<size_t, OpenGLMaterial> AeonGames::OpenGLRenderer::mMaterialStore {}
protected

Loaded material cache.

Definition at line 136 of file OpenGLRenderer.hpp.

◆ mMeshStore

std::unordered_map<size_t, OpenGLMesh> AeonGames::OpenGLRenderer::mMeshStore {}
protected

Loaded mesh cache.

Definition at line 137 of file OpenGLRenderer.hpp.

◆ mPipelineStore

std::unordered_map<size_t, OpenGLPipeline> AeonGames::OpenGLRenderer::mPipelineStore {}
protected

Loaded pipeline cache.

Definition at line 135 of file OpenGLRenderer.hpp.

◆ mTextureStore

std::unordered_map<size_t, OpenGLTexture> AeonGames::OpenGLRenderer::mTextureStore {}
protected

Loaded texture cache.

Definition at line 138 of file OpenGLRenderer.hpp.

◆ mVertexArrayObject

GLuint AeonGames::OpenGLRenderer::mVertexArrayObject {}
protected

General VAO.

Definition at line 121 of file OpenGLRenderer.hpp.

◆ mWindowStore

std::unordered_map<void*, OpenGLWindow> AeonGames::OpenGLRenderer::mWindowStore {}
protected

Attached window map.

Definition at line 139 of file OpenGLRenderer.hpp.


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