VVISF & VVGL
ISFPassTarget.hpp
1 #ifndef ISFPassTarget_hpp
2 #define ISFPassTarget_hpp
3 
4 #include "VVISF_Base.hpp"
5 
6 #include "exprtk/exprtk.hpp"
7 
8 
9 
10 
11 namespace VVISF
12 {
13 
14 
15 
16 
17 using namespace std;
18 
19 
20 
21 
22 class ISFDoc;
23 
24 
25 
26 
28 
32 class VVISF_EXPORT ISFPassTarget {
33  private:
34  string _name;
35  VVGL::GLBufferRef _buffer = nullptr;
36  ISFDoc *_parentDoc; // weak ref to the parent doc (ISFDoc*) that created and owns me
37 
38  mutex _targetLock;
39 
40  double _targetWidth = 1.0; // the target width for this pass. the expression evaluates to this value
41  string *_targetWidthString = nullptr;
42  exprtk::expression<double> *_targetWidthExpression = nullptr;
43  double _widthExpressionVar = 1.0; // the expression expects you to maintain static memory for the variables in its symbol table (the memory has to be retained as long as the expression is in use)
44 
45  double _targetHeight = 1.0; // the target height for this pass. the expression evaluates to this value
46  string *_targetHeightString = nullptr;
47  exprtk::expression<double> *_targetHeightExpression = nullptr;
48  double _heightExpressionVar = 1.0; // the expression expects you to maintain static memory for the variables in its symbol table (the memory has to be retained as long as the expression is in use)
49 
50  bool _floatFlag = false; // NO by default, if YES makes float texutres
51  VVGL::GLCachedUniRef _cachedUnis[4] = { nullptr, nullptr, nullptr, nullptr };
52  public:
53  // "class method" that creates a buffer ref
54  static ISFPassTargetRef Create(const string & inName, const ISFDoc * inParentDoc);
55  // clears the static tex-to-tex copier maintained by the class
56  static void cleanup();
57 
58  ISFPassTarget(const string & inName, const ISFDoc * inParentDoc);
59  ~ISFPassTarget();
60  ISFPassTarget(const ISFPassTarget & n) = default;
61  ISFPassTarget(ISFPassTarget && n) = default;
62  ISFPassTarget & operator=(ISFPassTarget & n) = delete;
63  ISFPassTarget & operator=(ISFPassTarget && n) = delete;
64 
66  void setTargetWidthString(const string & n);
68  const string targetWidthString();
70  void setTargetHeightString(const string & n);
72  const string targetHeightString();
74  void setFloatFlag(const bool & n);
76  bool floatFlag() const { return _floatFlag; }
78  void clearBuffer();
79 
80  bool targetSizeNeedsEval() const { return (_targetHeightString!=nullptr || _targetHeightString!=nullptr); }
81  void evalTargetSize(const VVGL::Size & inSize, map<string, double*> & inSymbols, const bool & inResize, const bool & inCreateNewBuffer);
82 
84  string & name() { return _name; }
86  VVGL::GLBufferRef & buffer() { return _buffer; }
88  void setBuffer(const VVGL::GLBufferRef & n) { _buffer=n; }
89 
91  VVGL::Size targetSize() { return { _targetWidth, _targetHeight }; }
92 
93  void cacheUniformLocations(const int & inPgmToCheck) { for (int i=0; i<4; ++i) _cachedUnis[i]->cacheTheLoc(inPgmToCheck); }
94  int32_t getUniformLocation(const int & inIndex) const { return (inIndex<0||inIndex>3) ? -1 : _cachedUnis[inIndex]->loc; }
95  void clearUniformLocations() { for (int i=0; i<4; ++i) _cachedUnis[i]->purgeCache(); }
96 
97  private:
98  void setTargetSize(const VVGL::Size & inSize, const bool & inResize=true, const bool & inCreateNewBuffer=true);
99 
100 };
101 
102 
103 
104 
105 }
106 
107 #endif /* ISFPassTarget_hpp */
STL namespace.
Definition: ISFAttr.hpp:12
Basic struct for 2D size.
Definition: VVGL_Geom.hpp:46
string & name()
Returns the receiver&#39;s name.
Definition: ISFPassTarget.hpp:84
VVGL::Size targetSize()
Returns the last-calculated target size for this pass.
Definition: ISFPassTarget.hpp:91
Describes an "ISF file"- requires an actual file on disk which is parsed. Capable of generating GLSL ...
Definition: ISFDoc.hpp:35
bool floatFlag() const
Gets the float flag for this pass- if true, this pass needs to render to a high-bitdepth texture...
Definition: ISFPassTarget.hpp:76
void setBuffer(const VVGL::GLBufferRef &n)
Sets the GLBuffer currently cached with this pass.
Definition: ISFPassTarget.hpp:88
Describes the target of a render pass for an ISF file, stores a number of properties and values speci...
Definition: ISFPassTarget.hpp:32
shared_ptr< ISFPassTarget > ISFPassTargetRef
ISFPassTargetRef is a shared pointer around an ISFPassTarget instance.
Definition: VVISF_Base.hpp:45
VVGL::GLBufferRef & buffer()
Returns the GLBuffer currently cached with this pass, or null.
Definition: ISFPassTarget.hpp:86