25 #ifndef SIMPLE_MULTIPASS_FRAGMENT_SHADER_HH_
26 #define SIMPLE_MULTIPASS_FRAGMENT_SHADER_HH_
28 #include <OpenGLFramework/RenderingContext/glfPBuffer.hh>
29 #include <OpenGLFramework/Utils/ShaderProgramPool.hh>
30 #include <OpenGLFramework/Utils/Texture2DPool.hh>
31 #include <OpenGLFramework/Utils/FramebufferSetupPool.hh>
32 #include <OpenGLFramework/Base/glfBatch.hh>
33 #include <OpenGLFramework/Utils/Primitives.hh>
35 #include <bias_config.h>
51 virtual void Execute(
const unsigned int& currentIter,
const unsigned int& numIter) = 0;
99 Init(
bool createGLContext =
true);
111 AddFragmentShader(
const std::string& shader_source,
112 const std::string& shader_name);
118 AddFragmentShaderFromFile(
const std::string& shader_path,
119 const std::string& shader_name);
125 LoadTexture(
const ImageBase& image,
const std::string& texture_name,
126 GLenum minFilter = GL_NEAREST, GLenum magFilter = GL_NEAREST,
127 GLenum wrapS = GL_CLAMP, GLenum wrapT = GL_CLAMP,
128 GLenum internalFormat = 0,
int mipmap = 0);
138 GLenum minFilter = GL_NEAREST, GLenum magFilter = GL_NEAREST,
139 GLenum wrapS = GL_CLAMP, GLenum wrapT = GL_CLAMP,
int mipmap = 0);
141 CreateTexture(
int width,
int height, GLenum internalFormat,
const std::string& texture_name,
142 GLenum minFilter = GL_NEAREST, GLenum magFilter = GL_NEAREST,
143 GLenum wrapS = GL_CLAMP, GLenum wrapT = GL_CLAMP,
int mipmap = 0);
151 SetInputTextures(
const std::string& shader_name,
const std::vector<
152 std::string>& samplers2D,
153 const std::vector<std::string>& texture_names);
160 SetInputTextures(
const std::string& shaderName,
const std::string& uniformVarName,
161 const std::string& texturePoolName);
167 SetOutputTextures(
const std::string& shader_name,
168 const std::vector<std::string>& texture_names,
const std::string& depthTextureName =
"");
174 SetOutputTexture(
const std::string& shader_name,
175 const std::string& texture_name,
const std::string& depthTextureName =
"");
181 Execute(
const std::vector<std::string>& shader_names,
182 unsigned int iter_number = 1);
188 CopyToImage(
const std::string& texture_name,
ImageBase& image);
194 CopyChannelsToImage(
const std::string& texture_name, GLenum format,
ImageBase& image);
202 template<
class StorageType>
204 SetShaderVariable(
const std::string& shader_name,
205 const std::string& var_name, StorageType value);
213 void SetDepthTest(
const std::string& shaderName,
214 const bool enabled, GLenum depthFunc);
220 void EnableColorClearance(
const std::string& shaderName,
221 float red = 0.0f,
float green = 0.0f,
float blue = 0.0f,
float alpha = 0.0f);
227 void EnableDepthClearance(
const std::string& shaderName,
float depth = 1.0f);
233 void DisableColorClearance(
const std::string& shaderName);
239 void DisableDepthClearance(
const std::string& shaderName);
250 void ResetPostAction(
const std::string& shaderName);
251 void ClearPostAction(
const std::string& shaderName);
264 void EvaluateOnlyPatches(
const unsigned int referenceWidth,
265 const unsigned int referenceHeight,
266 const std::vector<unsigned int>& posX,
267 const std::vector<unsigned int>& posY,
268 const unsigned int hw);
279 void EvaluateOnlyLine(
const unsigned int referenceWidth,
280 const unsigned int referenceHeight,
281 const unsigned int posY,
282 const unsigned int hw);
286 std::vector<std::pair<glfTexture*, std::pair<std::string, std::string> > >*
287 GetInputTextures_(
const std::string& shader_name);
289 SetInputTextures_(
const std::string& shader_name, std::vector<std::pair<
290 glfTexture*, std::pair<std::string, std::string> > >& textures);
292 ActivateInputTextures_(
const std::string& shader_name,
293 std::vector<std::pair<
glfTexture*, std::pair<std::string,
294 std::string> > >& textures);
296 bool IsInputTexture_(
const std::string& texture_name);
297 bool IsOutputTexture_(
const std::string& texture_name);
299 std::vector<std::string>*
300 GetOutputTextureNames_(
const std::string& shader_name);
302 bool initialized_, createdGLContext_;
309 std::map<std::string, std::vector<std::pair<
glfTexture*, std::pair<
310 std::string, std::string> > > > input_textures_;
319 batch_.SetVertexBuffer(&vertices_);
320 batch_.SetViewport(&viewport_);
321 batch_.SetModelViewMatrix(&ModelViewMatrix_);
322 batch_.SetProjectionMatrix(&ProjectionMatrix_);
325 glfVertexBuffer vertices_;
326 glfElementBuffer elements_;
333 glfMatrix ModelViewMatrix_;
334 glfMatrix ProjectionMatrix_;
335 glfViewport viewport_;
337 InitVertexTransformation_()
339 ModelViewMatrix_.MakeIdentity();
340 ProjectionMatrix_.MakeIdentity();
344 std::map<std::string, glfDepthBufferMode> depthTest_;
345 void ActivateDepthTest_(
const std::string& shaderName);
351 ActionGuard(
const SMPFSActionInterface* action);
353 void operator=(
const SMPFSActionInterface* action);
354 void Execute(
const unsigned int& currentIter,
const unsigned int& numIter);
355 ActionGuard(
const ActionGuard& a);
356 ActionGuard& operator=(
const ActionGuard& a);
359 SMPFSActionInterface* action_;
361 std::map<std::string, ActionGuard> postActions_;
EColorModel
These are the most often used color models.
this class represents a set of shader programs one can add and remove shader programs to and from the...
Texture2DPool & GetTexture2DPool()
Class allows to add actions different then rendering to the multipass shader execution.
this class collects a number of shaders and textures uniquely identified by their names shader unifor...
A batch represents a single Draw call including all parameters (render states).
virtual ~SMPFSActionInterface()
Executes the post action.
Convenience container for managing 2D textures.
Class containing a framebuffer and a map of setups.
GLX pbuffer rendering context.
static void PlainQuad2DWithTexture2D(BIAS::glfVertexBuffer &vb, BIAS::glfElementBuffer &eb, bool flip=false)
Vertex Order: 3–2 | | 0–1 .
virtual void Reset()
Allows to bring the object to some initial position.
glfFramebufferObject * GetFBO()
FramebufferSetupPool & GetFramebufferSetupPool()
void SetElementBuffer(const glfElementBuffer *elementBuffer)
Sets the element buffer.
This is the base class for images in BIAS.