Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PlainPerPixelProcessing.hh
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #ifndef __PlainPerPixelProcessing_hh__
26 #define __PlainPerPixelProcessing_hh__
27 
28 #include <OpenGLFramework/Base/glfBatch.hh>
29 #include <OpenGLFramework/Base/glfTexture2D.hh>
30 
31 #include <vector>
32 #include <list>
33 
34 #include <bias_config.h> // for MIPOpenGLFramework_EXPORT
35 
36 namespace BIAS {
37  /** Class rendering quad and executing a fragment shader.
38  * \ingroup g_openglframework
39  * \attention Do not use any class function without valid context!
40  * \author bartczak
41  **/
42  class BIASOpenGLFramework_EXPORT PlainPerPixelProcessing {
43  public:
44  PlainPerPixelProcessing(bool flip = false);
45 
46  /** Adds textures in their respective index order and assigns them the
47  * default names img<index> in the shader programm.
48  * \attention Will relink the programm so all uniforms set
49  * directly on the program (GetProgram()) will have to be set again!
50  **/
51  void SetTextures(const std::vector<BIAS::glfTexture2D*>& inputTextures);
52  void SetTextures(std::list<BIAS::glfTexture2D*>& inputTextures);
53  void SetTexture(BIAS::glfTexture2D* inputTexture);
54  void ReleaseTextures();
55 
56  void SetSamplerNames(const std::vector<std::string>& samplerNames);
57 
58  // /** \deprecated use SwapGLObjects instead**/
59  // enum PingPongID {ping=0, pong=1};
60  // /** \deprecated use SwapGLObjects instead**/
61  // void SetPingPongTextures(const std::vector<BIAS::glfTexture2D*>& ping,
62  // const std::vector<BIAS::glfTexture2D*>& pong,
63  // const PlainPerPixelProcessing::PingPongID& activeID);
64  // /** \deprecated use SwapGLObjects instead**/
65  // void SetPingPongTextures(const std::vector<BIAS::glfTexture2D*>& ping,
66  // const std::vector<BIAS::glfTexture2D*>& pong,
67  // const std::vector<BIAS::glfTexture2D*>& unSwapped,
68  // const PlainPerPixelProcessing::PingPongID& activeID);
69  // /** \deprecated use SwapGLObjects instead**/
70  // void SetPingPongTextures(const std::vector<BIAS::glfTexture2D*>& ping,
71  // const std::vector<BIAS::glfTexture2D*>& pong,
72  // BIAS::glfTexture2D* unSwapped,
73  // const PlainPerPixelProcessing::PingPongID& activeID);
74 
75 
76  // /** Returns the currently set texture set;
77  // * \deprecated use SwapGLObjects instead
78  // **/
79  // PingPongID SwapPingPongTextures();
80  // /** \deprecated use SwapGLObjects instead**/
81  // PingPongID GetCurrentPingPongID() const;
82  // /** \deprecated use SwapGLObjects instead**/
83  // static inline PingPongID GetPingPongIDComplement(const PingPongID ppid) {
84  // if(ppid==ping) return pong;
85  // else return ping;
86  // }
87 
88  void SetOutputSize(unsigned int width, unsigned int height);
89  void SetRenderTarget(BIAS::glfRenderTarget* rt);
90 
91  void SetFragmentShaderFromFile(const std::string& fileName);
92  void SetFragmentShaderFromString(const std::string& source);
93 
94  /* void Link();
95  glfShaderProgram* GetProgram();*/
96  void SetUniform(const std::string& name, float val);
97  void SetUniform(const std::string& name, int val);
98 
99  glfDepthBufferMode& GetDepthBufferMode();
100 
101  void Execute();
102 
103  void SetFlip(bool flip=true);
104  protected:
107  unsigned int numInputTextures_;
109  void Init_();
110 
112  void InitBatch_();
113 
116  void InitPrimitiveData_();
117 
121  void InitVertexTransformation_();
122 
125  void InitShaders_();
126 
128  // void InitPerFragmentOperations_();
129 
132 
133  std::vector<std::string> samplerNames_;
134 
135  // bool usePingPongTextures_;
136  // bool isPing_;
137  // std::vector<BIAS::glfTexture2D*> PingPongTex_[2];
138 
140  std::map<std::string, float> uniformsFloat_;
141  std::map<std::string, int> uniformsInt_;
142 
143 
144  };
145 } //end of namespace
146 
147 
148 #endif
An element buffer contains vertex indices that form primitives.
std::map< std::string, int > uniformsInt_
Defines the usage of the depth buffer.
A 2D texture.
Definition: glfTexture2D.hh:40
A vertex buffer contains an array of vertices that can be used for rendering.
A batch represents a single Draw call including all parameters (render states).
Definition: glfBatch.hh:48
A shader program composed of several shaders.
A GLSL vertex shader or fragment shader, which must be linked in a shader program.
Definition: glfShader.hh:39
class for setting viewports
Definition: glfViewport.hh:37
PlainPerPixelProcessing & operator=(const PlainPerPixelProcessing &)
Class rendering quad and executing a fragment shader.
A 4x4 matrix in native OpenGL format.
Definition: glfMatrix.hh:41
PlainPerPixelProcessing(const PlainPerPixelProcessing &)
std::map< std::string, float > uniformsFloat_
Interface for render targets.
std::vector< std::string > samplerNames_