QuasarEngine
Cross-platform 3D engine and editor
Loading...
Searching...
No Matches
Layer.h
Go to the documentation of this file.
1#pragma once
2
7
10
11#include <string>
12#include <utility>
13
14namespace Quasar
15{
22 class Layer
23 {
24 public:
25 virtual ~Layer() = default;
26
27 Layer(const Layer&) = delete;
28 Layer& operator=(const Layer&) = delete;
29 Layer(Layer&&) = delete;
30 Layer& operator=(Layer&&) = delete;
31
33 virtual void OnAttach() {}
34
36 virtual void OnDetach() {}
37
40 virtual void OnUpdate([[maybe_unused]] Timestep timestep) {}
41
43 virtual void OnRender() {}
44
46 virtual void OnImGuiRender() {}
47
51 virtual void OnEvent([[maybe_unused]] Event& event) {}
52
54 const std::string& GetName() const { return m_Name; }
55
56 protected:
58 explicit Layer(std::string name = "Layer") : m_Name(std::move(name)) {}
59
60 private:
61 std::string m_Name;
62 };
63}
Base class of all events, with their types and categories.
Contains the Timestep class, which represents a time duration in seconds.
Base class of all events.
Definition Event.h:95
virtual void OnAttach()
Called once when the layer is added to the application, before any other hook.
Definition Layer.h:33
Layer(std::string name="Layer")
Creates a layer with a name, used in logs and debugging tools.
Definition Layer.h:58
virtual void OnDetach()
Called once when the layer is removed from the application, after every other hook.
Definition Layer.h:36
const std::string & GetName() const
Returns the name of the layer, for debugging.
Definition Layer.h:54
virtual void OnEvent(Event &event)
Called for each event received by the layer.
Definition Layer.h:51
virtual void OnImGuiRender()
Called once per frame, after OnRender(), to draw the ImGui windows of the layer.
Definition Layer.h:46
virtual void OnUpdate(Timestep timestep)
Called once per frame to update the layer.
Definition Layer.h:40
virtual void OnRender()
Called once per frame, after OnUpdate(), to render the layer.
Definition Layer.h:43
Time elapsed between two frames, in seconds.
Definition Timestep.h:15
Contains all the engine code.