GraphicCore

Graphic core interface.

Overview

Typical use cases:

  • Providing OpenGL-specific core graphics functionality and resource management

Header

<RaeptorCogs/GAPI/GL/Core/Internal/GraphicCore.hpp>

Metadata

Author

Estorc

Version

v1.0

Copyright

Copyright (c) 2025 Estorc MIT License.

Classes

Classes

Class

Description

RaeptorCogs::GAPI::GL::GraphicCore

No description.

class GraphicCore : public RaeptorCogs::GAPI::Common::GraphicCore

Public Functions

inline GraphicCore(Common::RendererBackend &renderer)

Constructor for GraphicCore.

Initializes the GraphicCore with a reference to the renderer backend.

Parameters:

renderer – Reference to the renderer backend.

void initGraphics()

Initialize graphics resources.

Sets up graphics resources such as shaders, buffers, and framebuffers.

Note

Called during renderer backend initialization.

void buildBuffers()

Build necessary buffers.

Sets up vertex buffers and attribute pointers.

Note

Called during renderer backend initialization.

GLuint getMaxTextureUnits() const

Get the maximum number of texture units supported by the GPU.

Note

Useful for managing texture bindings.

Returns:

Maximum number of texture units.

inline std::pair<ObjectHandler<Common::TextureData>, ObjectHandler<Common::TextureData>> &getMaskTextures()

Get the mask textures used for ping-pong rendering.

inline ObjectHandler<Common::Shader> &getMainShader()

Get the main shader program.

inline ObjectHandler<Common::Shader> &getMaskShader()

Get the mask shader program.

inline ObjectHandler<Common::RBO> &getRenderbuffer()

Get the renderbuffer used for offscreen rendering.

inline std::pair<ObjectHandler<Common::FBO>, ObjectHandler<Common::FBO>> &getPingPongMaskFramebuffer()

Get the ping-pong framebuffers used for mask rendering.

inline ObjectHandler<Common::FBO> &getTextureFramebuffer()

Get the texture framebuffer used for rendering to textures.

virtual void setViewport(int x, int y, int width, int height) override

virtual void clearSwapchainBuffers() override

virtual void useBlend() override

virtual void bindMaskTexture() override

virtual void setTextureUniform(ObjectHandler<Common::Shader> shader) override

virtual void setMaskTextureUniform(ObjectHandler<Common::Shader> shader) override

virtual void drawElementsInstancedBaseVertexBaseInstance(size_t count, size_t instanceCount, size_t first, int baseVertex, unsigned int baseInstance) override

virtual void bindGraphicTexture(Graphic2D &graphic) override

virtual void enableStencilGuarding() override

Private Members

ObjectHandler<Common::Shader> mainShader

Main shader program.

Holds the main shader for rendering.

ObjectHandler<Common::Shader> maskShader

Mask shader program.

Holds the shader for rendering masks.

std::pair<ObjectHandler<Common::FBO>, FBO> pingPongFramebuffer

Shader Storage Buffer Object (SSBO) for static instance data.

Holds the SSBO for static instance data.

ObjectHandler<Common::FBO> textureFramebuffer

Shader Storage Buffer Object (SSBO) for dynamic instance data.

Holds the SSBO for dynamic instance data.

std::pair<ObjectHandler<Common::FBO>, ObjectHandler<Common::FBO>> pingPongMaskFramebuffer

Ping-pong framebuffers for mask rendering.

Holds the pair of framebuffers used for ping-pong rendering of masks.

std::pair<ObjectHandler<Common::TextureData>, ObjectHandler<Common::TextureData>> maskTextures

Mask textures for ping-pong rendering.

Holds the pair of textures used for ping-pong rendering of masks.

ObjectHandler<Common::RBO> renderbuffer

Renderbuffer for offscreen rendering.

Holds the renderbuffer used for offscreen rendering.

Variables

int RaeptorCogs::GAPI::GL::DEFAULT_DYNAMIC_DATA_BUFFER_SIZE = (MAX_SPRITES * INSTANCE_SIZE)

Default size of the dynamic instance data buffer.

int RaeptorCogs::GAPI::GL::INSTANCE_SIZE = 32

Width of the instance data texture.

int RaeptorCogs::GAPI::GL::MAX_SPRITES = 8000000

Maximum number of sprites supported.

int RaeptorCogs::GAPI::GL::STATIC_INSTANCE_DATA_SIZE = (MAX_SPRITES * sizeof(Common::StaticInstanceData))

Size of the static instance data buffer.