16#ifndef AEONGAMES_OPENGLRENDERER_HPP
17#define AEONGAMES_OPENGLRENDERER_HPP
19#include <unordered_map>
20#include "aeongames/Renderer.hpp"
23#include "OpenGLFunctions.hpp"
24#include "OpenGLBuffer.hpp"
25#include "OpenGLMesh.hpp"
26#include "OpenGLPipeline.hpp"
27#include "OpenGLMaterial.hpp"
28#include "OpenGLTexture.hpp"
29#include "OpenGLWindow.hpp"
85 void SetClearColor (
void* aWindowId,
float R,
float G,
float B,
float A )
final;
86 void ResizeViewport (
void* aWindowId, int32_t aX, int32_t aY, uint32_t aWidth, uint32_t aHeight )
final;
89 void Render (
void* aWindowId,
96 uint32_t aVertexStart = 0,
97 uint32_t aVertexCount = 0xffffffff,
98 uint32_t aInstanceCount = 1,
99 uint32_t aFirstInstance = 0 ) const final;
103 bool MakeCurrent ( HDC aDeviceContext =
nullptr );
104#elif defined(__unix__)
105 Display* GetDisplay()
const;
106 bool MakeCurrent ( ::Window aWindow = None );
115 HDC mDeviceContext{};
116 HGLRC mOpenGLContext{};
117#elif defined(__unix__)
118 GLXContext mOpenGLContext {None};
141 static std::atomic<size_t> mRendererCount;
143 static Display* mDisplay;
Header for 4x4 matrix class.
Provides the DLL_PROTOBUF export/import macro for protobuf wrapper classes.
Provides access to a region within a memory pool buffer.
View frustum defined by six clipping planes, extracted from a projection (or view-projection) matrix.
Represents a surface material with uniform properties and texture samplers.
4 by 4 matrix in colum mayor order.
Represents a polygon mesh with vertex attributes and index data.
OpenGL GPU buffer wrapper implementing the Buffer interface.
OpenGL mesh wrapper managing vertex and index buffers.
OpenGL shader program pipeline with attribute and uniform reflection.
void LoadPipeline(const Pipeline &aPipeline) final
Loads a rendering pipeline (shaders and state) into the renderer.
void FinalizeOverlay()
Release overlay shader program and quad buffer.
void UnloadTexture(const Texture &aTexture) final
Unloads a texture from GPU memory.
void LoadMaterial(const Material &aMaterial) final
Loads material data into the renderer.
void BindMesh(const Mesh &aMesh)
Bind a mesh for subsequent draw calls.
void SetViewMatrix(void *aWindowId, const Matrix4x4 &aMatrix) final
Sets the view matrix for a specific window surface.
void InitializeOverlay()
Initialize overlay shader program and quad buffer.
BufferAccessor AllocateSingleFrameUniformMemory(void *aWindowId, size_t aSize) final
Allocates uniform buffer memory that is valid for a single frame.
GLuint GetOverlayQuad() const
Get the overlay screen-quad buffer.
std::unordered_map< size_t, OpenGLMaterial > mMaterialStore
Loaded material cache.
void UnloadMesh(const Mesh &aMesh) final
Unloads mesh data from GPU memory.
void SetProjectionMatrix(void *aWindowId, const Matrix4x4 &aMatrix) final
Sets the projection matrix for a specific window surface.
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.
std::unordered_map< void *, OpenGLWindow > mWindowStore
Attached window map.
void SetMatrices(const OpenGLBuffer &aMatricesBuffer) const
Bind the matrices uniform buffer for the current draw.
const Frustum & GetFrustum(void *aWindowId) const final
Returns the view frustum for the given window surface.
void SetSkeleton(const BufferAccessor &aSkeletonBuffer) const
Upload skeleton joint matrices for skinned rendering.
void LoadMesh(const Mesh &aMesh) final
Loads mesh data into GPU memory.
std::unordered_map< size_t, OpenGLPipeline > mPipelineStore
Loaded pipeline cache.
OpenGLRenderer(void *aWindow)
Construct from a native window handle.
GLuint mVertexArrayObject
General VAO.
std::unordered_map< size_t, OpenGLTexture > mTextureStore
Loaded texture cache.
void BindPipeline(const Pipeline &aPipeline)
Bind a pipeline (shader program) for rendering.
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.
void UnloadPipeline(const Pipeline &aPipeline) final
Unloads a rendering pipeline from the renderer.
OpenGLPipeline * mCurrentPipeline
Currently bound pipeline.
void SetMaterial(const Material &aMaterial)
Set the active material for rendering.
void LoadTexture(const Texture &aTexture) final
Loads a texture into GPU memory.
void UnloadMaterial(const Material &aMaterial) final
Unloads material data from the renderer.
std::unordered_map< size_t, OpenGLMesh > mMeshStore
Loaded mesh cache.
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 AttachWindow(void *aWindowId) final
Attach a Window as a rendering surface.
void DetachWindow(void *aWindowId) final
Detach a Window as a rendering surface.
GLuint GetOverlayProgram() const
Get the overlay shader program identifier.
GLuint GetVertexArrayObject() const
Get the shared vertex array object.
GLuint GetTextureId(const Texture &aTexture)
Get the OpenGL texture identifier for a loaded texture.
void * GetContext() const
Get the platform-specific OpenGL rendering context.
Rendering pipeline resource.
Abstract base class for rendering backends.
Represents a 2D texture image resource.
OpenGLBuffer mOverlayQuad
Overlay quadrilateral.
GLuint mOverlayProgram
Raw overlay shader program.
<- This is here just for the literals
Topology
Primitive topology types for rendering.
@ TRIANGLE_LIST
Independent triangles.