12#include <utility/graphic/material.hpp>
14#include "evan/Version.hpp"
16#include "evan/DeviceContext.hpp"
17#include "evan/RenderSettings.hpp"
18#include "evan/Renderer.hpp"
19#include "evan/ASwapchainContext.hpp"
20#include "evan/IPlatform.hpp"
24#include <utility/graphic/model.hpp>
25#include <utility/graphic/primitive.hpp>
26#include <utility/graphic/view.hpp>
27#include <utility/graphic/text/text.hpp>
29#include <utility/ressource_provider.hpp>
31#include <utility/event/event.hpp>
32#include <utility/event/keyboard_event.hpp>
33#include <utility/event/mouse_motion_event.hpp>
34#include <utility/event/mouse_button_event.hpp>
35#include <utility/event/hand_motion_event.hpp>
36#include <utility/event/hand_thumb_stick_event.hpp>
38#include <utility/logging/loggable.hpp>
39#include <utility/logging/default_logger.hpp>
41#include <utility/engine.hpp>
43#include "RenderObject.hpp"
44#include "RessourceManager.hpp"
125 Engine(std::shared_ptr<utility::RessourceProvider> ressourceProvider,
126 std::shared_ptr<IPlatform> platform,
191 utility::graphic::ViewF
getView(
void)
const override;
200 utility::graphic::SizeF
227 size_t addMesh(
const utility::graphic::Mesh &mesh,
228 const std::string &materialName =
"default_material",
229 const std::string &shader =
"default");
237 std::shared_ptr<utility::graphic::Renderable>
object)
override;
245 bool updateObject(std::shared_ptr<utility::graphic::Renderable>
object,
246 size_t objectID)
override;
254 bool removeObject(std::shared_ptr<utility::graphic::Renderable>
object,
255 size_t objectID)
override;
336 void setScissor(
const utility::graphic::ScissorRect &rect)
override;
393 return _shouldCaptureViewportInput;
406 _shouldCaptureViewportInput = shouldCapture;
463 std::make_shared<Version>(0, 1, 0);
537 bool _shouldCaptureViewportInput =
true;
550 std::vector<std::shared_ptr<utility::event::Event>>
551 _capturedViewportEvents;
559 bool _isRightMouseButtonPressed =
false;
567 utility::math::Vector2F _lastMousePosition { 0.0f, 0.0f };
578 size_t _debugRayObjectID = std::numeric_limits<size_t>::max();
591 void handleViewportInput(
592 const std::vector<std::shared_ptr<utility::event::Event>> &events);
604 void handleKeyboardMovement(
605 const std::shared_ptr<utility::event::KeyboardEvent> &keyboardEvent,
606 const utility::graphic::OrientationF &orientation,
607 utility::graphic::PositionF &position,
float movementSpeed,
616 void handleMouseButtonEvent(
617 const std::shared_ptr<utility::event::MouseButtonEvent>
619 bool &isRightMouseButtonPressed,
620 utility::math::Vector2F &lastMousePosition);
630 void handleMouseMotionEvent(
631 const std::shared_ptr<utility::event::MouseMotionEvent>
633 bool isRightMouseButtonPressed,
634 utility::math::Vector2F &lastMousePosition,
635 utility::graphic::OrientationF &orientation,
float rotationSpeed,
646 void handleHandMotionEvent(
647 const std::shared_ptr<utility::event::HandMotionEvent>
649 utility::graphic::PositionF &position,
650 utility::graphic::OrientationF &orientation,
float movementSpeed,
651 float rotationSpeed,
float deltaTime);
666 void handleThumbStickEvent(
667 const std::shared_ptr<utility::event::HandThumbStickEvent>
669 utility::graphic::PositionF &position,
670 utility::graphic::OrientationF &orientation,
float movementSpeed,
671 float rotationSpeed,
float deltaTime);
682 void updateDebugRay(
const utility::graphic::RayF &ray);
687 std::chrono::steady_clock::time_point _lastFrameTime;
692 float _deltaTime { 0.0f };
701 float _targetFps { 0.0f };
707 void updateDeltaTime(
void);
The Engine class is the main entry point for the Evan Engine. It manages the core components of the e...
size_t createObject(std::shared_ptr< utility::graphic::Renderable > object) override
Creates a new renderable object.
bool removeObject(std::shared_ptr< utility::graphic::Renderable > object, size_t objectID) override
Removes a renderable object from the engine.
bool updateObject(std::shared_ptr< utility::graphic::Renderable > object, size_t objectID) override
Updates an existing renderable object.
utility::graphic::SizeF measureText(const utility::graphic::Text &text) const override
Measures the pixel dimensions of a given text string when rendered with a specific font.
utility::graphic::ViewF getView(void) const override
Get the mirrored view state.
bool shouldCaptureViewportInput(void) const
Checks if the engine should capture viewport input. This method returns a boolean value indicating wh...
bool isInstancingEnabled() const
Checks whether identical meshes are merged into one draw.
void clear(void) override
Clears the current rendering target.
void setScissor(const utility::graphic::ScissorRect &rect) override
Set the scissor (clip) rectangle, in framebuffer pixels.
void clearScissor(void) override
Clear the active scissor rectangle (restore full extent).
const std::string _engineVersion
std::shared_ptr< RessourceManager > _ressourceManager
bool setObjectTransform(size_t objectID, const glm::mat4 &transform)
Sets the model transform of an object in the current scene.
std::shared_ptr< IPlatform > _platform
void setTargetFps(float fps)
Sets an optional frame-rate limiter for the main loop.
void pollEvents() override
Polls for events from the platform. This method is responsible for handling input events,...
std::shared_ptr< Renderer > _renderer
const std::string _engineName
void setShouldCaptureViewportInput(bool shouldCapture)
Sets whether the engine should capture viewport input. This method allows users to enable or disable ...
void setInstancingEnabled(bool enabled)
Enables or disables merging of identical meshes.
std::shared_ptr< utility::RessourceProvider > _ressourceProvider
std::shared_ptr< DeviceContext > _deviceContext
Error getLastError() const
Returns the last error recorded by the platform.
void present(void) override
Presents the composed back buffer to the screen.
Error render()
Renders the engine's render objects. This method is responsible for drawing the render objects regist...
const std::shared_ptr< Version > _version
void setIndirectDrawingEnabled(bool enabled)
Enables or disables indirect drawing.
std::shared_ptr< ASwapchainContext > _swapchainContext
float getDeltaTime(void) const override
Get the delta time from the last frame in seconds.
size_t addMesh(const utility::graphic::Mesh &mesh, const std::string &materialName="default_material", const std::string &shader="default")
Adds a mesh to the renderer. This method takes a Mesh object, which contains the necessary informatio...
void update() override
Updates the state of the engine. This method is responsible for handling logic updates,...
const FrameStats & getFrameStats() const
Gets the renderer's frame statistics window.
bool isIndirectDrawingEnabled() const
Checks whether indirect drawing is enabled.
float getTargetFps(void) const
Gets the configured target frame rate for the loop limiter.
Engine(std::shared_ptr< utility::RessourceProvider > ressourceProvider, std::shared_ptr< IPlatform > platform, RenderSettings settings={})
Constructs a new Engine object with default settings. This constructor initializes the engine with de...
Per-frame instrumentation data (CPU phases and counters).
Application-facing rendering configuration.