VR-Forces 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) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 #pragma once
6 
10 
11 
16 
17 #include <vrvMath/DtDataFormat.h>
18 
19 #include <vector>
20 #include <string>
21 
22 #include <tuple>
23 
24 #define DTGLRENDERTEXTURE_FBO_DEBUG 0
25 
26 #if DTGLRENDERTEXTURE_FBO_DEBUG
27 #include <tbb/atomic.h>
28 #endif
29 
30 namespace makVrv
31 {
32  class DtGlTexture;
33 
35  {
36  std::string myName;
37  int myWidth = 0;
38  int myHeight = 0;
39  int myNumSamples = 0;
40  int myLayers = 1;
41  bool myUseMultiView = false;
42  bool myInitColor = true;
43  };
44 
47  {
48  private:
51 
54 
56  DtGlRenderTexture& operator=(const DtGlRenderTexture&);
57 
58  public:
62 
64  virtual ~DtGlRenderTexture();
65 
67  virtual bool init(DtGlImageType colorFormat, unsigned int minFilter, unsigned int wrapMode);
68 
72  virtual bool initWithExternalTexture(unsigned int glColorTexId);
73 
75  virtual bool initDepth(DtGlImageType depthFormat = D32);
76 
79  virtual bool initDepth(unsigned int glDepthTexId);
80 
82  virtual void activateForDrawingInto(bool shouldClear = true, bool setViewport = true);
83 
86  virtual void copyFromFramebuffer(unsigned int srcFbo, unsigned int bufferBits);
87 
89  // isArray indicates the srcTexture is a Tex 2D array and srclayer is the layer of the array to copy from.
90  virtual void copyFromTexture(unsigned int srcTexture, bool isDepth, bool isArray = false, unsigned int srclayer = 0, unsigned int layerCount = 1);
91 
93  virtual void deactivateForDrawingInto();
94 
96  virtual void setFboTextureLayer(unsigned int layer);
97 
99  virtual void bindColorTexture(int unit);
100 
102  virtual void bindDepthTexture(int unit);
103 
105  virtual void unbindColorTexture(int unit);
106 
108  virtual void unbindDepthTexture(int unit);
109 
111  virtual int width() const;
112 
114  virtual int height() const;
115 
117  virtual int layers() const;
118 
120  virtual unsigned int colorId() const;
121 
123  virtual unsigned int depthId() const;
124 
126  virtual int numSamples() const;
127 
129  virtual bool useMultiView() const;
130 
132  virtual bool usingStencil() const;
133 
134  virtual void setDeleteFbosOnDestruction(bool val);
135  virtual bool deleteFbosOnDestruction(void) const;
136 
137  virtual DtGlFboAndContext fbo(void) const;
138  virtual DtGlFboAndContext multiSampleFbo(void) const;
139 
140  protected:
142  virtual bool hasColorTexture(void) const;
143 
145  virtual void attemptToDeleteFbo(DtGlFboAndContext& fbo);
146 
147  protected:
152 
154 
155  virtual void initFBO(const std::string& name);
156 
157  int myWidth;
158  int myHeight;
159  int myLayers;
160 
164 
165  DtGlTexture* myColorTexture = nullptr;
166 
167  DtGlTexture* myDepthTexture = nullptr;
168 
169  std::string myName;
170 
172 
173 #if DTGLRENDERTEXTURE_FBO_DEBUG
174  static tbb::atomic<int> theFBOCount;
175 #endif
176  };
177 
178 }
179 
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
bool myIsFrameBufferValid
Definition: DtGlRenderToTexture.h:162
int myNumSamples
Definition: DtGlRenderToTexture.h:39
DtGlFboAndContext myFboId
Definition: DtGlRenderToTexture.h:148
Dll export defines.
bool myInitColor
Definition: DtGlRenderToTexture.h:42
A helper classes for creating a RTT target, optionally including depth buffer.
Definition: DtGlRenderToTexture.h:46
DtGlFboAndContext myMultisampleFboId
Definition: DtGlRenderToTexture.h:149
int myLayers
Definition: DtGlRenderToTexture.h:159
std::tuple< unsigned int, const void * > DtGlFboAndContext
an fbo and the context it was created in
Definition: DtGlObjects.h:19
std::string myName
Definition: DtGlRenderToTexture.h:36
Encapsulates an opengl object and the context it was created in.
std::string myName
Definition: DtGlRenderToTexture.h:169
Definition: DtGlImageType.h:28
unsigned int myMultisampleColorBuffer
Definition: DtGlRenderToTexture.h:150
bool myHasDepth
Definition: DtGlRenderToTexture.h:161
bool myDeleteFbosOnDestruction
Definition: DtGlRenderToTexture.h:153
bool myUseMultiView
Definition: DtGlRenderToTexture.h:41
int myLayers
Definition: DtGlRenderToTexture.h:40
A helper class for creating and managing OpenGL Shader programs.
DtGlImageType
Definition: DtGlImageType.h:15
Enumerations for various types of texture/buffer formats.
Definition: DtGlRenderToTexture.h:34
bool myUseMultiView
Definition: DtGlRenderToTexture.h:163
int myWidth
Definition: DtGlRenderToTexture.h:37
#define DT_DLL_VRVGRAPHICSUTILS
Definition: vrvGraphicsUtils.h:18
int myNumSamples
Definition: DtGlRenderToTexture.h:171
int myWidth
Definition: DtGlRenderToTexture.h:157
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:151
int myHeight
Definition: DtGlRenderToTexture.h:38
int myHeight
Definition: DtGlRenderToTexture.h:158

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)