cae  0.0.0
Cross-API graphics engine
Loading...
Searching...
No Matches
IRenderer.hpp
Go to the documentation of this file.
1///
2/// @file IRenderer.hpp
3/// @brief This file contains the Renderer interface
4/// @namespace cae
5///
6
7#pragma once
8
11
12#include <glm/mat4x4.hpp>
13
14namespace cae
15{
16
17 ///
18 /// @struct Color
19 /// @brief Struct for color
20 /// @namespace cae
21 ///
22 struct Color
23 {
24 float r;
25 float g;
26 float b;
27 float a;
28 };
29
30 ///
31 /// @interface IRenderer
32 /// @brief Interface for renderer
33 /// @namespace cae
34 ///
35 class IRenderer : public utl::IPlugin
36 {
37
38 public:
39 ~IRenderer() override = default;
40
41 ///
42 /// @param enabled Whether VSync is enabled
43 /// @brief Enable or disable VSync
44 ///
45 virtual void setVSyncEnabled(bool enabled) = 0;
46
47 ///
48 /// @param color Clear color to set
49 /// @brief Set the clear color
50 ///
51 virtual void setClearColor(const Color &color) = 0;
52
53 ///
54 /// @return Whether VSync is enabled
55 /// @brief Check if VSync is enabled
56 ///
57 [[nodiscard]] virtual bool isVSyncEnabled() const = 0;
58
59 ///
60 /// @param nativeWindowHandle Native window handle
61 /// @param clearColor Clear color (default: white)
62 /// @brief Initialize the renderer with a native window handle and clear color
63 ///
64 virtual void initialize(const NativeWindowHandle &nativeWindowHandle,
65 const Color &clearColor = {.r = 1.F, .g = 1.F, .b = 1.F, .a = 1.F}) = 0;
66
67 ///
68 /// @param id Shader ID
69 /// @param vertex Vertex shader IR module
70 /// @param fragment Fragment shader IR module
71 /// @brief Create a rendering pipeline with vertex and fragment shaders
72 ///
73 virtual void createPipeline(const ShaderID &id, const ShaderIRModule &vertex,
74 const ShaderIRModule &fragment) = 0;
75
76 ///
77 /// @param windowSize Current window size
78 /// @param shaderId Shader ID to use for drawing
79 /// @param mvp Model-View-Projection matrix
80 /// @brief Draw the scene using the specified shader and window size
81 ///
82 virtual void draw(const WindowSize &windowSize, const ShaderID &shaderId, glm::mat4 mvp) = 0;
83
84 ///
85 /// @param vertices Vertex data to create the mesh
86 /// @brief Create a mesh with the given vertex data
87 ///
88 virtual void createMesh(const std::vector<float> &vertices) = 0;
89
90 }; // interface IRenderer
91
92} // namespace cae
This file contains the ShaderFrontend interface.
This file contains the Window interface.
Interface for renderer.
Definition IRenderer.hpp:36
virtual void setClearColor(const Color &color)=0
Set the clear color.
~IRenderer() override=default
virtual void createPipeline(const ShaderID &id, const ShaderIRModule &vertex, const ShaderIRModule &fragment)=0
Create a rendering pipeline with vertex and fragment shaders.
virtual bool isVSyncEnabled() const =0
Check if VSync is enabled.
virtual void initialize(const NativeWindowHandle &nativeWindowHandle, const Color &clearColor={.r=1.F,.g=1.F,.b=1.F,.a=1.F})=0
Initialize the renderer with a native window handle and clear color.
virtual void createMesh(const std::vector< float > &vertices)=0
Create a mesh with the given vertex data.
virtual void setVSyncEnabled(bool enabled)=0
Enable or disable VSync.
virtual void draw(const WindowSize &windowSize, const ShaderID &shaderId, glm::mat4 mvp)=0
Draw the scene using the specified shader and window size.
Interface for plugins.
Definition IPlugin.hpp:46
std::string ShaderID
Struct for color.
Definition IRenderer.hpp:23
Struct for native window handle.
Definition IWindow.hpp:34
Struct for shader intermediate representation module.
Struct for window size.
Definition IWindow.hpp:23