GteDrawTarget.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <Graphics/GteTextureDS.h>
11 #include <Graphics/GteTextureRT.h>
12 #include <memory>
13 
14 namespace gte
15 {
16 
18 {
19 public:
20  // Construction and destruction. The number of supported targets depends
21  // on the graphics hardware and drivers. The number of render targets
22  // must be at least 1. Set 'hasRTData' to 'true' iff you want system
23  // memory data for the color textures. Set 'dsFormat' to a valid format
24  // when you want depth-stencil; these are
25  // DF_D32_FLOAT_S8X24_UINT
26  // DF_D32_FLOAT
27  // DF_D24_UNORM_S8_UINT
28  // DF_D16_UNORM
29  // Set 'dsFormat' to DF_UNKNOWN when you do not want a depth-stencil. Set
30  // 'hasDSData' to 'true' iff you want system memory data for the
31  // depth-stencil.
32  virtual ~DrawTarget();
33  DrawTarget(unsigned int numRenderTargets, DFType rtFormat,
34  unsigned int width, unsigned int height, bool hasRTMipmaps = false,
35  bool createRTStorage = true, DFType dsFormat = DF_UNKNOWN,
36  bool createDSStorage = false);
37 
38  // Member access.
39  unsigned int GetNumTargets() const;
40  DFType GetRTFormat() const;
41  unsigned int GetWidth() const;
42  unsigned int GetHeight() const;
43  bool HasRTMipmaps() const;
44  DFType GetDSFormat() const;
45  std::shared_ptr<TextureRT> const GetRTTexture(unsigned int i) const;
46  std::shared_ptr<TextureDS> const GetDSTexture() const;
47 
48  // Request that the GPU compute mipmap levels when the base-level render
49  // target is written. The AutogenerateMipmaps call should be made before
50  // binding the texture to the engine. If the texture does not have mipmaps,
51  // the AutogenerateMipmaps call will not set mAutogenerateMipmaps to true.
52  void AutogenerateRTMipmaps();
53  bool WantAutogenerateRTMipmaps() const;
54 
55  // Listeners subscribe to receive notification when a DrawTarget is about
56  // to be destroyed. The intended use is for the DX11Engine objects to
57  // destroy corresponding DX11DrawTarget objects.
59  {
60  public:
63  virtual void OnDestroy(DrawTarget const*) { }
64  };
65 
66  static void SubscribeForDestruction(std::shared_ptr<ListenerForDestruction> const& listener);
67  static void UnsubscribeForDestruction(std::shared_ptr<ListenerForDestruction> const& listener);
68 
69 protected:
70  std::vector<std::shared_ptr<TextureRT>> mRTTextures;
71  std::shared_ptr<TextureDS> mDSTexture;
72 
73 private:
74  // Support for listeners for destruction (LFD).
75  static std::mutex msLFDMutex;
76  static std::set<std::shared_ptr<ListenerForDestruction>> msLFDSet;
77 };
78 
79 }
GLint GLsizei width
Definition: glcorearb.h:98
virtual void OnDestroy(DrawTarget const *)
Definition: GteDrawTarget.h:63
std::shared_ptr< TextureDS > mDSTexture
Definition: GteDrawTarget.h:71
static std::set< std::shared_ptr< ListenerForDestruction > > msLFDSet
Definition: GteDrawTarget.h:76
GLint GLsizei GLsizei height
Definition: glcorearb.h:98
static std::mutex msLFDMutex
Definition: GteDrawTarget.h:75
std::vector< std::shared_ptr< TextureRT > > mRTTextures
Definition: GteDrawTarget.h:70
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63
DF_UNKNOWN
Definition: GteDataFormat.h:20


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59