Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
Renderer.hpp
1/*
2Copyright (C) 2016-2022,2024-2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGAMES_RENDERER_H
17#define AEONGAMES_RENDERER_H
18
19#include <string>
20#include <memory>
21#include <functional>
24#include "aeongames/Pipeline.hpp"
25
26namespace AeonGames
27{
28 class Frustum;
29 class StringId;
30 class Buffer;
31 class Texture;
32 class Mesh;
33 class Pipeline;
34 class Material;
35 class Window;
36 class BufferAccessor;
44 {
45 public:
47 DLL virtual ~Renderer() = 0;
50
53 virtual void LoadMesh ( const Mesh& aMesh ) = 0;
57 virtual void UnloadMesh ( const Mesh& aMesh ) = 0;
61 virtual void LoadPipeline ( const Pipeline& aPipeline ) = 0;
65 virtual void UnloadPipeline ( const Pipeline& aPipeline ) = 0;
69 virtual void LoadMaterial ( const Material& aMaterial ) = 0;
73 virtual void UnloadMaterial ( const Material& aMaterial ) = 0;
77 virtual void LoadTexture ( const Texture& aTexture ) = 0;
81 virtual void UnloadTexture ( const Texture& aTexture ) = 0;
83
86
90 virtual void AttachWindow ( void* aWindowId ) = 0;
95 virtual void DetachWindow ( void* aWindowId ) = 0;
100 virtual void SetProjectionMatrix ( void* aWindowId, const Matrix4x4& aMatrix ) = 0;
105 virtual void SetViewMatrix ( void* aWindowId, const Matrix4x4& aMatrix ) = 0;
113 virtual void SetClearColor ( void* aWindowId, float R, float G, float B, float A ) = 0;
121 virtual void ResizeViewport ( void* aWindowId, int32_t aX, int32_t aY, uint32_t aWidth, uint32_t aHeight ) = 0;
125 virtual void BeginRender ( void* aWindowId ) = 0;
129 virtual void EndRender ( void* aWindowId ) = 0;
143 virtual void Render ( void* aWindowId,
144 const Matrix4x4& aModelMatrix,
145 const Mesh& aMesh,
146 const Pipeline& aPipeline,
147 const Material* aMaterial = nullptr,
148 const BufferAccessor* aSkeleton = nullptr,
150 uint32_t aVertexStart = 0,
151 uint32_t aVertexCount = 0xffffffff,
152 uint32_t aInstanceCount = 1,
153 uint32_t aFirstInstance = 0 ) const = 0;
158 virtual const Frustum& GetFrustum ( void* aWindowId ) const = 0;
164 virtual BufferAccessor AllocateSingleFrameUniformMemory ( void* aWindowId, size_t aSize ) = 0;
166 };
167
174 DLL std::unique_ptr<Renderer> ConstructRenderer ( uint32_t aIdentifier, void* aWindow );
180 DLL std::unique_ptr<Renderer> ConstructRenderer ( const std::string& aIdentifier, void* aWindow );
186 DLL std::unique_ptr<Renderer> ConstructRenderer ( const StringId& aIdentifier, void* aWindow );
188 DLL bool RegisterRendererConstructor ( const StringId& aIdentifier, const std::function<std::unique_ptr<Renderer> ( void* ) >& aConstructor );
190 DLL bool UnregisterRendererConstructor ( const StringId& aIdentifier );
192 DLL void EnumerateRendererConstructors ( const std::function<bool ( const StringId& ) >& aEnumerator );
196 DLL std::vector<std::string> GetRendererConstructorNames();
198}
199#endif
Header for 4x4 matrix class.
Platform-specific macros, includes, and DLL export/import definitions.
Provides access to a region within a memory pool buffer.
Abstract interface for GPU/memory buffer operations.
Definition Buffer.hpp:24
View frustum defined by six clipping planes, extracted from a projection (or view-projection) matrix.
Definition Frustum.hpp:35
Represents a surface material with uniform properties and texture samplers.
Definition Material.hpp:38
4 by 4 matrix in colum mayor order.
Definition Matrix4x4.hpp:35
Represents a polygon mesh with vertex attributes and index data.
Definition Mesh.hpp:31
Rendering pipeline resource.
Definition Pipeline.hpp:122
Abstract base class for rendering backends.
Definition Renderer.hpp:44
virtual void UnloadPipeline(const Pipeline &aPipeline)=0
Unloads a rendering pipeline from the renderer.
virtual void SetClearColor(void *aWindowId, float R, float G, float B, float A)=0
Sets the color to be used to clear the window background.
virtual void LoadPipeline(const Pipeline &aPipeline)=0
Loads a rendering pipeline (shaders and state) into the renderer.
virtual DLL ~Renderer()=0
Virtual destructor.
virtual void UnloadMaterial(const Material &aMaterial)=0
Unloads material data from the renderer.
virtual void DetachWindow(void *aWindowId)=0
Detach a Window as a rendering surface.
virtual const Frustum & GetFrustum(void *aWindowId) const =0
Returns the view frustum for the given window surface.
virtual void AttachWindow(void *aWindowId)=0
Attach a Window as a rendering surface.
virtual void SetProjectionMatrix(void *aWindowId, const Matrix4x4 &aMatrix)=0
Sets the projection matrix for a specific window surface.
virtual void LoadTexture(const Texture &aTexture)=0
Loads a texture into GPU memory.
virtual void SetViewMatrix(void *aWindowId, const Matrix4x4 &aMatrix)=0
Sets the view matrix for a specific window surface.
virtual void ResizeViewport(void *aWindowId, int32_t aX, int32_t aY, uint32_t aWidth, uint32_t aHeight)=0
Resizes the specific window surface's viewport.
virtual void EndRender(void *aWindowId)=0
Ends the current render pass for the given window surface.
virtual void UnloadTexture(const Texture &aTexture)=0
Unloads a texture from GPU memory.
virtual void LoadMaterial(const Material &aMaterial)=0
Loads material data into the renderer.
virtual void BeginRender(void *aWindowId)=0
Begins a render pass for the given window surface.
virtual 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 =0
Issues a draw call for a mesh with the given pipeline and optional material.
virtual void LoadMesh(const Mesh &aMesh)=0
Loads mesh data into GPU memory.
virtual BufferAccessor AllocateSingleFrameUniformMemory(void *aWindowId, size_t aSize)=0
Allocates uniform buffer memory that is valid for a single frame.
virtual void UnloadMesh(const Mesh &aMesh)=0
Unloads mesh data from GPU memory.
CRC-based compile-time string identifier.
Definition StringId.hpp:31
Represents a 2D texture image resource.
Definition Texture.hpp:33
<- This is here just for the literals
Definition AABB.hpp:31
DLL bool RegisterRendererConstructor(const StringId &aIdentifier, const std::function< std::unique_ptr< Renderer >(void *) > &aConstructor)
Registers a Renderer loader for a specific identifier.
DLL std::unique_ptr< Renderer > ConstructRenderer(uint32_t aIdentifier, void *aWindow)
Constructs a Renderer identified by a numeric identifier.
DLL void EnumerateRendererConstructors(const std::function< bool(const StringId &) > &aEnumerator)
Enumerates Renderer loader identifiers via an enumerator functor.
DLL std::vector< std::string > GetRendererConstructorNames()
Returns the names of all registered Renderer constructors.
DLL bool UnregisterRendererConstructor(const StringId &aIdentifier)
Unregisters a Renderer loader for a specific identifier.
Topology
Primitive topology types for rendering.
Definition Pipeline.hpp:38
@ TRIANGLE_LIST
Independent triangles.
Definition Pipeline.hpp:45