17 #ifndef GZ_RENDERING_BASE_BASERENDERTARGET_HH_
18 #define GZ_RENDERING_BASE_BASERENDERTARGET_HH_
32 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
44 public:
virtual void PreRender()
override;
47 public:
virtual void PostRender()
override;
49 public:
virtual unsigned int Width()
const override;
51 public:
virtual void SetWidth(
const unsigned int _width)
override;
53 public:
virtual unsigned int Height()
const override;
55 public:
virtual void SetHeight(
const unsigned int _height)
override;
57 public:
virtual PixelFormat Format()
const override;
59 public:
virtual void SetFormat(
PixelFormat _format)
override;
62 public:
virtual math::Color BackgroundColor()
const override;
65 public:
virtual void AddRenderPass(
const RenderPassPtr &_pass)
override;
68 public:
virtual void RemoveRenderPass(
const RenderPassPtr &_pass)
72 public:
virtual unsigned int RenderPassCount()
const override;
75 public:
virtual RenderPassPtr RenderPassByIndex(
unsigned int _index)
78 protected:
virtual void Rebuild();
80 protected:
virtual void RebuildImpl() = 0;
84 protected:
bool targetDirty =
true;
87 protected:
bool renderPassDirty =
false;
89 protected:
unsigned int width = 0u;
91 protected:
unsigned int height = 0u;
107 public:
virtual unsigned int GLId()
const override;
110 public:
virtual void MetalId(
void *_textureIdPtr)
const override;
124 public:
virtual void SetHandle(
const std::string &_handle);
126 public:
virtual double DevicePixelRatio()
const;
128 public:
virtual void SetDevicePixelRatio(
const double _ratio);
130 public:
virtual void OnResize(
const unsigned int _width,
131 const unsigned int _height);
133 public:
virtual void OnMove();
137 protected:
double ratio = 1.0;
160 for (
auto &pass : this->renderPasses)
175 if (this->targetDirty)
178 this->targetDirty =
false;
193 this->width = _width;
194 this->targetDirty =
true;
208 this->height = _height;
209 this->targetDirty =
true;
224 this->targetDirty =
true;
238 this->renderPasses.push_back(_pass);
239 this->renderPassDirty =
true;
246 auto it =
std::find(this->renderPasses.begin(), this->renderPasses.end(),
248 if (it != this->renderPasses.end())
251 this->renderPasses.erase(it);
252 this->renderPassDirty =
true;
260 return this->renderPasses.size();
268 if (_index > this->renderPasses.size())
270 gzerr <<
"RenderPass index out of range: " << _index <<
std::endl;
273 return this->renderPasses[_index];
328 this->handle = _handle;
329 this->targetDirty =
true;
343 this->ratio = _ratio;
344 this->targetDirty =
true;
350 const unsigned int _height)
352 this->width = _width;
353 this->height = _height;
354 this->targetDirty =
true;
361 this->targetDirty =
true;