VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtGlRenderToTexture.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 #pragma once
6 
10 
11 
16 
17 #include <vector>
18 #include <string>
19 
20 #include <tuple>
21 
22 #define DTGLRENDERTEXTURE_FBO_DEBUG 0
23 
24 #if DTGLRENDERTEXTURE_FBO_DEBUG
25 #include <tbb/atomic.h>
26 #endif
27 
28 namespace makVrv
29 {
30  class DtGlTexture;
31 
32  // This will only contain the correct context if tracking has been set to true
33  typedef std::tuple<unsigned int, void*> DtGlFboAndContext;
34 
36  {
37  std::string myName;
38  int myWidth = 0;
39  int myHeight = 0;
40  int myNumSamples = 0;
41  int myLayers = 1;
42  bool myUseMultiView = false;
43  bool myInitColor = true;
44  };
45 
48  {
49  private:
52 
55 
57  DtGlRenderTexture& operator=(const DtGlRenderTexture&);
58 
59  public:
63 
65  virtual ~DtGlRenderTexture();
66 
68  virtual bool init(DtGlImageType colorFormat = RGB32F, GLenum minFilter = GL_LINEAR, GLenum wrapMode = GL_CLAMP_TO_EDGE);
69 
73  virtual bool init(unsigned int glColorTexId);
74 
76  virtual bool initDepth(DtGlImageType depthFormat = D32);
77 
80  virtual bool initDepth(unsigned int glDepthTexId);
81 
83  virtual void activateForDrawingInto(bool shouldClear = true, bool setViewport = true);
84 
87  virtual void copyFromFramebuffer(unsigned int srcFbo, unsigned int bufferBits);
88 
90  // isArray indicates the srcTexture is a Tex 2D array and srclayer is the layer of the array to copy from.
91  virtual void copyFromTexture(unsigned int srcTexture, bool isDepth, bool isArray = false, unsigned int srclayer = 0, unsigned int layerCount = 1);
92 
94  virtual void deactivateForDrawingInto();
95 
97  virtual void setFboTextureLayer(unsigned int layer);
98 
100  virtual void bindColorTexture(int unit);
101 
103  virtual void bindDepthTexture(int unit);
104 
106  virtual void unbindColorTexture(int unit);
107 
109  virtual void unbindDepthTexture(int unit);
110 
112  virtual int width() const;
113 
115  virtual int height() const;
116 
118  virtual int layers() const;
119 
121  virtual unsigned int colorId() const;
122 
124  virtual unsigned int depthId() const;
125 
127  virtual int numSamples() const;
128 
130  virtual bool useMultiView() const;
131 
133  virtual bool usingStencil() const;
134 
135  virtual void setDeleteFbosOnDestruction(bool val);
136  virtual bool deleteFbosOnDestruction(void) const;
137 
138  virtual DtGlFboAndContext fbo(void) const;
139  virtual DtGlFboAndContext multiSampleFbo(void) const;
140 
141  protected:
143  virtual bool hasColorTexture(void) const;
144 
146  virtual void attemptToDeleteFbo(DtGlFboAndContext& fbo);
147 
148  protected:
153 
155 
156  virtual void initFBO(const std::string& name);
157 
158  virtual GLenum getGLInternalTypes(DtGlImageType colorType);
159 
160  int myWidth;
161  int myHeight;
162  int myLayers;
163 
167 
168  DtGlTexture* myColorTexture = nullptr;
169 
170  DtGlTexture* myDepthTexture = nullptr;
171 
172  std::string myName;
173 
175 
176 #if DTGLRENDERTEXTURE_FBO_DEBUG
177  static tbb::atomic<int> theFBOCount;
178 #endif
179  };
180 
181 }
182 
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
bool myIsFrameBufferValid
Definition: DtGlRenderToTexture.h:165
int myNumSamples
Definition: DtGlRenderToTexture.h:40
DtGlFboAndContext myFboId
Definition: DtGlRenderToTexture.h:149
Dll export defines.
bool myInitColor
Definition: DtGlRenderToTexture.h:43
A helper classes for creating a RTT target, optionally including depth buffer.
Definition: DtGlRenderToTexture.h:47
DtGlFboAndContext myMultisampleFboId
Definition: DtGlRenderToTexture.h:150
int myLayers
Definition: DtGlRenderToTexture.h:162
std::string myName
Definition: DtGlRenderToTexture.h:37
std::string myName
Definition: DtGlRenderToTexture.h:172
Definition: DtGlImageType.h:28
unsigned int myMultisampleColorBuffer
Definition: DtGlRenderToTexture.h:151
bool myHasDepth
Definition: DtGlRenderToTexture.h:164
bool myDeleteFbosOnDestruction
Definition: DtGlRenderToTexture.h:154
bool myUseMultiView
Definition: DtGlRenderToTexture.h:42
int myLayers
Definition: DtGlRenderToTexture.h:41
A helper class for creating and managing OpenGL Shader programs.
DtGlImageType
Definition: DtGlImageType.h:15
Definition: DtGlImageType.h:20
std::tuple< unsigned int, void * > DtGlFboAndContext
Definition: DtGlRenderToTexture.h:30
unsigned int GLenum
Definition: DtGlTextureBufferObject.h:18
Enumerations for various types of texture/buffer formats.
Definition: DtGlRenderToTexture.h:35
bool myUseMultiView
Definition: DtGlRenderToTexture.h:166
int myWidth
Definition: DtGlRenderToTexture.h:38
#define DT_DLL_VRVGRAPHICSUTILS
Definition: vrvGraphicsUtils.h:18
int myNumSamples
Definition: DtGlRenderToTexture.h:174
int myWidth
Definition: DtGlRenderToTexture.h:160
enum representing an OpenGL image type
A helper classes for creating a RTT target, optionally including depth buffer.
Definition: DtGlTexture.h:20
unsigned int myMultisampleDepthBuffer
Definition: DtGlRenderToTexture.h:152
int myHeight
Definition: DtGlRenderToTexture.h:39
int myHeight
Definition: DtGlRenderToTexture.h:161

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)