Renderer

group renderer

Renderer components of the CoffeeEngine.

Enums

enum class ShaderDataType

Enum class representing different shader data types.

Values:

enumerator None
enumerator Bool
enumerator Int
enumerator Float
enumerator Vec2
enumerator Vec3
enumerator Vec4
enumerator Mat2
enumerator Mat3
enumerator Mat4

Functions

static uint32_t ShaderDataTypeSize(ShaderDataType type)

Returns the size of the specified ShaderDataType.

Parameters:

type – The ShaderDataType.

Returns:

The size of the ShaderDataType in bytes.

struct BufferAttribute
#include <Buffer.h>

Structure representing a buffer attribute.

Public Functions

BufferAttribute() = default

Default constructor for BufferAttribute.

inline BufferAttribute(ShaderDataType type, const std::string &name, bool normalized = false)

Constructs a BufferAttribute with the specified parameters.

Parameters:
  • type – The type of the attribute.

  • name – The name of the attribute.

  • normalized – Whether the attribute is normalized.

inline uint32_t GetComponentCount() const

Returns the number of components in the attribute.

Returns:

The number of components.

Public Members

std::string Name

The name of the attribute.

ShaderDataType Type

The type of the attribute.

uint32_t Size

The size of the attribute.

size_t Offset

The offset of the attribute.

bool Normalized

Whether the attribute is normalized.

class BufferLayout
#include <Buffer.h>

Class representing a buffer layout.

Public Functions

inline BufferLayout()

Default constructor for BufferLayout.

inline BufferLayout(std::initializer_list<BufferAttribute> elements)

Constructs a BufferLayout with the specified attributes.

Parameters:

elements – The list of buffer attributes.

inline uint32_t GetStride() const

Returns the stride of the buffer layout.

Returns:

The stride in bytes.

inline const std::vector<BufferAttribute> &GetElements() const

Returns the list of buffer attributes.

Returns:

The list of buffer attributes.

inline std::vector<BufferAttribute>::iterator begin()

Returns an iterator to the beginning of the buffer attributes.

Returns:

An iterator to the beginning.

inline std::vector<BufferAttribute>::iterator end()

Returns an iterator to the end of the buffer attributes.

Returns:

An iterator to the end.

inline std::vector<BufferAttribute>::const_iterator begin() const

Returns a constant iterator to the beginning of the buffer attributes.

Returns:

A constant iterator to the beginning.

inline std::vector<BufferAttribute>::const_iterator end() const

Returns a constant iterator to the end of the buffer attributes.

Returns:

A constant iterator to the end.

class VertexBuffer
#include <Buffer.h>

Class representing a vertex buffer.

Public Functions

VertexBuffer(uint32_t size)

Constructs a VertexBuffer with the specified size.

Parameters:

size – The size of the buffer.

VertexBuffer(float *vertices, uint32_t size)

Constructs a VertexBuffer with the specified vertices and size.

Parameters:
  • vertices – The vertex data.

  • size – The size of the buffer.

virtual ~VertexBuffer()

Destroys the VertexBuffer.

void Bind()

Binds the vertex buffer.

void Unbind()

Unbinds the vertex buffer.

void SetData(void *data, uint32_t size)

Sets the data of the vertex buffer.

Parameters:
  • data – The data to set.

  • size – The size of the data.

inline const BufferLayout &GetLayout() const

Returns the layout of the vertex buffer.

Returns:

The buffer layout.

inline void SetLayout(const BufferLayout &layout)

Sets the layout of the vertex buffer.

Parameters:

layout – The buffer layout.

Public Static Functions

static Ref<VertexBuffer> Create(uint32_t size)

Creates a vertex buffer with the specified size.

Parameters:

size – The size of the buffer.

Returns:

A reference to the created vertex buffer.

static Ref<VertexBuffer> Create(float *vertices, uint32_t size)

Creates a vertex buffer with the specified vertices and size.

Parameters:
  • vertices – The vertex data.

  • size – The size of the buffer.

Returns:

A reference to the created vertex buffer.

class IndexBuffer
#include <Buffer.h>

Class representing an index buffer.

Public Functions

IndexBuffer(uint32_t *indices, uint32_t count)

Constructs an IndexBuffer with the specified indices and count.

Parameters:
  • indices – The index data.

  • count – The number of indices.

virtual ~IndexBuffer()

Destroys the IndexBuffer.

void Bind()

Binds the index buffer.

void Unbind()

Unbinds the index buffer.

inline uint32_t GetCount() const

Returns the number of indices in the buffer.

Returns:

The number of indices.

Public Static Functions

static Ref<IndexBuffer> Create(uint32_t *indices, uint32_t count)

Creates an index buffer with the specified indices and count.

Parameters:
  • indices – The index data.

  • count – The number of indices.

Returns:

A reference to the created index buffer.

class Camera
#include <Camera.h>

The Camera class is responsible for managing the camera’s projection matrix.

Subclassed by Coffee::EditorCamera, Coffee::SceneCamera

Public Types

enum class ProjectionType

Enum class representing the type of projection.

Values:

enumerator PERSPECTIVE

Perspective projection.

enumerator ORTHOGRAPHIC

Orthographic projection.

Public Functions

Camera() = default

Default constructor for the Camera class.

inline Camera(const glm::mat4 &projection)

Constructs a Camera object with the specified projection matrix.

Parameters:

projection – The projection matrix.

virtual ~Camera() = default

Virtual destructor for the Camera class.

inline float GetFOV() const

Gets the field of view of the camera.

Returns:

The field of view.

inline void SetFOV(float fov)

Sets the field of view of the camera.

Parameters:

fov – The field of view.

inline float GetAspectRatio() const

Gets the aspect ratio of the camera.

Returns:

The aspect ratio.

inline void SetAspectRatio(float aspectRatio)

Sets the aspect ratio of the camera.

Parameters:

aspectRatio – The aspect ratio.

inline float GetNearClip() const

Gets the near clipping plane distance of the camera.

Returns:

The near clipping plane distance.

inline void SetNearClip(float nearClip)

Sets the near clipping plane distance of the camera.

Parameters:

nearClip – The near clipping plane distance.

inline float GetFarClip() const

Gets the far clipping plane distance of the camera.

Returns:

The far clipping plane distance.

inline void SetFarClip(float farClip)

Sets the far clipping plane distance of the camera.

Parameters:

farClip – The far clipping plane distance.

inline const glm::mat4 &GetProjection() const

Gets the projection matrix of the camera.

Returns:

The projection matrix.

inline ProjectionType GetProjectionType() const

Gets the projection type of the camera.

Returns:

The projection type.

inline void SetProjectionType(ProjectionType projectionType)

Sets the projection type of the camera.

Parameters:

projectionType – The projection type.

inline void SetViewportSize(float width, float height)

Sets the size of the viewport and updates the projection matrix.

Parameters:
  • width – The width of the viewport.

  • height – The height of the viewport.

inline glm::mat4 ProjectionTypeToMat4(ProjectionType projection)

Converts the projection type to a projection matrix.

Parameters:

projection – The type of projection.

Returns:

The projection matrix.

inline void UpdateProjection()

Updates the projection matrix based on the current viewport dimensions and projection type.

struct DebugVertex
#include <DebugRenderer.h>

Structure representing a vertex in a line.

Public Members

glm::vec3 Position

The position of the vertex.

glm::vec4 Color

The color of the vertex.

class DebugRenderer
#include <DebugRenderer.h>

Class responsible for rendering debug lines.

Public Static Functions

static void Init()

Initializes the DebugRenderer.

static void Shutdown()

Shuts down the DebugRenderer.

static void Flush()

Flushes the batched vertices to the GPU and renders them.

static void DrawLine(const glm::vec3 &start, const glm::vec3 &end, glm::vec4 color = glm::vec4(1.0f), float lineWidth = 1.0f)

Draws a line between two points.

Parameters:
  • start – The starting point of the line.

  • end – The ending point of the line.

  • color – The color of the line. Default is white.

  • lineWidth – The width of the line. Default is 1.0f.

static void DrawCircle(const glm::vec3 &position, float radius, const glm::quat &rotation, glm::vec4 color = glm::vec4(1.0f), float lineWidth = 1.0f)

Draws a circle.

Parameters:
  • position – The center position of the circle.

  • radius – The radius of the circle.

  • rotation – The rotation of the circle.

  • color – The color of the circle. Default is white.

  • lineWidth – The width of the circle line. Default is 1.0f.

static void DrawSphere(const glm::vec3 &position, float radius, const glm::vec4 &color = glm::vec4(1.0f), float lineWidth = 1.0f)

Draws a sphere.

Parameters:
  • position – The center position of the sphere.

  • radius – The radius of the sphere.

  • color – The color of the sphere. Default is white.

  • lineWidth – The width of the sphere line. Default is 1.0f.

static void DrawBox(const glm::vec3 &position, const glm::quat &rotation, const glm::vec3 &size, const glm::vec4 &color = glm::vec4(1.0f), const bool &isCentered = true, float lineWidth = 1.0f)

Draws a box.

Parameters:
  • position – The center position of the box.

  • rotation – The rotation of the box.

  • size – The size of the box.

  • color – The color of the box. Default is white.

  • isCentered – Whether the box is centered at the position.

  • lineWidth – The width of the box line. Default is 1.0f.

static void DrawBox(const glm::vec3 &min, const glm::vec3 &max, const glm::vec4 &color = glm::vec4(1.0f), float lineWidth = 1.0f)

Draws a box.

Parameters:
  • min – The minimum corner of the box.

  • max – The maximum corner of the box.

  • color – The color of the box. Default is white.

  • lineWidth – The width of the box line. Default is 1.0f.

static void DrawBox(const AABB &aabb, const glm::vec4 &color = glm::vec4(1.0f), float lineWidth = 1.0f)

Draws a box.

Parameters:
  • aabb – The axis-aligned bounding box.

  • color – The color of the box. Default is white.

  • lineWidth – The width of the box line. Default is 1.0f.

static void DrawBox(const OBB &obb, const glm::vec4 &color = glm::vec4(1.0f), float lineWidth = 1.0f)

Draws a box.

Parameters:
  • obb – The oriented bounding box.

  • color – The color of the box. Default is white.

  • lineWidth – The width of the box line. Default is 1.0f.

static void DrawArrow(const glm::vec3 &start, const glm::vec3 &end, bool fixedLength, glm::vec4 color = glm::vec4(1.0f), float lineWidth = 1.0f)

Draws an arrow.

Parameters:
  • start – The starting point of the arrow.

  • end – The ending point of the arrow.

  • fixedLength – Whether the arrow has a fixed length.

  • color – The color of the arrow. Default is white.

  • lineWidth – The width of the arrow line. Default is 1.0f.

static void DrawArrow(const glm::vec3 &origin, const glm::vec3 &direction, float length, glm::vec4 color = glm::vec4(1.0f), float lineWidth = 1.0f)

Draws an arrow.

Parameters:
  • origin – The origin point of the arrow.

  • direction – The direction of the arrow.

  • length – The length of the arrow.

  • color – The color of the arrow. Default is white.

  • lineWidth – The width of the arrow line. Default is 1.0f.

class EditorCamera : public Coffee::Camera
#include <EditorCamera.h>

The EditorCamera class is responsible for managing the editor camera’s view and projection matrices.

Public Types

enum class CameraState

Enum class representing the state of the camera.

Values:

enumerator NONE

No camera state.

enumerator ORBIT

Camera is in orbit mode.

enumerator FLY

Camera is in fly mode.

Public Functions

EditorCamera() = default

Default constructor for the EditorCamera class.

EditorCamera(float fov, ProjectionType projection = ProjectionType::PERSPECTIVE, float aspectRatio = 1.778, float nearClip = 0.1f, float farClip = 1000.0f)

Constructs an EditorCamera object with the specified parameters.

Parameters:
  • fov – The field of view for the perspective projection.

  • projection – The type of projection (perspective or orthographic).

  • aspectRatio – The aspect ratio of the viewport.

  • nearClip – The near clipping plane distance.

  • farClip – The far clipping plane distance.

void OnUpdate(float dt)

Updates the camera’s view matrix.

void OnEvent(Event &event)

Handles events for the camera.

Parameters:

event – The event to handle.

inline void SetFocusPoint(glm::vec3 focusPoint)

Sets the focal point of the camera.

Parameters:

focusPoint – The focal point.

inline const glm::mat4 GetViewMatrix() const

Gets the view matrix of the camera.

Returns:

The view matrix.

glm::vec3 GetUpDirection() const

Gets the up direction of the camera.

Returns:

The up direction.

glm::vec3 GetRightDirection() const

Gets the right direction of the camera.

Returns:

The right direction.

glm::vec3 GetForwardDirection() const

Gets the forward direction of the camera.

Returns:

The forward direction.

inline const glm::vec3 &GetPosition() const

Gets the position of the camera.

Returns:

The position.

glm::quat GetOrientation() const

Gets the orientation of the camera.

Returns:

The orientation.

inline const CameraState &GetState() const

Gets the current state of the camera.

Returns:

The current state of the camera.

class Framebuffer
#include <Framebuffer.h>

Class representing a framebuffer.

Public Functions

Framebuffer(uint32_t width, uint32_t height, std::initializer_list<ImageFormat> attachments)

Constructs a Framebuffer with the specified width, height, and attachments.

Parameters:
  • width – The width of the framebuffer.

  • height – The height of the framebuffer.

  • attachments – The list of image formats for the attachments.

~Framebuffer()

Destroys the Framebuffer.

void Invalidate()

Invalidates the framebuffer, forcing it to be recreated.

void Bind()

Binds the framebuffer.

void UnBind()

Unbinds the framebuffer.

void SetDrawBuffers(std::initializer_list<Ref<Texture2D>> colorAttachments)

Sets the draw buffers for the framebuffer.

Warning

This function is not finished, does not work, and is slow. Do not use it 🫡.

Parameters:

colorAttachments – The list of color attachments.

void SetDrawBuffers(std::initializer_list<uint32_t> colorAttachments)

Sets the draw buffers for the framebuffer.

Parameters:

colorAttachments – The list of color attachment indices.

void Resize(uint32_t width, uint32_t height)

Resizes the framebuffer.

Parameters:
  • width – The new width of the framebuffer.

  • height – The new height of the framebuffer.

inline const uint32_t GetWidth() const

Gets the width of the framebuffer.

Returns:

The width of the framebuffer.

inline const uint32_t GetHeight() const

Gets the height of the framebuffer.

Returns:

The height of the framebuffer.

void AttachColorTexture(Ref<Texture2D> &texture)

Attaches a color texture to the framebuffer.

Parameters:

texture – The color texture to attach.

void AttachDepthTexture(Ref<Texture2D> &texture)

Attaches a depth texture to the framebuffer.

Parameters:

texture – The depth texture to attach.

inline const Ref<Texture2D> &GetColorTexture(uint32_t index = 0) const

Gets the color texture at the specified index.

Parameters:

index – The index of the color texture.

Returns:

A reference to the color texture.

inline const Ref<Texture2D> &GetDepthTexture() const

Gets the depth texture.

Returns:

A reference to the depth texture.

Public Static Functions

static Ref<Framebuffer> Create(uint32_t width, uint32_t height, std::initializer_list<ImageFormat> attachments)

Creates a framebuffer with the specified width, height, and attachments.

Parameters:
  • width – The width of the framebuffer.

  • height – The height of the framebuffer.

  • attachments – The list of image formats for the attachments.

Returns:

A reference to the created framebuffer.

class GraphicsContext
#include <GraphicsContext.h>

Class representing the graphics context.

Public Functions

GraphicsContext(SDL_Window *windowHandle)

Constructs a GraphicsContext with the specified window handle.

Parameters:

windowHandle – The handle to the SDL window.

virtual ~GraphicsContext()

Virtual destructor for the GraphicsContext class.

void Init()

Initializes the graphics context.

void SwapBuffers()

Swaps the front and back buffers.

Public Static Functions

static Scope<GraphicsContext> Create(SDL_Window *window)

Creates a graphics context for the specified window.

Parameters:

window – The handle to the SDL window.

Returns:

A scope pointer to the created graphics context.

struct MaterialRenderSettings
struct MaterialProperties
#include <Material.h>

Structure representing the properties of a material.

Public Members

glm::vec4 color = glm::vec4(1.0f)

The color of the material.

float metallic = 0.0f

The metallic value of the material.

float roughness = 1.0f

The roughness value of the material.

float ao = 1.0f

The ambient occlusion value of the material.

glm::vec3 emissive = glm::vec3(0.0f)

The emissive value of the material.

struct MaterialTextures
#include <Material.h>

Structure representing the textures used in a material.

Public Members

Ref<Texture2D> albedo

The albedo texture.

Ref<Texture2D> normal

The normal map texture.

Ref<Texture2D> metallic

The metallic texture.

Ref<Texture2D> roughness

The roughness texture.

Ref<Texture2D> ao

The ambient occlusion texture.

Ref<Texture2D> emissive

The emissive texture.

struct MaterialTextureFlags

Public Members

bool hasAlbedo = false

Whether the material has an albedo texture.

bool hasNormal = false

Whether the material has a normal map texture.

bool hasMetallic = false

Whether the material has a metallic texture.

bool hasRoughness = false

Whether the material has a roughness texture.

bool hasAO = false

Whether the material has an ambient occlusion texture.

bool hasEmissive = false

Whether the material has an emissive texture.

class Material : public Coffee::Resource
#include <Material.h>

Class representing a material.

Public Functions

Material(const std::string &name)

Default constructor for the Material class.

Material(const std::string &name, Ref<Shader> shader)

Constructs a Material with the specified shader.

Parameters:

shader – The shader to be used with the material.

Material(std::filesystem::path &path)

Constructs a Material from a file path.

Note

This constructor is for future use when the material YAML exists.

Parameters:

path – The file path to the material definition.

Material(const std::string &name, MaterialTextures &materialTextures)

Constructs a Material with the specified textures.

Parameters:

materialTextures – The textures to be used with the material.

~Material() = default

Default destructor for the Material class.

void Use()

Uses the material by binding its shader and textures.

inline Ref<Shader> GetShader()

Gets the shader associated with the material.

Returns:

A reference to the shader.

struct Vertex
#include <Mesh.h>

Structure representing a vertex in a mesh.

Public Members

glm::vec3 Position = glm::vec3(0.0f)

The position of the vertex.

glm::vec2 TexCoords = glm::vec2(0.0f)

The texture coordinates of the vertex.

glm::vec3 Normals = glm::vec3(0.0f)

The normal vector of the vertex.

glm::vec3 Tangent = glm::vec3(0.0f)

The tangent vector of the vertex.

glm::vec3 Bitangent = glm::vec3(0.0f)

The bitangent vector of the vertex.

class Mesh : public Coffee::Resource
#include <Mesh.h>

Class representing a mesh.

Public Functions

Mesh(const std::vector<Vertex> &vertices, const std::vector<uint32_t> &indices)

Constructs a Mesh with the specified indices and vertices.

Parameters:
  • indices – The indices of the mesh.

  • vertices – The vertices of the mesh.

inline const Ref<VertexArray> &GetVertexArray() const

Gets the vertex array of the mesh.

Returns:

A reference to the vertex array.

inline const Ref<VertexBuffer> &GetVertexBuffer() const

Gets the vertex buffer of the mesh.

Returns:

A reference to the vertex buffer.

inline const Ref<IndexBuffer> &GetIndexBuffer() const

Gets the index buffer of the mesh.

Returns:

A reference to the index buffer.

inline void SetMaterial(Ref<Material> &material)

Sets the material of the mesh.

Parameters:

material – A reference to the material.

inline void SetAABB(const AABB aabb)

Sets the axis-aligned bounding box (AABB) of the mesh.

Parameters:

aabb – The axis-aligned bounding box to set.

inline const AABB &GetAABB()

Gets the axis-aligned bounding box (AABB) of the mesh.

Returns:

A reference to the AABB.

inline OBB GetOBB(const glm::mat4 &transform)

Gets the oriented bounding box (OBB) of the mesh.

Parameters:

transform – The transformation matrix.

Returns:

The OBB.

inline const Ref<Material> &GetMaterial() const

Gets the material of the mesh.

Returns:

A reference to the material.

inline const std::vector<Vertex> &GetVertices() const

Gets the vertices of the mesh.

Returns:

A reference to the vector of vertices.

inline const std::vector<uint32_t> &GetIndices() const

Gets the indices of the mesh.

Returns:

A reference to the vector of indices.

class Model : public Coffee::Resource, public std::enable_shared_from_this<Model>
#include <Model.h>

Class representing a 3D model.

Public Functions

inline Model()

Default constructor for the Model class.

Model(const std::filesystem::path &path)

Constructs a Model from a file path.

Parameters:

filePath – The file path to the model.

inline const std::vector<Ref<Mesh>> &GetMeshes() const

Gets the meshes of the model.

Returns:

A reference to the vector of meshes.

inline void AddMesh(const Ref<Mesh> mesh)

Adds a mesh to the model.

Parameters:

mesh – A reference to the mesh to add.

inline const std::weak_ptr<Model> GetParent() const

Gets the parent model.

Returns:

A pointer to the parent model.

inline const std::vector<Ref<Model>> GetChildren() const

Gets the children models.

Returns:

A reference to the vector of children models.

inline const glm::mat4 GetTransform() const

Gets the transformation matrix of the model.

Returns:

The transformation matrix.

Public Static Functions

static Ref<Model> Load(const std::filesystem::path &path)

Loads a model from the specified file path.

Parameters:

path – The path to the model file.

struct RenderCommand
struct RendererData
#include <Renderer.h>

Structure containing renderer data.

Public Members

CameraData cameraData

Camera data.

RenderData renderData

Render data.

Ref<UniformBuffer> CameraUniformBuffer

Uniform buffer for camera data.

Ref<UniformBuffer> RenderDataUniformBuffer

Uniform buffer for render data.

Ref<Material> DefaultMaterial

Default material.

Ref<Texture2D> RenderTexture

Render texture.

std::vector<RenderCommand> renderQueue

Render queue.

struct CameraData
#include <Renderer.h>

Structure containing camera data.

Public Members

glm::mat4 projection

The projection matrix.

glm::mat4 view

The view matrix.

glm::vec3 position

The position of the camera.

struct RenderData
#include <Renderer.h>

Structure containing render data.

Public Members

LightComponent lights[32]

Array of light components.

int lightCount = 0

Number of lights.

struct RendererStats
#include <Renderer.h>

Structure containing renderer statistics.

Public Members

uint32_t DrawCalls = 0

Number of draw calls.

uint32_t VertexCount = 0

Number of vertices.

uint32_t IndexCount = 0

Number of indices.

struct RenderSettings
#include <Renderer.h>

Structure containing render settings.

Public Members

bool PostProcessing = true

Enable or disable post-processing.

bool SSAO = false

Enable or disable SSAO.

bool Bloom = false

Enable or disable bloom.

bool FXAA = false

Enable or disable FXAA.

float Exposure = 1.0f

Exposure value.

class Renderer
#include <Renderer.h>

Class representing the 3D renderer.

Public Static Functions

static void Init()

Initializes the renderer.

static void Shutdown()

Shuts down the renderer.

static void BeginScene(EditorCamera &camera)

Begins a new scene with the specified editor camera.

Parameters:

camera – The editor camera.

static void BeginScene(Camera &camera, const glm::mat4 &transform)

Begins a new scene with the specified camera and transform.

Parameters:
  • camera – The camera.

  • transform – The transform matrix.

static void EndScene()

Ends the current scene.

static void BeginOverlay(EditorCamera &camera)

Begins an overlay with the specified editor camera.

Parameters:

camera – The editor camera.

static void EndOverlay()

Ends the current overlay.

static void Submit(const LightComponent &light)

Submits a light component.

Parameters:

light – The light component.

static void OnResize(uint32_t width, uint32_t height)

Resizes the renderer to the specified width and height.

Parameters:
  • width – The new width.

  • height – The new height.

static inline const Ref<Texture2D> &GetRenderTexture()

Gets the render texture.

Returns:

A reference to the render texture.

static inline const Ref<Texture2D> &GetEntityIDTexture()

Retrieves the texture associated with the entity ID.

This static method returns a reference to the texture that is used to identify entities within the renderer. The texture is stored as a static member of the class.

Returns:

A constant reference to the entity ID texture.

static inline const RendererData &GetData()

Gets the renderer data.

Returns:

A reference to the renderer data.

static inline const RendererStats &GetStats()

Gets the renderer statistics.

Returns:

A reference to the renderer statistics.

static inline RenderSettings &GetRenderSettings()

Gets the render settings.

Returns:

A reference to the render settings.

class RendererAPI
#include <RendererAPI.h>

Class representing the Renderer API.

Public Static Functions

static void Init()

Initializes the Renderer API.

static void SetClearColor(const glm::vec4 &color)

Sets the clear color for the renderer.

Parameters:

color – The clear color as a glm::vec4.

static void Clear()

Clears the current buffer.

static void SetDepthMask(bool enabled)

Enables or disables the depth mask.

Parameters:

enabled – True to enable the depth mask, false to disable it.

static void DrawIndexed(const Ref<VertexArray> &vertexArray)

Draws the indexed vertices from the specified vertex array.

Parameters:

vertexArray – The vertex array containing the vertices to draw.

static void DrawLines(const Ref<VertexArray> &vertexArray, uint32_t vertexCount, float lineWidth = 1.0f)

Draws lines from the specified vertex array.

Parameters:
  • vertexArray – The vertex array containing the vertices to draw.

  • vertexCount – The number of vertices to draw.

  • lineWidth – The width of the lines.

static Scope<RendererAPI> Create()

Creates a new Renderer API instance.

Returns:

A scope pointer to the created Renderer API instance.

class Shader : public Coffee::Resource
#include <Shader.h>

Class representing a shader program.

Public Functions

Shader(const std::filesystem::path &shaderPath)

Constructs a Shader with the specified vertex and fragment shader paths.

Parameters:
  • vertexPath – The file path to the vertex shader.

  • fragmentPath – The file path to the fragment shader.

virtual ~Shader()

Destructor for the Shader class.

void Bind()

Binds the shader program for use.

void Unbind()

Unbinds the shader program.

void setBool(const std::string &name, bool value) const

Sets a boolean uniform in the shader.

Parameters:
  • name – The name of the uniform.

  • value – The boolean value to set.

void setInt(const std::string &name, int value) const

Sets an integer uniform in the shader.

Parameters:
  • name – The name of the uniform.

  • value – The integer value to set.

void setFloat(const std::string &name, float value) const

Sets a float uniform in the shader.

Parameters:
  • name – The name of the uniform.

  • value – The float value to set.

void setVec2(const std::string &name, const glm::vec2 &value) const

Sets a vec2 uniform in the shader.

Parameters:
  • name – The name of the uniform.

  • value – The vec2 value to set.

void setVec3(const std::string &name, const glm::vec3 &value) const

Sets a vec3 uniform in the shader.

Parameters:
  • name – The name of the uniform.

  • value – The vec3 value to set.

void setVec4(const std::string &name, const glm::vec4 &value) const

Sets a vec4 uniform in the shader.

Parameters:
  • name – The name of the uniform.

  • value – The vec4 value to set.

void setMat2(const std::string &name, const glm::mat2 &mat) const

Sets a mat2 uniform in the shader.

Parameters:
  • name – The name of the uniform.

  • mat – The mat2 value to set.

void setMat3(const std::string &name, const glm::mat3 &mat) const

Sets a mat3 uniform in the shader.

Parameters:
  • name – The name of the uniform.

  • mat – The mat3 value to set.

void setMat4(const std::string &name, const glm::mat4 &mat) const

Sets a mat4 uniform in the shader.

Parameters:
  • name – The name of the uniform.

  • mat – The mat4 value to set.

void checkCompileErrors(GLuint shader, std::string type)

Checks for compile errors in the shader.

Parameters:
  • shader – The shader ID.

  • type – The type of the shader.

Public Static Functions

static Ref<Shader> Create(const std::filesystem::path &shaderPath)

Creates a shader from the specified vertex and fragment shader paths.

Parameters:
  • vertexPath – The file path to the vertex shader.

  • fragmentPath – The file path to the fragment shader.

Returns:

A reference to the created shader.

class UniformBuffer
#include <UniformBuffer.h>

Class representing a uniform buffer.

Public Functions

UniformBuffer(uint32_t size, uint32_t binding)

Constructs a UniformBuffer with the specified size and binding.

Parameters:
  • size – The size of the buffer.

  • binding – The binding point of the buffer.

virtual ~UniformBuffer()

Destructor for the UniformBuffer class.

void SetData(const void *data, uint32_t size, uint32_t offset = 0)

Sets the data of the uniform buffer.

Parameters:
  • data – A pointer to the data to set.

  • size – The size of the data.

  • offset – The offset in the buffer to set the data.

Public Static Functions

static Ref<UniformBuffer> Create(uint32_t size, uint32_t binding)

Creates a uniform buffer with the specified size and binding.

Parameters:
  • size – The size of the buffer.

  • binding – The binding point of the buffer.

Returns:

A reference to the created uniform buffer.

class VertexArray
#include <VertexArray.h>

Class representing a vertex array.

Public Functions

VertexArray()

Constructs a VertexArray.

virtual ~VertexArray()

Destructor for the VertexArray class.

void Bind()

Binds the vertex array.

void Unbind()

Unbinds the vertex array.

void AddVertexBuffer(const Ref<VertexBuffer> &vertexBuffer)

Adds a vertex buffer to the vertex array.

Parameters:

vertexBuffer – A reference to the vertex buffer to add.

void SetIndexBuffer(const Ref<IndexBuffer> &indexBuffer)

Sets the index buffer for the vertex array.

Parameters:

indexBuffer – A reference to the index buffer to set.

inline const std::vector<Ref<VertexBuffer>> &GetVertexBuffers() const

Gets the vertex buffers of the vertex array.

Returns:

A constant reference to the vector of vertex buffers.

inline const Ref<IndexBuffer> &GetIndexBuffer() const

Gets the index buffer of the vertex array.

Returns:

A constant reference to the index buffer.

Public Static Functions

static Ref<VertexArray> Create()

Creates a vertex array.

Returns:

A reference to the created vertex array.