Skylicht Engine
Loading...
Searching...
No Matches
CRenderToTextureRP.h
1/*
2!@
3MIT License
4
5Copyright (c) 2025 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "CBaseRP.h"
28
29namespace Skylicht
30{
91 class SKYLICHT_API CRenderToTextureRP : public CBaseRP
92 {
93 protected:
94 int m_id;
95 bool m_enable;
96 core::matrix4 m_bias;
97 float m_scale;
98 core::dimension2du m_size;
99 core::dimension2du m_customSize;
100 CCamera* m_customCamera;
101 ITexture* m_renderTarget;
102 IRenderPipeline* m_customPipleline;
103 video::ECOLOR_FORMAT m_format;
104 bool m_autoGenerateMipmap;
105
106 public:
107 CRenderToTextureRP(u32 id, video::ECOLOR_FORMAT format, const core::dimension2du& customSize = core::dimension2du(), float scale = 1.0f);
108
109 virtual ~CRenderToTextureRP();
110
111 virtual void initRender(int w, int h);
112
113 virtual void resize(int w, int h);
114
115 virtual void render(ITexture* target, CCamera* camera, CEntityManager* entityManager, const core::recti& viewport, int cubeFaceId = -1, IRenderPipeline* lastRP = NULL);
116
117 inline void setCustomCamera(CCamera* camera)
118 {
119 m_customCamera = camera;
120 }
121
122 inline CCamera* getCustomCamera()
123 {
124 return m_customCamera;
125 }
126
127 inline int getId()
128 {
129 return m_id;
130 }
131
132 inline bool isEnable()
133 {
134 return m_enable;
135 }
136
137 inline void setEnable(bool b)
138 {
139 m_enable = b;
140 }
141
142 inline ITexture* getTarget()
143 {
144 return m_renderTarget;
145 }
146
147 inline void setCustomPipleline(IRenderPipeline* pipeline)
148 {
149 m_customPipleline = pipeline;
150 }
151
152 inline void enableAutoGenerateMipmap(bool b)
153 {
154 m_autoGenerateMipmap = b;
155 }
156
157 inline bool isAutoGenerateMipmap()
158 {
159 return m_autoGenerateMipmap;
160 }
161
162 static const float* getMatrix(int id);
163
164 protected:
165
166 void initRTT(int w, int h);
167
168 void releaseRTT();
169 };
170}
This is an object class used to set up the camera, including its position, viewing angle,...
Definition CCamera.h:70
This object class manages all entities within a scene.
Definition CEntityManager.h:89
Definition IRenderPipeline.h:37
Interface of a Video Driver dependent Texture.
Definition ITexture.h:119
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
rect< s32 > recti
Rectangle with int values.
Definition rect.h:273
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
dimension2d< u32 > dimension2du
Typedef for an unsigned integer dimension.
Definition dimension2d.h:212
ECOLOR_FORMAT
An enum for the color format of textures used by the Irrlicht Engine.
Definition SColor.h:18
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58