VR-Forces 4.3.1 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 setVertexShaderSource(const char *source);
64 
70  void setFragmentShaderFile(const std::string& fileName);
71 
77  void setVertexShaderFile(const std::string& fileName);
78 
79 
84  void setInputTexture(const DtChannel *channel, osg::Texture2D* texture);
85 
87  virtual void update(DtChannel *channel) = 0;
88 
92  osg::Texture2D* outputTexture();
93 
97  void setIsFinalEffect(const DtChannel *channel, bool final);
98 
101  osg::Camera* cameraForChannel(const DtChannel *channel);
102 
103  virtual void releaseGLObjects();
104 
106  bool hasEffect(std::string effect);
107 
109  bool effectEnabled(std::string effect);
110 
112  bool anyEffectEnabled();
113 
115 
116 
117 
118  virtual bool enableEffect(std::string effect);
119  virtual bool disableEffect(std::string effect);
121 
123  std::list<std::string> supportedEffects();
124 
127  bool handles2D() const;
128 
130  const std::string& type() const;
131 
133 
134  virtual void enablePostProcessor();
135  virtual void disablePostProcessor();
137 
139  bool postProcessorEnabled() const;
140 
141  protected:
142  void initialize();
143 
147  void addEffect(std::string effect);
148 
150  void setEnablePostProcessor(bool enabled);
151 
152  protected:
153 
154  osg::ref_ptr<osg::Texture2D> myOutputTexture, myInputTexture;
155  osg::ref_ptr<osg::Program> myProgram;
156  osg::ref_ptr<osg::Shader> myFragmentShader;
157  osg::ref_ptr<osg::Shader> myVertexShader;
158  osg::ref_ptr<osg::Geode> myQuad;
159 
161 
162  typedef std::map<const DtChannel*, osg::ref_ptr<osg::Camera> > CameraMap;
164 
167 
168  // The category of this post effect ex. "dof", "wateronscreen"
169  std::string myType;
170 
171  // A list of sub-effects that can be enabled/disabled
172  typedef boost::unordered_map<std::string, bool> EffectMap;
173 
174  EffectMap myEffects; // ex. { {"rainsplash",true}, {"oceanspray",false} }
175  };
176 
181  {
182  public:
185 
188 
190  virtual ~DtPostProcessorCreator();
191 
192  protected:
194  virtual DtPostProcessor* create(DtDe& de, const std::string& postProcessorType) = 0;
195  };
196 }

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)