VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtPostProcessor.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2014 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
14 #include <osg/Camera>
15 #include <osg/Texture>
16 #include <osg/Program>
17 #include <osg/Shader>
18 #include <osg/Texture2D>
19 #include <osg/Geode>
20 
21 #include <map>
22 
23 #include <boost/unordered_map.hpp>
24 
25 namespace makVrv
26 {
27  class DtChannel;
28 
39  {
40  public:
42 
46  DtPostProcessor(const std::string& postProcessType, bool handles2D);
47 
49  virtual ~DtPostProcessor();
50 
56  void setFragmentShaderSource(const char *source);
57 
63  void setFragmentShaderFile(const std::string& fileName);
64 
69  void setInputTexture(const DtChannel *channel, osg::Texture2D* texture);
70 
72  virtual void update(DtChannel *channel) = 0;
73 
77  osg::Texture2D* outputTexture();
78 
82  void setIsFinalEffect(const DtChannel *channel, bool final);
83 
86  osg::Camera* cameraForChannel(const DtChannel *channel);
87 
88  virtual void releaseGLObjects();
89 
91  bool hasEffect(std::string effect);
92 
94  bool effectEnabled(std::string effect);
95 
97  bool anyEffectEnabled();
98 
100 
101 
102 
103  virtual bool enableEffect(std::string effect);
104  virtual bool disableEffect(std::string effect);
106 
108  std::list<std::string> supportedEffects();
109 
112  bool handles2D() const;
113 
115  const std::string& type() const;
116 
118 
119  virtual void enablePostProcessor();
120  virtual void disablePostProcessor();
122 
124  bool postProcessorEnabled() const;
125 
126  protected:
127  void initialize();
128 
132  void addEffect(std::string effect);
133 
135  void setEnablePostProcessor(bool enabled);
136 
137  protected:
138 
139  osg::ref_ptr<osg::Texture2D> myOutputTexture, myInputTexture;
140  osg::ref_ptr<osg::Program> myProgram;
141  osg::ref_ptr<osg::Shader> myFragmentShader;
142  osg::ref_ptr<osg::Geode> myQuad;
143 
145 
146  typedef std::map<const DtChannel*, osg::ref_ptr<osg::Camera> > CameraMap;
148 
151 
152  // The category of this post effect ex. "dof", "wateronscreen"
153  std::string myType;
154 
155  // A list of sub-effects that can be enabled/disabled
156  typedef boost::unordered_map<std::string, bool> EffectMap;
157 
158  EffectMap myEffects; // ex. { {"rainsplash",true}, {"oceanspray",false} }
159  };
160 
165  {
166  public:
169 
172 
174  virtual ~DtPostProcessorCreator();
175 
176  protected:
178  virtual DtPostProcessor* create(DtDe& de, const std::string& postProcessorType) = 0;
179  };
180 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)