VVISF & VVGL
GLTexToTexCopier.hpp
1 #ifndef VVGL_GLTexToTexCopier_hpp
2 #define VVGL_GLTexToTexCopier_hpp
3 
4 #include "VVGL_Defines.hpp"
5 
6 #include "GLScene.hpp"
7 
8 #if defined(VVGL_SDK_MAC)
9 #import <TargetConditionals.h>
10 #endif
11 
12 
13 
14 
15 namespace VVGL
16 {
17 
18 
19 
20 
22 
26 class VVGL_EXPORT GLTexToTexCopier : public GLScene {
27  private:
28  bool _copyToIOSurface = false;
29  bool _copyAndResize = false;
30  Size _copySize = { 320., 240. };
31  SizingMode _copySizingMode = SizingMode_Stretch;
32 
33  //GLBufferRef geoXYVBO = nullptr;
34  //GLBufferRef geoSTVBO = nullptr;
35 
36 #if defined(VVGL_TARGETENV_GL3PLUS) || defined(VVGL_TARGETENV_GLES3)
37  GLBufferRef _vao = nullptr; // "owns" its own VBO, used to draw stuff if we're in GL 3
38 #elif defined(VVGL_TARGETENV_GLES)
39  GLBufferRef _vbo = nullptr; // geometry + tex coords, used to draw stuff if we're in GL ES
40 #endif
41  Quad<VertXYZST> _vboContents; // the VBO owned by '_vao' or the VBO '_vbo' is described by this var. we check this, and if there's a delta the vao has to make a new vbo/'_vbo' has to update its contents
42  GLCachedAttrib _inputXYZLoc = GLCachedAttrib("inXYZ"); // address of the attribute loc we pass geometry data to
43  GLCachedAttrib _inputSTLoc = GLCachedAttrib("inST"); // address of the attribute loc we pass tex coord data to
44  GLCachedUni _inputImageLoc = GLCachedUni("inputImage"); // address of the uniform loc we pass 2D texture IDs to
45  GLCachedUni _inputImageRectLoc = GLCachedUni("inputImageRect"); // address of the uniform loc we pass RECT texture IDs to
46  GLCachedUni _isRectTexLoc = GLCachedUni("isRectTex"); // address of the uniform we use to indicate whether the program should sample the 2D or RECT texture
47 
48  public:
52  GLTexToTexCopier(const GLContextRef & inCtx);
53 
54  virtual ~GLTexToTexCopier();
55 
56  virtual void prepareToBeDeleted();
57 
59  void setCopyToIOSurface(const bool & n);
61  bool copyToIOSurface();
63  void setCopyAndResize(const bool & n);
65  bool copyAndResize();
67  void setCopySize(const Size & n);
69  Size copySize();
71  void setCopySizingMode(const SizingMode & n);
73  SizingMode copySizingMode();
74 
76  GLBufferRef copyToNewBuffer(const GLBufferRef & n);
78  bool copyFromTo(const GLBufferRef & a, const GLBufferRef & b);
80  void sizeVariantCopy(const GLBufferRef & a, const GLBufferRef & b);
82  void ignoreSizeCopy(const GLBufferRef & a, const GLBufferRef & b);
83 
85  void copyBlackFrameTo(const GLBufferRef & n);
87  void copyOpaqueBlackFrameTo(const GLBufferRef & n);
89  void copyRedFrameTo(const GLBufferRef & n);
90 
91  protected:
92  virtual void _initialize();
93  void generalInit();
94 
95  private:
96  // acquire '_renderLock' and set current context before calling
97  void _drawBuffer(const GLBufferRef & inBufferRef, const Quad<VertXYZST> & inVertexStruct);
98 };
99 
100 
101 
102 
107 inline GLTexToTexCopierRef CreateGLTexToTexCopierRef() { return make_shared<GLTexToTexCopier>(); }
112 inline GLTexToTexCopierRef CreateGLTexToTexCopierRefUsing(const GLContextRef & inCtx) { return make_shared<GLTexToTexCopier>(inCtx); }
113 
114 
115 
116 
117 }
118 
119 #endif /* VVGL_GLTexToTexCopier_hpp */
the content is scaled to fit perfectly within the desired area- some stretching or squashing may occu...
Definition: VVGL_Geom.hpp:112
Definition: GLBuffer.hpp:13
SizingMode
Definition: VVGL_Geom.hpp:109
Subclass of GLCachedProperty that caches the location of a uniform variable in a GLSL program...
Definition: GLCachedProperty.hpp:89
Basic struct for 2D size.
Definition: VVGL_Geom.hpp:46
Subclass of GLCachedProperty that caches the location of an attribute in a GLSL program.
Definition: GLCachedProperty.hpp:66
Manages drawing in a GLContext, provides a simple interface for orthographic rendering, render-to-texture operations, and loading vert/geo/frag shaders.
Definition: GLScene.hpp:33
shared_ptr< GLTexToTexCopier > GLTexToTexCopierRef
A GLTexToTexCopierRef is a shared pointer around a GLTexToTexCopier.
Definition: VVGL_Base.hpp:54
Copies the contents of one texture-type GLBuffer to another texture-type GLBuffer, capable of basic resizing.
Definition: GLTexToTexCopier.hpp:26
GLTexToTexCopierRef CreateGLTexToTexCopierRef()
Creates and returns a GLTexToTexCopier. The scene makes a new GL context which shares the context of ...
Definition: GLTexToTexCopier.hpp:107
This struct defines a quad- it&#39;s a simple template which is expected to be passed one of the structs ...
Definition: VVGL_Geom.hpp:413
GLTexToTexCopierRef CreateGLTexToTexCopierRefUsing(const GLContextRef &inCtx)
Creates and returns a GLTexToTexCopier. The downloader uses the passed GL context to perform its GL o...
Definition: GLTexToTexCopier.hpp:112