Core
- group core
Core components of the CoffeeEngine.
Functions
-
Application *CreateApplication()
Creates the application. To be defined in the client.
- Returns:
A pointer to the created application.
-
class Application
- #include <Application.h>
The Application class is responsible for managing the main application loop, handling events, and managing layers and overlays.
Public Types
Public Functions
-
Application()
Constructs the Application object.
-
virtual ~Application()
Destroys the Application object.
-
void Run()
Starts the main application loop.
-
void PushLayer(Layer *layer)
Pushes a layer onto the layer stack.
- Parameters:
layer – The layer to push.
-
void PushOverlay(Layer *layer)
Pushes an overlay onto the layer stack.
- Parameters:
layer – The overlay to push.
-
inline Window &GetWindow()
Gets the main application window.
- Returns:
A reference to the main application window.
-
inline void SetEventCallback(const EventCallbackFn &callback)
Sets the event callback function.
- Parameters:
callback – The event callback function.
-
void Close()
Closes the application.
-
inline ImGuiLayer *GetImGuiLayer()
Gets the ImGui layer.
- Returns:
A pointer to the ImGui layer.
Public Static Functions
-
static inline Application &Get()
Gets the singleton instance of the Application.
- Returns:
A reference to the singleton instance.
-
Application()
-
class Input
Public Static Functions
-
static bool IsKeyPressed(const KeyCode key)
Checks if a specific key is currently being pressed.
- Parameters:
key – The key code of the key to check.
- Returns:
True if the key is currently being pressed, false otherwise.
-
static bool IsMouseButtonPressed(const MouseCode button)
Checks if a mouse button is currently pressed.
- Parameters:
button – The mouse button to check.
- Returns:
True if the mouse button is pressed, false otherwise.
-
static glm::vec2 GetMousePosition()
Retrieves the current position of the mouse.
- Returns:
The current position of the mouse as a 2D vector.
-
static float GetMouseX()
Retrieves the current x-coordinate of the mouse cursor.
- Returns:
The x-coordinate of the mouse cursor.
-
static float GetMouseY()
Retrieves the current y-coordinate of the mouse cursor.
- Returns:
The y-coordinate of the mouse cursor.
-
static bool IsKeyPressed(const KeyCode key)
-
class Layer
Subclassed by Coffee::ImGuiLayer
Public Functions
-
inline Layer(const std::string &name = "Layer")
Constructor for the Layer class.
- Parameters:
name – The name of the layer, default is “Layer”.
-
inline virtual void OnAttach()
Called when the layer is attached.
-
inline virtual void OnDetach()
Called when the layer is detached.
-
inline virtual void OnUpdate(float dt)
Called every frame to update the layer.
- Parameters:
dt – Delta time since the last frame.
-
inline virtual void OnImGuiRender()
Called to render ImGui elements.
-
inline virtual void OnEvent(Event &event)
Called when an event occurs.
- Parameters:
event – The event that occurred.
-
inline const std::string &GetName() const
Gets the name of the layer.
- Returns:
The name of the layer.
-
inline Layer(const std::string &name = "Layer")
-
class Log
- #include <Log.h>
The Log class is responsible for initializing and providing access to the core and client loggers.
Public Static Functions
-
static void Init()
Initializes the logging system.
-
static inline std::shared_ptr<spdlog::logger> &GetCoreLogger()
Gets the core logger.
- Returns:
A shared pointer to the core logger.
-
static inline std::shared_ptr<spdlog::logger> &GetClientLogger()
Gets the client logger.
- Returns:
A shared pointer to the client logger.
-
static void Init()
-
struct WindowProps
- #include <Window.h>
Structure to hold window properties such as title, width, and height.
Public Functions
-
inline WindowProps(const std::string &title = "Coffee Engine", uint32_t width = 1600, uint32_t height = 900)
Constructs WindowProps with default or specified values.
- Parameters:
title – The title of the window.
width – The width of the window.
height – The height of the window.
-
inline WindowProps(const std::string &title = "Coffee Engine", uint32_t width = 1600, uint32_t height = 900)
-
class Window
- #include <Window.h>
The Window class is responsible for managing the window and its properties.
Public Functions
-
Window(const WindowProps &props)
Constructs a Window object with the specified properties.
- Parameters:
props – The properties of the window.
-
void OnUpdate()
Updates the window.
-
inline unsigned int GetWidth() const
Gets the width of the window.
- Returns:
The width of the window.
-
inline unsigned int GetHeight() const
Gets the height of the window.
- Returns:
The height of the window.
-
void SetVSync(bool enabled)
Enables or disables VSync.
- Parameters:
enabled – True to enable VSync, false to disable.
-
bool IsVSync() const
Checks if VSync is enabled.
- Returns:
True if VSync is enabled, false otherwise.
-
void SetTitle(const std::string &title)
Sets the title of the window.
- Parameters:
title – The new title of the window.
-
inline const std::string &GetTitle() const
Gets the title of the window.
- Returns:
The title of the window.
-
void SetIcon(const std::string &path)
Sets the icon of the window.
- Parameters:
path – The path to the icon file.
-
inline virtual void *GetNativeWindow() const
Gets the native window handle.
- Returns:
A pointer to the native window.
Public Static Functions
-
static inline Scope<Window> Create(const WindowProps &props = WindowProps())
Creates a window with the specified properties.
- Parameters:
props – The properties of the window.
- Returns:
A scoped pointer to the created window.
-
Window(const WindowProps &props)
-
Application *CreateApplication()
Events
- group events
Defines
-
EVENT_CLASS_TYPE(type)
Macro to define the type of an event.
-
EVENT_CLASS_CATEGORY(category)
Macro to define the category of an event.
Enums
-
enum class EventType
Enum representing different types of events.
Values:
-
enumerator None
-
enumerator WindowClose
-
enumerator WindowResize
-
enumerator WindowFocus
-
enumerator WindowLostFocus
-
enumerator WindowMoved
-
enumerator AppTick
-
enumerator AppUpdate
-
enumerator AppRender
-
enumerator KeyPressed
-
enumerator KeyReleased
-
enumerator KeyTyped
-
enumerator MouseButtonPressed
-
enumerator MouseButtonReleased
-
enumerator MouseMoved
-
enumerator MouseScrolled
-
enumerator None
Functions
-
class WindowResizeEvent : public Coffee::Event
- #include <ApplicationEvent.h>
Event for window resize.
Public Functions
-
inline unsigned int GetWidth() const
Get the width of the window.
- Returns:
The width of the window.
-
inline unsigned int GetHeight() const
Get the height of the window.
- Returns:
The height of the window.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline unsigned int GetWidth() const
-
class WindowCloseEvent : public Coffee::Event
- #include <ApplicationEvent.h>
Event for window close.
-
class AppTickEvent : public Coffee::Event
- #include <ApplicationEvent.h>
Event for application tick.
-
class AppUpdateEvent : public Coffee::Event
- #include <ApplicationEvent.h>
Event for application update.
-
class AppRenderEvent : public Coffee::Event
- #include <ApplicationEvent.h>
Event for application render.
-
class Event
- #include <Event.h>
Base class for all events.
Subclassed by Coffee::AppRenderEvent, Coffee::AppTickEvent, Coffee::AppUpdateEvent, Coffee::KeyEvent, Coffee::MouseButtonEvent, Coffee::MouseMovedEvent, Coffee::MouseScrolledEvent, Coffee::WindowCloseEvent, Coffee::WindowResizeEvent
Public Functions
-
virtual const char *GetName() const = 0
Get the name of the event.
- Returns:
The event name.
-
virtual int GetCategoryFlags() const = 0
Get the category flags of the event.
- Returns:
The category flags.
-
inline virtual std::string ToString() const
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline bool IsInCategory(EventCategory category)
Check if the event is in a specific category.
- Parameters:
category – The category to check.
- Returns:
True if the event is in the category, false otherwise.
-
virtual const char *GetName() const = 0
-
class EventDispatcher
- #include <Event.h>
Event dispatcher to handle events.
Public Functions
-
template<typename T, typename F>
inline bool Dispatch(const F &func) Dispatches the event if it matches the type.
- Template Parameters:
T – The event type.
F – The function type.
- Parameters:
func – The function to call if the event matches the type.
- Returns:
True if the event was dispatched, false otherwise.
-
template<typename T, typename F>
-
class KeyEvent : public Coffee::Event
- #include <KeyEvent.h>
Base class for key events.
Subclassed by Coffee::KeyPressedEvent, Coffee::KeyReleasedEvent, Coffee::KeyTypedEvent
Public Functions
-
inline KeyCode GetKeyCode() const
Get the key code associated with the event.
- Returns:
The key code.
-
inline KeyCode GetKeyCode() const
-
class KeyPressedEvent : public Coffee::KeyEvent
- #include <KeyEvent.h>
Event for key press.
Public Functions
-
inline KeyPressedEvent(const KeyCode keycode, bool isRepeat = false)
Constructor for KeyPressedEvent.
- Parameters:
keycode – The key code associated with the event.
isRepeat – Whether the key press is a repeat.
-
inline bool IsRepeat() const
Check if the key press is a repeat.
- Returns:
True if the key press is a repeat, false otherwise.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline KeyPressedEvent(const KeyCode keycode, bool isRepeat = false)
-
class KeyReleasedEvent : public Coffee::KeyEvent
- #include <KeyEvent.h>
Event for key release.
Public Functions
-
inline KeyReleasedEvent(const KeyCode keycode)
Constructor for KeyReleasedEvent.
- Parameters:
keycode – The key code associated with the event.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline KeyReleasedEvent(const KeyCode keycode)
-
class KeyTypedEvent : public Coffee::KeyEvent
- #include <KeyEvent.h>
Event for key typing.
Public Functions
-
inline KeyTypedEvent(const KeyCode keycode)
Constructor for KeyTypedEvent.
- Parameters:
keycode – The key code associated with the event.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline KeyTypedEvent(const KeyCode keycode)
-
class MouseMovedEvent : public Coffee::Event
- #include <MouseEvent.h>
Event for mouse movement.
Public Functions
-
inline MouseMovedEvent(const float x, const float y)
Constructor for MouseMovedEvent.
- Parameters:
x – The x-coordinate of the mouse.
y – The y-coordinate of the mouse.
-
inline float GetX() const
Get the x-coordinate of the mouse.
- Returns:
The x-coordinate.
-
inline float GetY() const
Get the y-coordinate of the mouse.
- Returns:
The y-coordinate.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline MouseMovedEvent(const float x, const float y)
-
class MouseScrolledEvent : public Coffee::Event
- #include <MouseEvent.h>
Event for mouse scrolling.
Public Functions
-
inline MouseScrolledEvent(const float xOffset, const float yOffset)
Constructor for MouseScrolledEvent.
- Parameters:
xOffset – The scroll offset along the x-axis.
yOffset – The scroll offset along the y-axis.
-
inline float GetXOffset() const
Get the scroll offset along the x-axis.
- Returns:
The x-axis scroll offset.
-
inline float GetYOffset() const
Get the scroll offset along the y-axis.
- Returns:
The y-axis scroll offset.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline MouseScrolledEvent(const float xOffset, const float yOffset)
-
class MouseButtonEvent : public Coffee::Event
- #include <MouseEvent.h>
Base class for mouse button events.
Subclassed by Coffee::MouseButtonPressedEvent, Coffee::MouseButtonReleasedEvent
Public Functions
-
inline MouseCode GetMouseButton() const
Get the mouse button associated with the event.
- Returns:
The mouse button.
-
inline MouseCode GetMouseButton() const
-
class MouseButtonPressedEvent : public Coffee::MouseButtonEvent
- #include <MouseEvent.h>
Event for mouse button press.
Public Functions
-
inline MouseButtonPressedEvent(const MouseCode button)
Constructor for MouseButtonPressedEvent.
- Parameters:
button – The mouse button associated with the event.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline MouseButtonPressedEvent(const MouseCode button)
-
class MouseButtonReleasedEvent : public Coffee::MouseButtonEvent
- #include <MouseEvent.h>
Event for mouse button release.
Public Functions
-
inline MouseButtonReleasedEvent(const MouseCode button)
Constructor for MouseButtonReleasedEvent.
- Parameters:
button – The mouse button associated with the event.
-
inline virtual std::string ToString() const override
Convert the event to a string representation.
- Returns:
A string representation of the event.
-
inline MouseButtonReleasedEvent(const MouseCode button)
-
EVENT_CLASS_TYPE(type)
ImGui
- group imgui
ImGui components of the CoffeeEngine.
-
class ImGuiLayer : public Coffee::Layer
- #include <ImGuiLayer.h>
The ImGuiLayer class is responsible for managing the ImGui layer in the application.
Public Functions
-
ImGuiLayer()
Constructs the ImGuiLayer object.
-
~ImGuiLayer()
Destroys the ImGuiLayer object.
-
virtual void OnAttach() override
Attaches the ImGui layer to the application.
-
virtual void OnDetach() override
Detaches the ImGui layer from the application.
-
virtual void OnEvent(Event &e) override
Handles events for the ImGui layer.
- Parameters:
e – The event to handle.
-
void Begin()
Begins a new ImGui frame.
-
void End()
Ends the current ImGui frame.
-
virtual void OnImGuiRender() override
Renders ImGui elements.
-
inline void BlockEvents(bool block)
Blocks or unblocks events from being handled by the ImGui layer.
- Parameters:
block – True to block events, false to unblock.
-
void SetTeaColorStyle()
Sets the Coffee color style for ImGui.
-
void SetGodotColorStyle()
Sets the Godot color style for ImGui.
-
void SetCoffeeColorStyle()
Sets the Coffee color style for ImGui.
-
ImGuiLayer()
-
class ImGuiLayer : public Coffee::Layer
Project
- group project
Project management components of the CoffeeEngine.
-
class Project
- #include <Project.h>
The Project class is responsible for managing project data such as name, directory, and start scene path.
Public Functions
Public Static Functions
-
static Ref<Project> New()
Creates a new project.
- Returns:
A reference to the newly created project.
-
static Ref<Project> Load(const std::filesystem::path &path)
Loads a project from the specified path.
- Parameters:
path – The path to the project file.
- Returns:
A reference to the loaded project.
-
static void SaveActive(const std::filesystem::path &path)
Saves the active project to the specified path.
- Parameters:
path – The path to save the project file.
-
static inline Ref<Project> GetActive()
Gets the active project.
- Returns:
A reference to the active project.
-
static inline const std::filesystem::path &GetProjectDirectory()
Gets the directory of the active project.
- Returns:
The path to the project directory.
-
static inline const std::string &GetProjectName()
Gets the name of the active project.
- Returns:
The name of the project.
-
static Ref<Project> New()
-
class Project
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
-
enumerator None
-
enum class ImageFormat
Enum class representing different image formats.
Values:
-
enumerator R8
8-bit Red channel.
-
enumerator RG8
8-bit Red and Green channels.
-
enumerator RGB8
8-bit Red, Green, and Blue channels.
-
enumerator SRGB8
8-bit sRGB Red, Green, and Blue channels.
-
enumerator RGBA8
8-bit Red, Green, Blue, and Alpha channels.
-
enumerator SRGBA8
8-bit sRGB Red, Green, Blue, and Alpha channels.
-
enumerator RGBA32F
32-bit floating point Red, Green, Blue, and Alpha channels.
-
enumerator DEPTH24STENCIL8
24-bit Depth and 8-bit Stencil channels.
-
enumerator R8
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.
-
Texture(const TextureProperties &properties)
Constructs a Texture with the specified properties.
- Parameters:
properties – The properties of the texture.
-
Texture(uint32_t width, uint32_t height, ImageFormat imageFormat)
Constructs a Texture with the specified width, height, and image format.
- Parameters:
width – The width of the texture.
height – The height of the texture.
imageFormat – The format of the image.
-
Texture(const std::filesystem::path &path, bool srgb = true)
Constructs a Texture from a file path.
- Parameters:
path – The file path to the texture.
srgb – Whether the texture is in sRGB format.
-
void Bind(uint32_t slot)
Binds the texture to the specified slot.
- Parameters:
slot – The slot to bind the texture to.
-
void Resize(uint32_t width, uint32_t height)
Resizes the texture to the specified width and height.
- Parameters:
width – The new width of the texture.
height – The new height of the texture.
-
inline std::pair<uint32_t, uint32_t> GetSize()
Gets the size of the texture.
- Returns:
A pair containing the width and height of the texture.
-
inline uint32_t GetWidth()
Gets the width of the texture.
- Returns:
The width of the texture.
-
inline uint32_t GetHeight()
Gets the height of the texture.
- Returns:
The height of the texture.
-
inline uint32_t GetID()
Gets the ID of the texture.
- Returns:
The ID of the texture.
-
void Clear(glm::vec4 color)
-
void SetData(void *data, uint32_t size)
-
inline ImageFormat GetImageFormat()
Gets the image format of the texture.
- Returns:
The image format of the texture.
-
static Ref<Texture> Load(const std::filesystem::path &path, bool srgb = true)
Loads a texture from a file path.
- Parameters:
path – The file path to the texture.
srgb – Whether the texture is in sRGB format.
- Returns:
A reference to the loaded texture.
-
static Ref<Texture> Create(uint32_t width, uint32_t height, ImageFormat format)
Creates a texture with the specified width, height, and format.
- Parameters:
width – The width of the texture.
height – The height of the texture.
format – The format of the texture.
- Returns:
A reference to the created texture.
Variables
-
ImageFormat Format
The format of the image.
-
uint32_t Width
-
uint32_t Height
The width and height of the texture.
-
bool GenerateMipmaps = true
Whether to generate mipmaps.
-
bool srgb = true
Whether the texture is in sRGB format.
-
TextureProperties m_Properties
The properties of the texture.
-
uint32_t m_textureID
-
int m_Width
-
int m_Height
-
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.
-
BufferAttribute() = default
-
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.
-
inline BufferLayout()
-
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.
-
VertexBuffer(uint32_t size)
-
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.
-
IndexBuffer(uint32_t *indices, uint32_t count)
-
class Camera
- #include <Camera.h>
The Camera class is responsible for managing the camera’s projection matrix.
Subclassed by Coffee::EditorCamera, Coffee::SceneCamera
-
struct DebugVertex
- #include <DebugRenderer.h>
Structure representing a vertex in a line.
-
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 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 Init()
-
class EditorCamera : public Coffee::Camera
- #include <EditorCamera.h>
The EditorCamera class is responsible for managing the editor camera’s view and projection matrices.
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()
Updates the camera’s view matrix.
-
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 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.
-
EditorCamera() = default
-
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<Texture>> 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<Texture> &texture)
Attaches a color texture to the framebuffer.
- Parameters:
texture – The color texture to attach.
-
void AttachDepthTexture(Ref<Texture> &texture)
Attaches a depth texture to the framebuffer.
- Parameters:
texture – The depth texture to attach.
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.
-
Framebuffer(uint32_t width, uint32_t height, std::initializer_list<ImageFormat> attachments)
-
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.
-
GraphicsContext(SDL_Window *windowHandle)
-
struct MaterialProperties
- #include <Material.h>
Structure representing the properties of a material.
-
struct MaterialTextures
- #include <Material.h>
Structure representing the textures used in a material.
-
class Material
- #include <Material.h>
Class representing a material.
Public Functions
-
Material(Ref<Shader> shader)
Constructs a Material with the specified shader.
- Parameters:
shader – The shader to be used with the material.
-
Material(std::string &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(MaterialTextures &materialTextures)
Constructs a Material with the specified textures.
- Parameters:
materialTextures – The textures to be used with the material.
-
void Use()
Uses the material by binding its shader and textures.
-
Material(Ref<Shader> 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.
-
glm::vec3 Position = glm::vec3(0.0f)
-
class Mesh
- #include <Mesh.h>
Class representing a mesh.
Public Functions
-
Mesh(const std::vector<uint32_t> &indices, const std::vector<Vertex> &vertices)
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 SetName(const std::string &name)
Sets the name of the mesh.
- Parameters:
name – The name of the mesh.
-
inline const std::string &GetName() const
Gets the name of the mesh.
- Returns:
The name of the mesh.
-
inline void SetMaterial(Ref<Material> &material)
Sets the material of the mesh.
- Parameters:
material – A reference to the material.
-
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.
-
Mesh(const std::vector<uint32_t> &indices, const std::vector<Vertex> &vertices)
-
class Model : public Coffee::Resource
- #include <Model.h>
Class representing a 3D model.
Public Functions
-
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 std::string &GetName()
Gets the name of the model.
- Returns:
A reference to the name of the model.
-
inline const 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.
-
Model(const std::filesystem::path &path)
-
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.
-
struct CameraData
- #include <Renderer.h>
Structure containing camera data.
-
struct RenderData
- #include <Renderer.h>
Structure containing render data.
-
CameraData cameraData
-
struct RendererStats
- #include <Renderer.h>
Structure containing renderer statistics.
-
struct RenderSettings
- #include <Renderer.h>
Structure containing render settings.
-
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(const 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 Ref<Shader> &shader, const Ref<VertexArray> &vertexArray, const glm::mat4 &transform = glm::mat4(1.0f), uint32_t entityID = 4294967295)
Submits a draw call with the specified shader, vertex array, and transform.
- Parameters:
shader – The shader.
vertexArray – The vertex array.
transform – The transform matrix.
-
static void Submit(const Ref<Material> &material, const Ref<Mesh> &mesh, const glm::mat4 &transform = glm::mat4(1.0f), uint32_t entityID = 4294967295)
Submits a draw call with the specified material, mesh, and transform.
- Parameters:
material – The material.
mesh – The mesh.
transform – The transform matrix.
-
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<Texture> &GetRenderTexture()
Gets the render texture.
- Returns:
A reference to the render texture.
-
static inline const Ref<Texture> &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.
-
static void Init()
-
class RendererAPI
- #include <RendererAPI.h>
Class representing the Renderer API.
Public Static Functions
-
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.
-
static void SetClearColor(const glm::vec4 &color)
-
class Shader : public Coffee::Resource
- #include <Shader.h>
Class representing a shader program.
Public Functions
-
Shader(const std::string &vertexPath, const std::string &fragmentPath)
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.
-
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::string &vertexPath, const std::string &fragmentPath)
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.
-
Shader(const std::string &vertexPath, const std::string &fragmentPath)
-
struct TextureProperties
- #include <Texture.h>
Structure representing properties of a texture.
-
class Texture : public Coffee::Resource
- #include <Texture.h>
Class representing a texture.
-
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.
-
UniformBuffer(uint32_t size, uint32_t binding)
-
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.
-
VertexArray()
-
enum class ShaderDataType
Scene
- group scene
Functions
-
void AddModelToTheSceneTree(Scene *scene, Ref<Model> model)
Add a model to the scene tree.
- Parameters:
scene – The scene.
model – The model to add.
-
class Entity
- #include <Entity.h>
Class representing an entity in the scene.
Public Functions
-
Entity(entt::entity handle, Scene *scene)
Constructor for Entity with handle and scene.
- Parameters:
handle – The entity handle.
scene – The scene the entity belongs to.
-
Entity(const Entity &other) = default
Copy constructor for Entity.
- Parameters:
other – The other entity to copy from.
-
template<typename T, typename ...Args>
inline T &AddComponent(Args&&... args) Add a component to the entity.
- Template Parameters:
T – The component type.
Args – The component constructor arguments.
- Parameters:
args – The component constructor arguments.
- Returns:
Reference to the added component.
-
template<typename T>
inline T &GetComponent() Get a component from the entity.
- Template Parameters:
T – The component type.
- Returns:
Reference to the component.
-
template<typename T>
inline bool HasComponent() Check if the entity has a component.
- Template Parameters:
T – The component type.
- Returns:
True if the entity has the component, false otherwise.
-
template<typename T>
inline void RemoveComponent() Remove a component from the entity.
- Template Parameters:
T – The component type.
-
inline operator bool() const
Check if the entity is valid.
- Returns:
True if the entity is valid, false otherwise.
-
inline operator entt::entity() const
Convert the entity to its handle.
- Returns:
The entity handle.
-
inline operator uint32_t() const
Convert the entity to its handle as a uint32_t.
- Returns:
The entity handle as a uint32_t.
-
inline bool operator==(const Entity &other) const
Equality operator.
- Parameters:
other – The other entity to compare with.
- Returns:
True if the entities are equal, false otherwise.
-
Entity(entt::entity handle, Scene *scene)
-
class PrimitiveMesh
- #include <PrimitiveMesh.h>
Class representing different types of primitive meshes.
Public Static Functions
-
static Ref<Mesh> CreateCube(const glm::vec3 &size = {1.0f, 1.0f, 1.0f}, int subdivideW = 0, int subdidiveH = 0, int subdivideD = 0)
Creates a cube mesh.
- Parameters:
size – The size of the cube.
subdivideW – Number of subdivisions along the width.
subdivideH – Number of subdivisions along the height.
subdivideD – Number of subdivisions along the depth.
- Returns:
A reference to the created cube mesh.
-
static Ref<Mesh> CreateSphere(float radius = 0.5f, float height = 1.0f, int radialSegments = 64, int rings = 32, bool isHemiSphere = false)
Creates a sphere mesh.
- Parameters:
radius – The radius of the sphere.
height – The height of the sphere.
radialSegments – Number of radial segments.
rings – Number of rings.
isHemiSphere – Whether the sphere is a hemisphere.
- Returns:
A reference to the created sphere mesh.
-
static Ref<Mesh> CreatePlane(const glm::vec2 &size, const glm::vec3 &normal = {0.0f, 1.0f, 0.0f})
Creates a plane mesh.
- Parameters:
size – The size of the plane.
normal – The normal vector of the plane.
- Returns:
A reference to the created plane mesh.
-
static Ref<Mesh> CreateCylinder(float topRadius = 0.5f, float bottomRadius = 0.5f, float height = 1.0f, int radialSegments = 64, int rings = 1, bool capTop = true, bool capBottom = true)
Creates a cylinder mesh.
- Parameters:
topRadius – The radius of the top of the cylinder.
bottomRadius – The radius of the bottom of the cylinder.
height – The height of the cylinder.
radialSegments – Number of radial segments.
rings – Number of rings.
capTop – Whether to cap the top of the cylinder.
capBottom – Whether to cap the bottom of the cylinder.
- Returns:
A reference to the created cylinder mesh.
-
static Ref<Mesh> CreateCone(float radius = 0.5f, float height = 1.0f, int radialSegments = 64, int rings = 1, bool cap = true)
Creates a cone mesh.
- Parameters:
radius – The radius of the base of the cone.
height – The height of the cone.
radialSegments – Number of radial segments.
rings – Number of rings.
cap – Whether to cap the base of the cone.
- Returns:
A reference to the created cone mesh.
-
static Ref<Mesh> CreateTorus(float innerRadius = 0.5f, float outerRadius = 1.0f, int rings = 64, int ringSegments = 32)
Creates a torus mesh.
- Parameters:
innerRadius – The inner radius of the torus.
outerRadius – The outer radius of the torus.
rings – Number of rings.
ringSegments – Number of ring segments.
- Returns:
A reference to the created torus mesh.
-
static Ref<Mesh> CreateCapsule(float radius = 1.0f, float height = 4.0f, int radialSegments = 64, int rings = 8)
Creates a capsule mesh.
- Parameters:
radius – The radius of the capsule.
height – The height of the capsule.
radialSegments – Number of radial segments.
rings – Number of rings.
- Returns:
A reference to the created capsule mesh.
-
static Ref<Mesh> CreateCube(const glm::vec3 &size = {1.0f, 1.0f, 1.0f}, int subdivideW = 0, int subdidiveH = 0, int subdivideD = 0)
-
class Scene
- #include <Scene.h>
Class representing a scene.
Public Functions
-
~Scene() = default
Default destructor.
-
Entity CreateEntity(const std::string &name = std::string())
Create an entity in the scene.
- Parameters:
name – The name of the entity.
- Returns:
The created entity.
-
void DestroyEntity(Entity entity)
Destroy an entity in the scene.
- Parameters:
entity – The entity to destroy.
-
void OnInit()
Initialize the scene.
-
void OnUpdateEditor(EditorCamera &camera, float dt)
Update the scene in editor mode.
- Parameters:
camera – The editor camera.
dt – The delta time.
-
void OnUpdateRuntime(float dt)
Update the scene in runtime mode.
- Parameters:
dt – The delta time.
-
void OnExit()
Exit the scene.
-
~Scene() = default
-
class SceneCamera : public Coffee::Camera
- #include <SceneCamera.h>
Camera class for the scene.
Public Functions
-
SceneCamera()
Constructor for SceneCamera.
-
~SceneCamera() = default
Default destructor.
-
SceneCamera()
-
struct HierarchyComponent
- #include <SceneTree.h>
Component for managing entity hierarchy.
Public Functions
-
HierarchyComponent(entt::entity parent)
Constructor with parent entity.
- Parameters:
parent – The parent entity.
-
HierarchyComponent()
Default constructor.
Public Static Functions
-
static void OnConstruct(entt::registry ®istry, entt::entity entity)
Called when the component is constructed.
- Parameters:
registry – The entity registry.
entity – The entity.
-
static void OnDestroy(entt::registry ®istry, entt::entity entity)
Called when the component is destroyed.
- Parameters:
registry – The entity registry.
entity – The entity.
-
static void OnUpdate(entt::registry ®istry, entt::entity entity)
Called when the component is updated.
- Parameters:
registry – The entity registry.
entity – The entity.
-
static void Reparent(entt::registry ®istry, entt::entity entity, entt::entity parent)
Reparent the entity to a new parent.
- Parameters:
registry – The entity registry.
entity – The entity to reparent.
parent – The new parent entity.
-
HierarchyComponent(entt::entity parent)
-
class SceneTree
- #include <SceneTree.h>
Class for managing the scene tree.
-
void AddModelToTheSceneTree(Scene *scene, Ref<Model> model)