SpiecsEngine
 
Loading...
Searching...
No Matches
RendererResource.cpp
Go to the documentation of this file.
1/**
2* @file RendererResource.cpp.
3* @brief The RendererResource Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9
10namespace Spices {
11
13 : m_Info(info)
14 {
16
17 /**
18 * @brief Set local variable.
19 */
21
22 /**
23 * @brief Create the texture with specific info.
24 */
25 switch (info.type)
26 {
27 case TextureType::Texture2D:
28 m_Texture = std::make_unique<Texture2D>(info);
29 break;
30 case TextureType::Texture2DArray:
31 m_Texture = std::make_unique<Texture2DArray>(info);
32 break;
33 case TextureType::Texture2DCube:
34 m_Texture = std::make_unique<Texture2DCube>(info);
35 break;
36 default:
37 SPICES_CORE_ERROR("Not supported Texture Class Type");
38 break;
39 }
40 }
41
42 void RendererResource::OnResized(const uint32_t width, const uint32_t height)
43 {
45
46 /**
47 * @brief Go on if can resize,
48 */
49 if (!m_IsResizeable) return;
50
51 /**
52 * @brief Update info's width.
53 */
54 m_Info.width = width;
55
56 /**
57 * @brief Update info's height.
58 */
59 m_Info.height = height;
60
61 /**
62 * @brief Recreate the texture with specific info.
63 */
64 switch (m_Info.type)
65 {
66 case TextureType::Texture2D:
67 m_Texture = std::make_unique<Texture2D>(m_Info);
68 break;
69 case TextureType::Texture2DArray:
70 m_Texture = std::make_unique<Texture2DArray>(m_Info);
71 break;
72 case TextureType::Texture2DCube:
73 m_Texture = std::make_unique<Texture2DCube>(m_Info);
74 break;
75 default:
76 SPICES_CORE_ERROR("Not supported Texture Class Type");
77 break;
78 }
79 }
80}
#define SPICES_PROFILE_ZONE
RendererResource(const RendererResourceCreateInfo &info)
Constructor Function. Init member variables.
bool m_IsResizeable
True if this resource can resize.
RendererResource Class. This class is a wrapper of framebuffer attachment.
TextureType type
Texture's Class Type.
bool isResizeable
True if this resource needs resize(sync with viewport's size).
This struct defines the data used to create a texture2d. From render pass.