Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SimpleMultiPassFragmentShader.cpp
1 /*
2  * SimpleMultiPassFragmentShader.cpp
3  *
4  * Created on: Feb 26, 2009
5  * Author: africk
6  */
7 
8 #include "SimpleMultiPassFragmentShader.hh"
9 
10 using namespace std;
11 using namespace BIAS;
12 
13 SimpleMultiPassFragmentShader::SimpleMultiPassFragmentShader()
14 {
15  initialized_ = false;
16  createdGLContext_ = false;
17 }
18 
19 void
20 SimpleMultiPassFragmentShader::Init(bool createGLContext)
21 {
22  if (initialized_)
23  {
24  Destroy();
25  }
26  if (createGLContext)
27  {
28  // setup configuration
30  cfg.width = 1; // size does not matter!
31  cfg.height = 1; // size does not matter!
32  cfg.doubleBuffer = 0;
33  cfg.redSize = 8;
34  cfg.greenSize = 8;
35  cfg.blueSize = 8;
36  cfg.alphaSize = 8;
37  cfg.depthSize = 24;
38  cfg.stencilSize = 0;
39  pbuffer_.Init(cfg);
40  createdGLContext_ = true;
41  }
42  else
43  {
44  createdGLContext_ = false;
45  }
46 
47  framebuffer_setup_pool_.Create(texture_pool_);
48 
49  InitBatch_();
50  InitPrimitiveData_();
51  InitVertexTransformation_();
52 
53  initialized_ = true;
54 }
55 
56 void
57 SimpleMultiPassFragmentShader::Destroy()
58 {
59  shader_pool_.ClearAll();
60  framebuffer_setup_pool_.ClearAll();
61  texture_pool_.ClearAll();
62  input_textures_.clear();
63 
64  if (createdGLContext_)
65  {
66  pbuffer_.Destroy();
67  }
68  else
69  {
70  createdGLContext_ = false;
71  }
72 
73  depthTest_.clear();
74  postActions_.clear();
75 
76  initialized_ = false;
77 
78 }
79 
80 void
81 SimpleMultiPassFragmentShader::AddFragmentShaderFromFile(
82  const string& shader_path, const string& shader_name)
83 {
84  if (initialized_)
85  {
86  //the name of the program and shader are equal
87  try {
88  shader_pool_.AddShaderProgram(shader_name);
89  shader_pool_.AddFragmentShaderFromFile(shader_path, shader_name,
90  shader_name);
91 
92  shader_pool_.LinkAll();
93  } catch(glfException& e) {
94  BIASERR("error adding shader : "<<shader_name<<" from file : "<<shader_path<<endl);
95  throw e;
96  }
97  }
98  else
99  {
100  GLF_THROW_EXCEPTION("call Init first !" << endl);
101  }
102 }
103 
104 void
105 SimpleMultiPassFragmentShader::AddFragmentShader(const string& shader_source,
106  const string& shader_name)
107 {
108  if (initialized_)
109  {
110  //the name of the program and shader are equal
111  shader_pool_.AddShaderProgram(shader_name);
112  shader_pool_.AddFragmentShader(shader_source, shader_name, shader_name);
113  shader_pool_.LinkAll();
114  }
115  else
116  {
117  GLF_THROW_EXCEPTION("call Init first !" << endl);
118  }
119 }
120 
121 template<class StorageType>
122  void
123  SimpleMultiPassFragmentShader::SetShaderVariable(const string& shader_name,
124  const string& var_name, StorageType value)
125  {
126  string type = shader_pool_.GetUniformType(shader_name, var_name);
127  if (type.compare("sampler2D") == 0)
128  {
129  GLF_THROW_EXCEPTION("variable with name " << var_name << " is a texture (sampler2D), use SetOutputTextures / SetInputTextures to set textures " << endl);
130  }
131  else
132  {
133  shader_pool_.SetUniform(shader_name, var_name, value);
134  }
135  }
136 
137 void
138 SimpleMultiPassFragmentShader::LoadTexture(const ImageBase& image,
139  const string& texture_name, GLenum minFilter, GLenum magFilter,
140  GLenum wrapS, GLenum wrapT, GLenum internalFormat, int mipmap)
141 {
142  if (initialized_)
143  {
144  texture_pool_.UploadImage(texture_name, image, minFilter, magFilter,
145  wrapS, wrapT, internalFormat, mipmap);
146  }
147  else
148  {
149  GLF_THROW_EXCEPTION("call Init first !" << endl);
150  }
151 }
152 
153 void
154 SimpleMultiPassFragmentShader::CreateTexture(int width, int height,
155  GLenum internalFormat, const std::string& texture_name,
156  GLenum minFilter, GLenum magFilter,
157  GLenum wrapS, GLenum wrapT, int mipmap)
158 {
159 if (initialized_)
160  {
161  texture_pool_.Create(texture_name, width, height, internalFormat,
162  minFilter, magFilter, wrapS, wrapT, mipmap);
163  }
164  else
165  {
166  GLF_THROW_EXCEPTION("call Init first !" << endl);
167  }
168 }
169 
170 void
171 SimpleMultiPassFragmentShader::CreateTexture(int width, int height,
172  ImageBase::EStorageType storageType, ImageBase::EColorModel colorModel,
173  const string& texture_name, GLenum minFilter, GLenum magFilter,
174  GLenum wrapS, GLenum wrapT, int mipmap)
175 {
176  if (initialized_)
177  {
178  texture_pool_.Create(texture_name, width, height, storageType,
179  colorModel, minFilter, magFilter, wrapS, wrapT, mipmap);
180  }
181  else
182  {
183  GLF_THROW_EXCEPTION("call Init first !" << endl);
184  }
185 }
186 
187 void
188 SimpleMultiPassFragmentShader::SetInputTextures(const string& shader_name,
189  const vector<string>& samplers2D, const vector<string>& texture_names)
190 {
191  //TODO check if an output texture with this name exists
192  BIASASSERT(samplers2D.size() == texture_names.size());
193  if (initialized_)
194  {
195  shader_pool_.LinkAll();
196 
197  glfShaderProgram* programP = shader_pool_.GetShaderProgram(shader_name);
198  if (programP == NULL)
199  {
200  GLF_THROW_EXCEPTION("no shader with name: " << shader_name
201  << " exists." << endl);
202  }
203  else
204  {
205  vector<pair<glfTexture*, pair<string, string> > > textures(
206  samplers2D.size());
207  for (unsigned int i = 0; i < samplers2D.size(); i++)
208  {
209  glfTexture2D* textureP = texture_pool_[texture_names[i]];
210  if (textureP == NULL)
211  {
212  GLF_THROW_EXCEPTION("no texture with name: " << texture_names[i]
213  << " exists." << endl);
214  }
215  else
216  {
217  textures[i] = make_pair(textureP, make_pair(samplers2D[i],
218  texture_names[i]));
219  }
220  }
221  SetInputTextures_(shader_name, textures);
222  }
223  }
224  else
225  {
226  BIASERR("call Init first !" << endl);
227  BIASABORT;
228  }
229 }
230 
231 void
232 SimpleMultiPassFragmentShader::SetInputTextures(const std::string& shaderName, const std::string& uniformVarName,
233  const std::string& texturePoolName)
234 {
235  if (initialized_)
236  {
237  shader_pool_.LinkAll();
238 
239  glfShaderProgram* programP = shader_pool_.GetShaderProgram(shaderName);
240  if (programP == NULL)
241  {
242  GLF_THROW_EXCEPTION("no shader with name: " << shaderName
243  << " exists." << endl);
244  }
245  else
246  {
247  vector<pair<glfTexture*, pair<string, string> > > textures(1);
248 
249  glfTexture2D* textureP = texture_pool_[texturePoolName];
250  if (textureP == NULL)
251  {
252  GLF_THROW_EXCEPTION("no texture with name: " << texturePoolName
253  << " exists." << endl);
254  }
255  else
256  {
257  textures[0] = make_pair(textureP, make_pair(uniformVarName, texturePoolName));
258  }
259 
260  SetInputTextures_(shaderName, textures);
261  }
262  }
263  else
264  {
265  BIASERR("call Init first !" << endl);
266  BIASABORT;
267  }
268 }
269 
270 vector<pair<glfTexture*, pair<string, string> > >*
271 SimpleMultiPassFragmentShader::GetInputTextures_(const string& shader_name)
272 {
273  map<string, vector<pair<glfTexture*, pair<string, string> > > >::iterator
274  iter = input_textures_.find(shader_name);
275  if (iter != input_textures_.end())
276  {
277  return &(iter->second);
278  }
279  else
280  {
281  return NULL;
282  }
283 }
284 
285 void
286 SimpleMultiPassFragmentShader::ActivateInputTextures_(
287  const string& shader_name,
288  vector<pair<glfTexture*, pair<string, string> > >& textures)
289 {
290  for (int i = 0; i < (int) textures.size(); i++)
291  {
292  glActiveTexture(GL_TEXTURE0+i);
293  textures[i].first->Bind();
294  shader_pool_.SetUniform(shader_name, (textures[i].second).first, i);
295  }
296 }
297 
298 void
299 SimpleMultiPassFragmentShader::SetInputTextures_(const string& shader_name,
300  vector<pair<glfTexture*, pair<string, string> > >& textures)
301 {
302  map<string, vector<pair<glfTexture*, pair<string, string> > > >::iterator
303  iter = input_textures_.find(shader_name);
304  if (iter != input_textures_.end())
305  {
306  iter->second = textures;
307  }
308  else
309  {
310  input_textures_[shader_name] = textures;
311  }
312 }
313 
314 void
315 SimpleMultiPassFragmentShader::SetOutputTexture(const string& shader_name,
316  const string& colorTextureName, const string& depthTextureName)
317 {
318 
319  //TODO check if an input texture with this name exists
320  if (initialized_)
321  {
322  FramebufferSetup* setupP = framebuffer_setup_pool_.CreateSetup(
323  shader_name);
324  if (setupP == NULL)
325  {
326  GLF_THROW_EXCEPTION("no shader with name: " << shader_name
327  << " exists." << endl);
328  }
329  else
330  {
331  /*vector<string> texture_names(1);
332  texture_names[0] = texture_name;
333  framebuffer_setup_pool_.SetColorAttachments(shader_name, texture_names);*/
334  glfTexture2D* texture = texture_pool_[colorTextureName];
335  if(texture==NULL) {
336  GLF_THROW_EXCEPTION("cannot attach unexistant texture with name" <<colorTextureName<< endl);
337  }
338  setupP->ClearColorAttachments();
339  setupP->SetColorAttachment(texture);
340  if(depthTextureName.size()>0) {
341  texture = texture_pool_[depthTextureName];
342  if(texture==NULL) {
343  GLF_THROW_EXCEPTION("cannot attach unexistant texture with name" <<depthTextureName<< endl);
344  }
345  setupP->SetDepthAttachment(texture);
346  }
347  setupP->Execute();//why
348  }
349  }
350  else
351  {
352  BIASERR("call Init first !" << endl);
353  BIASABORT;
354  }
355 }
356 
357 void
358 SimpleMultiPassFragmentShader::SetOutputTextures(const string& shader_name,
359  const vector<string>& texture_names, const string& depthTextureName)
360 {
361 
362  //TODO check if an input texture with this name exists
363  if (initialized_)
364  {
365  FramebufferSetup* setupP = framebuffer_setup_pool_.CreateSetup(
366  shader_name);
367  if (setupP == NULL)
368  {
369  GLF_THROW_EXCEPTION("no shader with name: " << shader_name
370  << " exists." << endl);
371  }
372  else
373  {
374  // setupP->DisableColorClearance();
375  //setupP->DisableDepthClearance();
376  framebuffer_setup_pool_.SetColorAttachments(shader_name, texture_names);
377  if(depthTextureName.size()>0) {
378  glfTexture2D* texture = texture_pool_[depthTextureName];
379  if(texture==NULL) {
380  GLF_THROW_EXCEPTION("cannot attach unexistant texture with name" <<depthTextureName<< endl);
381  }
382  setupP->SetDepthAttachment(texture);
383  }
384  setupP->Execute();
385  }
386  }
387  else
388  {
389  BIASERR("call Init first !" << endl);
390  BIASABORT;
391  }
392 }
393 
394 void
395 SimpleMultiPassFragmentShader::CopyToImage(const string& texture_name,
396  ImageBase& image)
397 {
398  glfTexture2D* textureP = texture_pool_[texture_name];
399  if (textureP == NULL)
400  {
401  GLF_THROW_EXCEPTION("no texture with name: " << texture_name << " exists !" << endl);
402  }
403  else
404  {
405  textureP->CopyToImage(image, 0);
406  }
407 }
408 
409 void
410 SimpleMultiPassFragmentShader::CopyChannelsToImage(const string& texture_name,
411  GLenum format,
412  ImageBase& image)
413 {
414  glfTexture2D* textureP = texture_pool_[texture_name];
415  if (textureP == NULL)
416  {
417  GLF_THROW_EXCEPTION("no texture with name: " << texture_name << " exists !" << endl);
418  }
419  else
420  {
421  textureP->CopyChannelsToImage(image, format, 0);
422  }
423 }
424 
425 SimpleMultiPassFragmentShader::ActionGuard::ActionGuard() : action_(NULL)
426 {}
427 
428 SimpleMultiPassFragmentShader::ActionGuard::~ActionGuard()
429 {
430  delete action_;
431 }
432 
433 SimpleMultiPassFragmentShader::ActionGuard::ActionGuard(const BIAS::SMPFSActionInterface* action)
434 {
435  action_ = NULL;
436  this->operator = (action);
437 }
438 
439 
440 void
441 SimpleMultiPassFragmentShader::ActionGuard::operator =(const BIAS::SMPFSActionInterface* action)
442 {
443  delete action_;
444  if(action!=NULL)
445  action_ = action->Clone();
446  else
447  action_ = NULL;
448 }
449 
450 void
451 SimpleMultiPassFragmentShader::ActionGuard::Execute(const unsigned int& currentIter, const unsigned int& numIter)
452 {
453  if(action_==NULL) {
454  BIASERR("fatal implementation error!");
455  BIASABORT;
456  }
457  action_->Execute(currentIter, numIter);
458 }
459 
460  void
461 SimpleMultiPassFragmentShader::ActionGuard::Reset()
462  {
463  if(action_==NULL) {
464  BIASERR("fatal implementation error!");
465  BIASABORT;
466  }
467  action_->Reset();
468  }
469 
470 SimpleMultiPassFragmentShader::ActionGuard::ActionGuard(const SimpleMultiPassFragmentShader::ActionGuard& a)
471 {
472  action_=NULL;
473  this->operator = (a.action_);
474 }
475 
476 SimpleMultiPassFragmentShader::ActionGuard&
477 SimpleMultiPassFragmentShader::ActionGuard::operator=(const SimpleMultiPassFragmentShader::ActionGuard& a)
478 {
479  this->operator = (a.action_);
480  return (*this);
481 }
482 
483 void
484 SimpleMultiPassFragmentShader::SetPostAction(const std::string& shaderName, const SMPFSActionInterface& postAction)
485 {
486  postActions_[shaderName] = &postAction;
487 }
488 
489 void
491 {
492  if(postActions_.find(shaderName)!=postActions_.end())
493  postActions_[shaderName].Reset();
494 }
495 
496 
497 
498 void
500 {
501  map<std::string, ActionGuard>::iterator it = postActions_.find(shaderName);
502  if(it!=postActions_.end()) {
503  postActions_.erase(it);
504  }
505 }
506 
507 void
508 SimpleMultiPassFragmentShader::Execute(const vector<string>& shader_names,
509  unsigned int iter_number)
510 {
511 
512  glfFramebufferObject* fboP = framebuffer_setup_pool_.GetFBO();
513  //fboP->CheckComplete();
514  batch_.SetRenderTarget(fboP);
515 
516  for (unsigned int num = 0; num < iter_number; num++)
517  {
518  for (unsigned int i = 0; i < shader_names.size(); i++)
519  {
520 
521  glfShaderProgram* programP = shader_pool_.GetShaderProgram(
522  shader_names[i]);
523 
524  if (programP == NULL)
525  {
526  GLF_THROW_EXCEPTION("no program"<< shader_names[i] << " exists !" << endl);
527  }
528 
529  batch_.SetShaderProgram(programP);
530 
531  GLF_THROW_ON_OPENGL_ERROR;
532  vector<pair<glfTexture*, pair<string, string> > >* input_texturesP =
533  GetInputTextures_(shader_names[i]);
534 
535  if (input_texturesP != NULL)
536  {
537  ActivateInputTextures_(shader_names[i], *input_texturesP);
538  for (unsigned int j = 0; j < input_texturesP->size(); j++)
539  {
540  batch_.SetTexture(((*input_texturesP)[j]).first, j);
541  }
542  }
543 
544  FramebufferSetup* setupP = framebuffer_setup_pool_.GetSetup(
545  shader_names[i]);
546 
547  if (setupP == NULL)
548  {
549  GLF_THROW_EXCEPTION("no output textures for shader "<< shader_names[i] << " specified" << endl);
550  }
551  glfTexture2D* textureP = setupP->GetColorAttachment2D(0);
552 
553  if (textureP == NULL)
554  {
555  GLF_THROW_EXCEPTION("no output textures for shader "<< shader_names[i] << " specified" << endl);
556  }
557 
558 
559  framebuffer_setup_pool_.Activate(shader_names[i]);
560 
561 
562  viewport_.SetSize(textureP->GetWidth(), textureP->GetHeight());
563 
564 
565  ActivateDepthTest_(shader_names[i]);
566 
567 
568  batch_.Draw();
569 
570  map<string, ActionGuard>::iterator postAction = postActions_.find(shader_names[i]);
571  if(postAction != postActions_.end()) {
572  postAction->second.Execute(num, iter_number);
573  }
574  }
575  }
576 }
577 
578 void
580  float red, float green, float blue, float alpha)
581 {
582  FramebufferSetup* setupP = framebuffer_setup_pool_.GetSetup(shaderName);
583 
584  if (setupP == NULL) {
585  GLF_THROW_EXCEPTION("no output textures for shader "<< setupP << " spezified" << endl);
586  }
587  setupP->EnableColorClearance(red, green, blue, alpha);
588 }
589 
590 
591 void
592 SimpleMultiPassFragmentShader::EnableDepthClearance(const std::string& shaderName, float depth)
593 {
594  FramebufferSetup* setupP = framebuffer_setup_pool_.GetSetup(shaderName);
595 
596  if (setupP == NULL) {
597  GLF_THROW_EXCEPTION("no output textures for shader "<< setupP << " spezified" << endl);
598  }
599  setupP->EnableDepthClearance(depth);
600 }
601 
602 
603 void
605 {
606  FramebufferSetup* setupP = framebuffer_setup_pool_.GetSetup(shaderName);
607 
608  if (setupP == NULL) {
609  GLF_THROW_EXCEPTION("no output textures for shader "<< setupP << " spezified" << endl);
610  }
611  setupP->DisableColorClearance();
612 }
613 
614 
615 void
617 {
618  FramebufferSetup* setupP = framebuffer_setup_pool_.GetSetup(shaderName);
619 
620  if (setupP == NULL) {
621  GLF_THROW_EXCEPTION("no output textures for shader "<< setupP << " spezified" << endl);
622  }
623  setupP->DisableDepthClearance();
624 }
625 
626 void
627 SimpleMultiPassFragmentShader::SetDepthTest(const std::string& shaderName, const bool enabled, GLenum depthFunc)
628 {
629  depthTest_[shaderName].SetDepthTest(enabled);
630  depthTest_[shaderName].SetDepthFunc(depthFunc);
631 }
632 
633 void
634 SimpleMultiPassFragmentShader::ActivateDepthTest_(const std::string& shaderName)
635 {
636  map<string, glfDepthBufferMode>::const_iterator it = depthTest_.find(shaderName);
637  if(it!=depthTest_.end()) {
638  batch_.SetDepthBufferMode(&(it->second));
639  } else {
641  }
642 }
643 
644 
646 EvaluateOnlyPatches(const unsigned int referenceWidth,
647  const unsigned int referenceHeight,
648  const std::vector<unsigned int>& posX,
649  const std::vector<unsigned int>& posY,
650  const unsigned int hw)
651 {
652  Primitives:: AddRelativeQuadPatches(referenceWidth, referenceHeight,
653  posX, posY, hw,
654  vertices_, elements_, false);
655 }
656 
658 EvaluateOnlyLine(const unsigned int referenceWidth,
659  const unsigned int referenceHeight,
660  const unsigned int posY,
661  const unsigned int hw)
662 {
663  Primitives:: AddRelativeQuadPatchOverImageLine(referenceWidth, referenceHeight,
664  posY, hw,
665  vertices_, elements_, false);
666 }
667 
668 
669 //bool
670 //SimpleMultiPassFragmentShader::IsInputTexture_(const string& shader_name, const string& texture_name)
671 //{
672 // vector<string>* texNamesP = GetOutputTextureNames_()
673 //}
674 //bool
675 //SimpleMultiPassFragmentShader::IsOutputTexture_(const string& shader_name, const string& texture_name)
676 //{
677 //
678 //}
679 
680 
681 //#################################################
682 template BIASOpenGLFramework_EXPORT void
683 SimpleMultiPassFragmentShader::SetShaderVariable<int>(
684  const string& shader_program_name, const string& varName, int value);
685 template BIASOpenGLFramework_EXPORT void
686 SimpleMultiPassFragmentShader::SetShaderVariable<bool>(
687  const string& shader_program_name, const string& varName, bool value);
688 template BIASOpenGLFramework_EXPORT void
689 SimpleMultiPassFragmentShader::SetShaderVariable<float>(
690  const string& shader_program_name, const string& varName, float value);
691 template BIASOpenGLFramework_EXPORT void
692 SimpleMultiPassFragmentShader::SetShaderVariable<double>(
693  const string& shader_program_name, const string& varName, double value);
694 template BIASOpenGLFramework_EXPORT void
695 SimpleMultiPassFragmentShader::SetShaderVariable<Vector<float> >(
696  const string& shader_program_name, const string& varName,
697  Vector<float> value);
EColorModel
These are the most often used color models.
Definition: ImageBase.hh:127
void ResetPostAction(const std::string &shaderName)
void DisableDepthClearance(const std::string &shaderName)
Disables the clearence of the output when rendered into.
int GetWidth(int mipmap=0) const
Returns the width of a mipmap of the texture.
A 2D texture.
Definition: glfTexture2D.hh:40
void SetDepthBufferMode(const glfDepthBufferMode *depthBufferMode)
Sets the depth buffer mode.
Definition: glfBatch.cpp:106
void Draw()
Draws the batch.
Definition: glfBatch.cpp:218
Class allows to add actions different then rendering to the multipass shader execution.
void SetDepthAttachment(BIAS::glfTexture *texture)
static void AddRelativeQuadPatchOverImageLine(const unsigned int referenceWidth, const unsigned int referenceHeight, const unsigned int linePos, const unsigned int hw, BIAS::glfVertexBuffer &vb, BIAS::glfElementBuffer &eb, const bool flip)
Adds a patch suited for rendering with identity rendering parameters that exactly fits over an image ...
Definition: Primitives.cpp:39
void CopyToImage(ImageBase &image, int mipmap=0)
Copies the pixels of a mipmap of the texture to a BIAS::ImageBase.
Exception class used for run-time errors in the OpenGLFramework.
Definition: glfException.hh:79
A shader program composed of several shaders.
void ClearPostAction(const std::string &shaderName)
static const glfDepthBufferMode DEFAULT
The default depth buffer mode.
FramebufferSetup * GetSetup(const std::string &setupName)
Returns the pointer to a texture attached during a setup.
int GetHeight(int mipmap=0) const
Returns the height of a mipmap of the texture.
void Activate(const std::string &setupName)
void EnableColorClearance(float red=0.0f, float green=0.0f, float blue=0.0f, float alpha=0.0f)
void SetTexture(const glfTexture *texture, int textureUnit)
Sets the texture of a texture unit.
Definition: glfBatch.cpp:71
void DisableColorClearance(const std::string &shaderName)
Disables the clearence of the output when rendered into.
void SetRenderTarget(const glfRenderTarget *renderTarget)
Sets the render target.
Definition: glfBatch.cpp:59
void EvaluateOnlyLine(const unsigned int referenceWidth, const unsigned int referenceHeight, const unsigned int posY, const unsigned int hw)
Instead of processing a whole image, the fragment shaders are run only on a region around an image li...
void SetShaderProgram(const glfShaderProgram *shaderProgram)
Sets the shader program.
Definition: glfBatch.cpp:124
void SetColorAttachment(BIAS::glfTexture *texture, int AttachmentPoint=0)
glfFramebufferObject * GetFBO()
void SetSize(int width, int height)
Sets the size of the viewport in pixel coordinates.
Definition: glfViewport.cpp:51
Base class for textures.
Definition: glfTexture.hh:42
void EvaluateOnlyPatches(const unsigned int referenceWidth, const unsigned int referenceHeight, const std::vector< unsigned int > &posX, const std::vector< unsigned int > &posY, const unsigned int hw)
Instead ogf processing a whole image, the fragment shaders are run only on a set of symmetric patches...
void SetPostAction(const std::string &shaderName, const SMPFSActionInterface &postAction)
Sets an action that is performed after the respective shader has run.
void EnableDepthClearance(const std::string &shaderName, float depth=1.0f)
Enables the clearence of the output, each time when rendered into.
static void AddRelativeQuadPatches(const unsigned int referenceWidth, const unsigned int referenceHeight, const std::vector< unsigned int > &posX, const std::vector< unsigned int > &posY, const unsigned int hw, BIAS::glfVertexBuffer &vb, BIAS::glfElementBuffer &eb, const bool flip)
Calculates 2D patches in the image plane suited for rendering with identity rendering parameters...
Definition: Primitives.cpp:107
void EnableColorClearance(const std::string &shaderName, float red=0.0f, float green=0.0f, float blue=0.0f, float alpha=0.0f)
Enables the clearence of the output, each time when rendered into.
void Execute(const std::vector< std::string > &shader_names, unsigned int iter_number=1)
executes all shaders with names in shader_names vector in the given order (iter_number)-times ...
virtual SMPFSActionInterface * Clone() const =0
void SetDepthTest(const std::string &shaderName, const bool enabled, GLenum depthFunc)
Sets the depth test for the particular shader execution.
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
Configuration for a rendering context.
glfShaderProgram * GetShaderProgram(const std::string &shader_program_name)
returns the pointer to the shader program with the name shader_program_name if a program with this na...
void CopyChannelsToImage(ImageBase &image, GLenum format, int mipmap=0)
Copies the pixels of a mipmap of the texture to a BIAS::ImageBase and interprets the texture using th...
void EnableDepthClearance(float depth=1.0f)
glfTexture2D * GetColorAttachment2D(int AttachmentPoint)
Returns texture attached to AttachmentPoint if it is a glfTexture2D otherwise NULL.