Pioneer
RenderTarget.h
Go to the documentation of this file.
1 // Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #ifndef _GRAPHICS_RENDERTARGET_H
5 #define _GRAPHICS_RENDERTARGET_H
6 /*
7  * Render target. Created by filling out a description and calling
8  * renderer->CreateRenderTarget.
9  */
10 #include "Texture.h"
11 
12 namespace Graphics {
13 
14  // A render target may have a color texture, depth buffer/texture or both.
15  // Setting the formats to NONE will skip the texture creation, and you will
16  // have to set the textures yourself.
17  // Only request allowDepthTexture if you actually need to read the depth as texture
18  // Specifying a depth format with no allowDepthTexture will create a depth buffer
19  // fixed to this rendertarget
21  RenderTargetDesc(Uint16 _width, Uint16 _height, TextureFormat _colorFormat, TextureFormat _depthFormat, bool _allowDepthTexture = false, Uint16 _samples = 0) :
22  width(_width),
23  height(_height),
24  colorFormat(_colorFormat),
25  depthFormat(_depthFormat),
26  allowDepthTexture(_allowDepthTexture),
27  numSamples(_samples)
28  {}
29 
30  const Uint16 width;
31  const Uint16 height;
34  const bool allowDepthTexture;
35  const Uint16 numSamples;
36  };
37 
38  class RenderTarget {
39  public:
40  virtual ~RenderTarget() {}
41 
42  virtual Texture *GetColorTexture() const = 0;
43  virtual Texture *GetDepthTexture() const = 0;
44 
45  //Replace the texture attachment, or pass zero to detach
46  //Increases the new texture's reference count and decreases
47  //any existing texture's count
48  //Setting a depth texture is not allowed if the render target is not
49  //created with allowDepthTexture
50  virtual void SetCubeFaceTexture(const Uint32, Texture *) = 0;
51  virtual void SetColorTexture(Texture *) = 0;
52  virtual void SetDepthTexture(Texture *) = 0;
53 
54  const RenderTargetDesc &GetDesc() const { return m_desc; }
55 
56  protected:
58  m_desc(d) {}
59 
61  };
62 
63 } // namespace Graphics
64 
65 #endif
Definition: RenderTarget.h:38
RenderTarget(const RenderTargetDesc &d)
Definition: RenderTarget.h:57
virtual ~RenderTarget()
Definition: RenderTarget.h:40
virtual void SetCubeFaceTexture(const Uint32, Texture *)=0
virtual Texture * GetDepthTexture() const =0
virtual void SetColorTexture(Texture *)=0
const RenderTargetDesc & GetDesc() const
Definition: RenderTarget.h:54
virtual void SetDepthTexture(Texture *)=0
virtual Texture * GetColorTexture() const =0
RenderTargetDesc m_desc
Definition: RenderTarget.h:60
Definition: Texture.h:106
Definition: Background.h:14
TextureFormat
Definition: Texture.h:14
Definition: RenderTarget.h:20
const Uint16 height
Definition: RenderTarget.h:31
RenderTargetDesc(Uint16 _width, Uint16 _height, TextureFormat _colorFormat, TextureFormat _depthFormat, bool _allowDepthTexture=false, Uint16 _samples=0)
Definition: RenderTarget.h:21
const Uint16 numSamples
Definition: RenderTarget.h:35
const TextureFormat colorFormat
Definition: RenderTarget.h:32
const Uint16 width
Definition: RenderTarget.h:30
const bool allowDepthTexture
Definition: RenderTarget.h:34
const TextureFormat depthFormat
Definition: RenderTarget.h:33