SpiecsEngine
 
Loading...
Searching...
No Matches
VulkanWindows.h
Go to the documentation of this file.
1/**
2* @file VulkanWindows.h.
3* @brief The VulkanWindows Class Definitions.
4* @author Spices.
5*/
6
7#pragma once
8#include "Core/Core.h"
9#include "VulkanUtils.h"
10
11#include <stb_image.h>
12
13namespace Spices {
14
15 /**
16 * @brief This struct helps load the icon of window.
17 */
19 {
20 /**
21 * @brief Constructor Function.
22 * Load the icon file immediately.
23 * @param[in] iconPath The file path of icon.
24 */
25 WindowIcon(const std::string& iconPath)
26 {
27 if (image.pixels)
28 {
29 stbi_image_free(image.pixels);
30 }
31
32 int texChannels;
33 image.pixels = stbi_load(iconPath.c_str(), &image.width, &image.height, &texChannels, STBI_rgb_alpha);
34 if (!image.pixels)
35 {
36 SPICES_CORE_ERROR("Failed to load texture image!");
37 }
38 }
39
40 /**
41 * @brief Destructor Function.
42 */
43 virtual ~WindowIcon()
44 {
45 stbi_image_free(image.pixels);
46 }
47
48 /**
49 * @brief GLFWimage.
50 */
51 GLFWimage image { 0, 0, nullptr};
52 };
53
54 /**
55 * @brief This struct defines the basic information of window.
56 */
58 {
59 /**
60 * @brief Window's width.
61 */
62 int width;
63
64 /**
65 * @brief Window's height.
66 */
67 int height;
68
69 /**
70 * @brief Window's name.
71 */
72 std::string name;
73
74 /**
75 * @brief Window's icon.
76 */
77 std::shared_ptr<WindowIcon> icon;
78 };
79
80 /**
81 * @brief VulkanWindows Class.
82 * This class defines the windows behaves.
83 */
85 {
86 public:
87
88 /**
89 * @brief Constructor Function.
90 * Create Windows.
91 * @param[in] vulkanState The global VulkanState.
92 * @param[in] initInfo WindowInfo.
93 */
95 VulkanState& vulkanState ,
96 const WindowInfo& initInfo
97 );
98
99 /**
100 * @brief Destructor Function.
101 */
102 virtual ~VulkanWindows() override;
103
104 /**
105 * @brief Get m_WindowsResized variable.
106 * @return Returns the m_WindowsResized variable.
107 */
108 bool IsResized() const { return m_WindowsResized; }
109
110 /**
111 * @brief Set m_WindowsResized variable.
112 * @param[in] isResized .
113 */
114 void SetResized(bool isResized) { m_WindowsResized = isResized; }
115
116 private:
117
118 /**
119 * @brief Set all needed GLFW events call back.
120 */
121 void SetInternalCallBack() const;
122
123 private:
124
125 /**
126 * @brief Window's info.
127 * not viewport's info.
128 */
130
131 /**
132 * @brief True if viewPort is resized.
133 */
134 bool m_WindowsResized = false;
135 };
136}
#define EVENT_CLASS_TYPE(type)
Defines Event type.
Definition Event.h:74
#define EVENT_CLASS_CATEGORY(category)
Defines Event category.
Definition Event.h:82
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
#define SPICES_PROFILE_FRAME
virtual ~Application()
Destructor Function.
Application()
Constructor Function.
static void Run()
Run Our World.
Application Class. Our Engine Start here.
Definition Application.h:20
This Class is the basic Event Class. Inherit from it and create specific event class.
Definition Event.h:96
uint32_t m_PickMaterial
Identify of selected material.
Definition FrameInfo.h:89
FrameInfo(const FrameInfo &)=delete
Copy Constructor Function.
uint32_t m_FrameIndex
FrameIndex, varying during 0 - (MaxFrameInFlight - 1). Used almost anywhere.
Definition FrameInfo.h:69
FrameInfo & operator=(const FrameInfo &)=delete
Copy Assignment Operation.
virtual ~FrameInfo()=default
Destructor Function.
static FrameInfo & Get()
Get FrameInfo.
Definition FrameInfo.cpp:14
std::shared_ptr< World > m_World
The shared pointer of specific world.
Definition FrameInfo.h:94
scl::linked_unordered_map< int, std::string > m_PickEntityID
Definition FrameInfo.h:82
RendererType m_RendererType
The renderer type of current world.
Definition FrameInfo.h:99
FrameInfo()=default
Constructor Function.
uint32_t m_ImageIndex
ImageIndex, varying during 0 - (MaxFrameInFlight - 1). Used in swapchain index and framebuffer index.
Definition FrameInfo.h:75
FrameInfo Class. This class defines the FrameInfo data.
Definition FrameInfo.h:32
static void Init()
Init Log.
Definition Log.cpp:24
static void ShutDown()
Shutdown Log.
Definition Log.cpp:82
virtual std::string ToString() const override
Serialize this Event Class to string.
Definition WorldEvent.h:60
MeshAddedWorldEvent()=default
Constructor Function.
virtual ~MeshAddedWorldEvent() override=default
Destructor Function.
This Class is inherited from Event Class.
Definition WorldEvent.h:43
NativeScriptSystem Class. This class defines the specific behaves of NativeScriptSystem.
ResourceSystem Class. This class defines the specific behaves of RenderSystem.
RendererResourcePool Class. This class is a pool of all framebuffer's attachment.
ResourceSystem Class. Handles resource load/unload event.
This Class is inherited from Event Class. Called by Viewport Resize.
Definition SlateEvent.h:18
SlateSystem Class. This class defines the specific behaves of SlateSystem.
Definition SlateSystem.h:21
SystemManager()
Constructor Function.
static SystemManager & Get()
Get Static SystemManager.
SystemManager & PopSystem(const std::string &systemName)
Push a system to this manager.
SystemManager Class. This class defines the behave of SystemManager.
void Flush()
Refresh time in each engine loop.
Definition TimeStep.cpp:26
const uint64_t & fs() const
Get frames count.
Definition TimeStep.h:63
This Class handles our engine time step during frames. Global Unique.
Definition TimeStep.h:22
VulkanDescriptorPool Class. This class is the wrapper of VkDescriptorPool.
VulkanInstance Class. This class defines the VulkanDevice behave. This class is just a wrapper of vkd...
VulkanObject Class. This class defines the basic behaves of VulkanObject. When we create an new Vulka...
void EndFrame(FrameInfo &frameInfo)
End record the frame with vulkan render backend.
void RecreateSwapChain()
Called OnSlateResize.
std::shared_ptr< VulkanMemoryAllocator > m_VmaAllocator
VulkanMemoryAllocator.
std::unique_ptr< VulkanSwapChain > m_VulkanSwapChain
VulkanSwapChain.
virtual ~VulkanRenderBackend()
Destructor Function.
std::unique_ptr< VulkanCommandPool > m_VulkanCommandPool
VulkanCommandPool.
VulkanRenderBackend()
Constructor Function.
static std::shared_ptr< VulkanDescriptorPool > GetDescriptorPool()
Get DescriptorPool in use.
static VulkanState m_VulkanState
The VulkanState in use.
std::unique_ptr< VulkanCommandBuffer > m_VulkanCommandBuffer
VulkanCommandBuffer.
bool isWindowClosed()
Determine whether window is closed.
static std::shared_ptr< VulkanDescriptorPool > m_VulkanDescriptorPool
The VulkanDescriptorPool in use.
static std::shared_ptr< RendererResourcePool > m_RendererResourcePool
The RendererResourcePool in use.
static VulkanState & GetState()
Get VulkanState in use.
std::unique_ptr< VulkanWindows > m_VulkanWindows
VulkanWindows.
bool OnMeshAddedWorldEvent(WorldEvent &event)
This function is called on world mark query tick.
void RenderFrame(TimeStep &ts, FrameInfo &frameInfo)
Draw World.
void OnEvent(Event &event)
This function is called on global event function is called.
static std::shared_ptr< RendererResourcePool > GetRendererResourcePool()
Get RendererResourcePool in use.
void BeginFrame(FrameInfo &frameInfo)
Start record a new frame with vulkan render backend.
VulkanRenderBackend & operator=(const VulkanRenderBackend &)=delete
Copy Assignment Operation.
bool OnWindowResizeOver(WindowResizeOverEvent &event)
This function is called on window is resized over.
std::shared_ptr< VulkanDevice > m_VulkanDevice
VulkanDevice.
std::unique_ptr< VulkanInstance > m_VulkanInstance
VulkanInstance.
bool OnSlateResize(SlateResizeEvent &event)
This function is called on viewport is resized.
VulkanRenderBackend(const VulkanRenderBackend &)=delete
Copy Constructor Function.
This class defines the render backend behaves of Vulkan.
VulkanWindows(VulkanState &vulkanState, const WindowInfo &initInfo)
Constructor Function. Create Windows.
bool m_WindowsResized
True if viewPort is resized.
virtual ~VulkanWindows() override
Destructor Function.
void SetInternalCallBack() const
Set all needed GLFW events call back.
void SetResized(bool isResized)
Set m_WindowsResized variable.
WindowInfo m_WindowInfo
Window's info. not viewport's info.
bool IsResized() const
Get m_WindowsResized variable.
VulkanWindows Class. This class defines the windows behaves.
virtual ~WorldEvent() override=default
Destructor Function.
WorldEvent()=default
Constructor Function.
This Class is inherited from Event Class. Inherit from it and create specific KeyEvent class....
Definition WorldEvent.h:20
World Class. This class defines the basic behaves of World. When we create an new world,...
Definition World.h:41
The container combines hashmap and list together. Used in the case that we want iter a hashmap in ord...
@ EventCategoryWorld
Definition Event.h:68
@ MeshAdded
World Event.
RendererType
Definition FrameInfo.h:22
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74
GLFWimage image
GLFWimage.
WindowIcon(const std::string &iconPath)
Constructor Function. Load the icon file immediately.
virtual ~WindowIcon()
Destructor Function.
This struct helps load the icon of window.
std::shared_ptr< WindowIcon > icon
Window's icon.
std::string name
Window's name.
int width
Window's width.
int height
Window's height.
This struct defines the basic information of window.