Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DistortionRendering.cpp
1 #include <GLviewer/DistortionRendering.hh>
2 #include <GLviewer/GLProjectionParametersInterface.hh>
3 
4 #include <Base/Image/Image.hh>
5 #include <Base/Image/ImageIO.hh>
6 #include <Utils/GlewInitWrapper.hh>
7 
8 
9 #ifdef BIAS_HAVE_CLASS_DISTORTIONRENDERING
10 
11 using namespace BIAS;
12 using namespace BIAS;
13 using namespace std;
14 
15 template<class imgType>
16 void Dump(glfTexture2D& textureA, const std::string& fileNameA)
17 {
18  Image<imgType> imgA;
19  textureA.CopyToImage(imgA);
20  if(ImageIO::Save(fileNameA, imgA)!=0) {
21  BIASERR("could not dump to "<<fileNameA);
22  }
23 }
24 
25 
26 
28 NotDistortedImageWidth_(0),
29 NotDistortedImageHeight_(0)
30 {
31  loadDistortionShaders_ = true;
32  ClearColor_.Set(0., 0., 0., 0.);
33  UseStencilBuffer_ = true;
34  DistortionShadersInitialized_=false;
35  // AddDebugLevel(GLP_STATE_HIGH);
36 }
37 
38 
40 {
41  Reset();
42  glFinish();
43 }
44 
45 
46 void DistortionRendering::
47 SetQuadDataTexture_(float* data)
48 {
49 
50  /* GL_QUADS
51  * 3--2
52  * | |
53  * 0--1
54  */
55 
56  unsigned int i=0;
57  data[i++] = -1.0;
58  data[i++] = -1.0; //vertex
59  data[i++] = 0.0;
60  data[i++] = 1.0; //tex0
61 
62 
63  data[i++] = 1.0;
64  data[i++] = -1.0; //vertex
65  data[i++] = 1.0;
66  data[i++] = 1.0; //tex0
67 
68  data[i++] = 1.0;
69  data[i++] = 1.0; //vertex
70  data[i++] = 1.0;
71  data[i++] = 0.0; //tex0
72 
73 
74  data[i++] = -1.0;
75  data[i++] = 1.0; //vertex
76  data[i++] = 0.0;
77  data[i] = 0.0; //tex0
78  // BIASERR("endpoint "<<i);
79 }
80 
81 
82 
83 void DistortionRendering::
84 SetupPrimitiveRendering_()
85 {
86  glfVertexFormat vertexFormat;
87  vertexFormat.AddAttribute(glfVertexFormat::ATTRIB_POSITION, GL_FLOAT, 2);
88  vertexFormat.AddAttribute(glfVertexFormat::ATTRIB_TEXCOORD, 0, GL_FLOAT, 2);
89 
90 
91  float vertexData[16]; //4 vertices a 4 data entries
92  SetQuadDataTexture_(vertexData);
93  /*disable arraybuffer usage -
94  crashes in conjunction with open scene graph. (grauel 10/08) */
95  vertices_.Create(4, vertexFormat, vertexData, false );
96  distortionBatch_.SetVertexBuffer(&vertices_);
97 
98  distortionBatch_.SetPrimitiveType(GL_QUADS);
99 
100 
101  //index buffering for 1 quad with 4 vertices? overhead?
102  //anyway: i had to disable this due to incomapability with open scene graph!
103  //reactivated ischiller 11/09
104  /* GL_QUADS
105  * 3--2
106  * | |
107  * 0--1
108  */
109  GLuint quadIndices[4] = {0,1,2,3};
110  elements_.Create(4,
111  GL_UNSIGNED_INT,
112  GL_QUADS,
113  quadIndices);
114  distortionBatch_.SetElementBuffer(&elements_);
115  distortionBatch_.SetRange(0, 4);
116 }
117 
120 {
121 
122  // GlewInitWrapper::GetInstance()->Init();
123  if (!GLEW_EXT_framebuffer_object) {
124  BIASWARN("Required rendering state not supported. Distortion rendering disabled!");
125  return -1;
126  }
127 
128  BIASDOUT(GLP_ACTIVITY_MEDIUM, "[DistortionRendering ]: INIT ");
129 
130  //the diameters of the distorted image
131  unsigned int distortedImageWidth=0, distortedImageHeight=0;
132  projParams->GetImageSize(distortedImageWidth,
133  distortedImageHeight);
134 
135  BIASDOUT(GLP_ACTIVITY_MEDIUM, "Image Dim:"<<distortedImageWidth<<","<<distortedImageHeight);
136 
137  BIASASSERT(distortedImageWidth>0);
138  BIASASSERT(distortedImageHeight>0);
139 
140  //get the size of a not distorted image
141  projParams->GetIdealImageSize(NotDistortedImageWidth_,
142  NotDistortedImageHeight_);
143  BIASDOUT(GLP_ACTIVITY_MEDIUM, "Undistorted Image Dim:"
144  <<NotDistortedImageWidth_<<","<<NotDistortedImageHeight_);
145 
146  BIASASSERT(NotDistortedImageWidth_>0);
147  BIASASSERT(NotDistortedImageHeight_>0);
148 
149  GLenum depthformat = GL_DEPTH_COMPONENT;
150  if(UseStencilBuffer_) depthformat = GL_DEPTH24_STENCIL8_EXT;
151  //setup not distorted DEPTH texture
152  NotDistortedDepthTexture_.Create();
153  NotDistortedDepthTexture_.SetMagFilter(GL_NEAREST);
154  NotDistortedDepthTexture_.SetMinFilter(GL_NEAREST);
155  NotDistortedDepthTexture_.SetWrapT(GL_CLAMP);
156  NotDistortedDepthTexture_.SetWrapS(GL_CLAMP);
157  NotDistortedDepthTexture_.Allocate(NotDistortedImageWidth_,
158  NotDistortedImageHeight_,
159  depthformat);//
160 
161  //GL_EXT_PACKED_DEPTH_STENCIL
162  //DEPTH_STENCIL_EXT
163 
164  //setup not distorted COLOR texture
165  int alphaBits;
166  glGetIntegerv(GL_ALPHA_BITS, &alphaBits);
167  GLenum format = (alphaBits>0) ? GL_RGBA8 : GL_RGB8;
168  NotDistortedColorTexture_.Create();
169  NotDistortedColorTexture_.SetMagFilter(GL_LINEAR);
170  NotDistortedColorTexture_.SetMinFilter(GL_LINEAR_MIPMAP_LINEAR);
171 
172  NotDistortedColorTexture_.SetWrapT(GL_CLAMP);
173  NotDistortedColorTexture_.SetWrapS(GL_CLAMP);
174  NotDistortedColorTexture_.Allocate(NotDistortedImageWidth_,
175  NotDistortedImageHeight_,
176  format);
177  NotDistortedColorTexture_.GenerateMipMap();
178 
179 
180  DistortionRenderingFBO_.Create();
181  DistortionRenderingFBO_.AttachTexture(NotDistortedColorTexture_,
182  GL_COLOR_ATTACHMENT0_EXT);
183  DistortionRenderingFBO_.AttachTexture(NotDistortedDepthTexture_,
184  GL_DEPTH_ATTACHMENT_EXT);
185  if(UseStencilBuffer_)
186  {
187  //in this case depthtexture also contains an 8bit stencil channel
188  DistortionRenderingFBO_.AttachTexture(NotDistortedDepthTexture_,
189  GL_STENCIL_ATTACHMENT_EXT);
190  }
191 
192  DistortionRenderingFBO_.ClearColorBuffer(ClearColor_[0], ClearColor_[1],
193  ClearColor_[2], ClearColor_[3]);
194  DistortionRenderingFBO_.ClearDepthBuffer();
195 
196  try {
197  DistortionRenderingFBO_.CheckComplete();
198  } catch (glfException& e) {
199  BIASERR("FBO init error: " << e.GetMessageString());
200  return -1;
201  }
202  BIASDOUT(GLP_STATE_HIGH, "[DistortionRendering ]: DISTORTION FBO OK");
203 
204  KMatrix K, Kinv, idealK;
205  K = projParams->GetK();
206  Kinv = K.Invert();
207  projParams->GetIdealK(idealK);
208 
209  Image<float> lookupTexture(distortedImageWidth, distortedImageHeight, 3);
210  float* tex = lookupTexture.GetImageData();
211  unsigned int c=0;
212  HomgPoint2D source(0,0,1);
213 
214 
215  BIASDOUT(GLP_STATE_HIGH, "[DistortionRendering ]: ideal size "<<
216  NotDistortedImageWidth_<<"x"<<NotDistortedImageHeight_);
217 
218  for (unsigned int y=0; y<distortedImageHeight; y++) {
219  for (unsigned int x=0; x<distortedImageWidth; x++) {
220  source[0] = x;
221  source[1] = y;
222  //might have been changed by Undistort() in previous loop step
223  source[2] = 1;
224  projParams->Undistort(source);
225  source = idealK * Kinv * source;
226  source.Homogenize();
227 
228  source[0] /= NotDistortedImageWidth_;
229  source[1] /= NotDistortedImageHeight_;
230 
231  tex[c++] = source[0];
232  tex[c++] = 1.0-source[1];
233  tex[c++] = source[2];
234  }
235  }
236 
237  distortionMap_.Create();
238  distortionMap_.SetMinFilter(GL_NEAREST);
239  distortionMap_.SetMagFilter(GL_NEAREST);
240  distortionMap_.SetWrapT(GL_CLAMP);
241  distortionMap_.SetWrapS(GL_CLAMP);
242  distortionMap_.UploadImage(lookupTexture, GL_RGB32F_ARB);
243  // Dump<float>(distortionMap_, "lookup");
244 
245  if(loadDistortionShaders_) {
246  BIASDOUT(GLP_ACTIVITY_MEDIUM, "[DistortionRendering ]: loading shaders");
247 
248  std::string fragmentProgramCode_ =
249  "uniform sampler2D lookup;"
250  "uniform sampler2D color;"
251  "uniform sampler2D depth;"
252  ""
253  " void main() {"
254  ""
255  " vec2 indirect = texture2D(lookup, gl_TexCoord[0].st).st;"
256  " gl_FragColor = texture2D(color, indirect);"
257  //" gl_FragColor.rg = indirect; "
258  " gl_FragDepth = texture2D(depth, indirect).r;" //distort depth buffer
259  // "gl_FragColor.r = texture2D(depth, indirect).a;" //dbughack show depth in redchannel REMOVEME!
260  " }";
261 
262  try {
263  PerspectiveDistortionFragmentShader_.Create(GL_FRAGMENT_SHADER,
264  fragmentProgramCode_);
265  } catch (glfException& e) {
266  BIASERR("Fragment Shader Compile ERROR: \n" << e.GetMessageString());
267  return -1;
268  }
269  distortionProgram_.Create();
270  distortionProgram_.AttachShader(PerspectiveDistortionFragmentShader_);
271  try {
272  distortionProgram_.Link();
273  } catch (glfException& e) {
274  BIASERR("Fragment Shader Linking ERROR: \n" << e.GetMessageString());
275  return -1;
276  }
277  distortionProgram_.SetUniform("lookup", 0);
278  distortionProgram_.SetUniform("color", 1);
279  distortionProgram_.SetUniform("depth", 2);
280 
281  // why use the fixed pipeline??
282  // glUseProgram(0);
283  loadDistortionShaders_ = false;
284  }
285 
286  //set in BeginRendering_ before call to Init(...)
287  targetViewport_.SetOrigin(lastUsedGLViewport_[0],
288  lastUsedGLViewport_[1]);
289  targetViewport_.SetSize(lastUsedGLViewport_[2],
290  lastUsedGLViewport_[3]);
291 
292  distortionBatch_.SetTexture(&distortionMap_, 0);
293  distortionBatch_.SetTexture(&NotDistortedColorTexture_, 1);
294  distortionBatch_.SetTexture(&NotDistortedDepthTexture_, 2);
295  distortionBatch_.SetViewport(&targetViewport_);
296  distortionBatch_.SetDepthBufferMode(&depthTest_);
297  depthTest_.SetDepthFunc(GL_LEQUAL);
298  depthTest_.SetDepthTest(true);
299  distortionBatch_.SetRenderTarget(&globalRenderTarget_);
300  distortionBatch_.SetShaderProgram(&distortionProgram_);
301  //attaches quad
302  SetupPrimitiveRendering_();
303 
304  //used later
305  undistortedViewport_.SetOrigin(0,0);
306  undistortedViewport_.SetSize(NotDistortedImageWidth_,
307  NotDistortedImageHeight_);
308 
309  DistortionShadersInitialized_ = true;
310  BIASDOUT(GLP_ACTIVITY_BASIC, "Distortion-shaders should be initialized now");
311 
312  GLF_THROW_ON_OPENGL_ERROR;
313  return 0;
314 }
315 
318 {
319  DistortionShadersInitialized_ = false;
320 }
321 
324  bool useStencil)
325 {
326  glGetIntegerv(GL_VIEWPORT, lastUsedGLViewport_.GetData());
327 
328  if((useStencil)&&(!GLEW_EXT_packed_depth_stencil))
329  {
330  BIASWARNONCE("Required stencil buffer capabilites not supported." "Distortion rendering disabled!");
331  return -1;
332  }
333 
334  if ((!GLEW_EXT_framebuffer_object)) {
335  BIASWARNONCE("DistortionRendering is unsupported by your hardware");
336  return -1;
337  }
338 
339  BIASDOUT(GLP_ACTIVITY_HIGH, "[DistortionRendering]:**** DrawScenes ****");
340  UseStencilBuffer_ = useStencil;
341 
342  try {
343  if(!DistortionShadersInitialized_) {
344 
345  BIASDOUT(GLP_STATE_HIGH, "[DistortionRendering]: Distortion not Initialized");
346  try {
347  if(Init(projParams)!=0) {
348  BIASERR("error during perspective distortion intialization");
349  return -1;
350  } else {
351  BIASDOUT(GLP_STATE_HIGH,
352  "[DistortionRendering]: Distortion already Initialized");
353  }
354  } catch (glfException& e) {
355  BIASERR("ERROR in INIT of Distortion rendering: \n"
356  << e.GetMessageString());
357  throw e;
358  }
359  }
360 
361 
362  //setting appropriate viewport, this is bigger then the final rendering
363  //and the previouse one must be reinstalled afterwards
364  // glGetIntegerv(GL_VIEWPORT, lastUsedGLViewport_.GetData());
365 
366  // cerr<<"last used viewport ";
367  // for(unsigned int i=0;i<4;i++) {
368  // cerr<<lastUsedGLViewport_[i]<<" ";
369  // }
370  // cerr<<endl;
371 
372  // activate fbo pipes output to renderbuffer for depth and
373  // and color buffer into NotDistortedColorTexure_ object.
374  //DistortionRenderingFBO_.Install();//[0]->Bind();
375 
376  GLF_THROW_ON_OPENGL_ERROR;
377  DistortionRenderingFBO_.CheckComplete();
378 
379  try {
380  DistortionRenderingFBO_.Bind();
381  } catch (glfException& e) {
382  BIASERR("exception binding distortion FBO : \n" << e.GetMessageString());
383  throw e;
384  }
385 
386  undistortedViewport_.Bind();
387 
388  try {
389  DistortionRenderingFBO_.ClearColorBuffer(ClearColor_[0], ClearColor_[1],
390  ClearColor_[2], ClearColor_[3]);
391  } catch (glfException& e) {
392  BIASERR("clearing color of distortion FBO : \n" << e.GetMessageString());
393  throw e;
394  }
395 
396  try {
397  DistortionRenderingFBO_.ClearDepthBuffer();
398  } catch (glfException& e) {
399  BIASERR("clearing depth of distortion FBO : \n" << e.GetMessageString());
400  throw e;
401  }
402 
403  if(UseStencilBuffer_)
404  {
405  try {
406  DistortionRenderingFBO_.ClearStencilBuffer(); // here was a 0
407  } catch (glfException& e) {
408  BIASERR("clearing stencil of distortion FBO : \n"<<e.GetMessageString());
409  throw e;
410  }
411  }
412 
413  } catch (glfException& e) {
414  BIASERR("Preparing Distortion rendering: \n" << e.GetMessageString());
415  throw e;
416  }
417 
418  try {
419  DistortionRenderingFBO_.CheckComplete();
420  DistortionRenderingFBO_.Bind();
421  } catch (glfException& e) {
422  BIASERR("exception binding distortion FBO : \n" << e.GetMessageString());
423  throw e;
424  }
425 
426  undistortedViewport_.Bind();
427 
428  try {
429  DistortionRenderingFBO_.ClearColorBuffer(ClearColor_[0], ClearColor_[1],
430  ClearColor_[2], ClearColor_[3]);
431  } catch (glfException& e) {
432  BIASERR("clearing color of distortion FBO : \n" << e.GetMessageString());
433  throw e;
434  }
435 
436  try {
437  DistortionRenderingFBO_.ClearDepthBuffer();
438  } catch (glfException& e) {
439  BIASERR("clearing depth of distortion FBO : \n" << e.GetMessageString());
440  throw e;
441  }
442 
443  if(UseStencilBuffer_)
444  {
445  try {
446  DistortionRenderingFBO_.ClearStencilBuffer(); // here was a 0
447  } catch (glfException& e) {
448  BIASERR("clearing stencil of distortion FBO : \n"<<e.GetMessageString());
449  throw e;
450  }
451  }
452  return 0;
453 }
454 
456 {
457  undistortedViewport_.Bind();
458  DistortionRenderingFBO_.Bind();
459 }
460 
463 {
464  if (!GLEW_EXT_framebuffer_object) {
465  BIASERR("Distortion rendering was not possible!");
466  return -1;
467  }
468 
469  NotDistortedColorTexture_.GenerateMipMap();
470 
471  // activate render target
472  renderTarget->Bind();
473 
474  targetViewport_.SetOrigin(lastUsedGLViewport_[0],
475  lastUsedGLViewport_[1]);
476  targetViewport_.SetSize(lastUsedGLViewport_[2],
477  lastUsedGLViewport_[3]);
478 
479  //producing the final result in buffers:
480  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
481 
482  glPushAttrib(GL_ALL_ATTRIB_BITS);
483 
484  glMatrixMode(GL_MODELVIEW);
485  glPushMatrix();
486  glMatrixMode(GL_PROJECTION);
487  glPushMatrix();
488 
489  //will also set the viewport !
490  distortionBatch_.Draw();
491  // disable active textures
492  for (int i=2; i>=0; i--) {
493  glActiveTexture(GL_TEXTURE0+i);
494  glDisable(GL_TEXTURE_2D);
495  }
496 
497  //Batch::SetDefaultRenderStates();
498  glMatrixMode(GL_PROJECTION);
499  glPopMatrix();
500  glMatrixMode(GL_MODELVIEW);
501  glPopMatrix();
502 
503  glPopAttrib();
504 
505  glUseProgram(0);
506  glEnable(GL_DEPTH_TEST);
507 
508 
509  // for some strange reason, this viewport is not set by distortionBatch_ (??)
510  // glViewport(lastUsedGLViewport_[0],
511  // lastUsedGLViewport_[1],
512  // lastUsedGLViewport_[2],
513  // lastUsedGLViewport_[3]);
514 
515  GLF_THROW_ON_OPENGL_ERROR;
516 
517  return 0;
518 }
519 
521 DrawScenes(std::vector<SceneBase*>& scenes,
522  bool& FirstRenderingPassFinished,
523  bool& informScenesOfChange,
525  glfRenderTarget* renderTarget,
526  bool useStencil
527 )
528 {
529  if (BeginRendering(projParams,useStencil) != 0) {
530 
531  return -1;
532  }
533 
534  for (unsigned int i=0; i<scenes.size(); i++) {
535  if(informScenesOfChange)
536  scenes[i]->UpdateCameraRelatedState();
537  scenes[i]->Render();
538  }
539  FirstRenderingPassFinished = false;
540  informScenesOfChange = false;
541 
542  if(useStencil)
543  { //set all pixels in the offscreen undistorted zbuffer for which the
544  //stencil test passes to zfar
545  //enable stencil test
546  glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_TEXTURE_BIT |GL_STENCIL_BUFFER_BIT);
547  glEnable(GL_STENCIL_TEST);
548  glEnable(GL_DEPTH_TEST);
549  glDepthMask(GL_TRUE);
550  glStencilFunc(GL_EQUAL, 1, (GLuint)(~0));
551  glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
552  glMatrixMode(GL_MODELVIEW);
553  glPushMatrix();
554  glLoadIdentity();
555  glMatrixMode(GL_PROJECTION);
556  glPushMatrix();
557  glLoadIdentity();
558  glDepthFunc(GL_ALWAYS); //<-------- overwrite everything not stenciled!
559  glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
560  glColorMask(0,0,0,1); //clear alpha channel or background image blending will use alpha channel
561  float s=1;
562  glDisable(GL_TEXTURE_2D);
563  glBegin(GL_QUADS);
564  glColor4f(0,1,1,0); //clear alpha channel with 0 rgb can be anything
565  glVertex3f(-s, s, -s);
566  glVertex3f(-s, -s, -s);
567  glVertex3f(s, -s, -s);
568  glVertex3f(s, s, -s);
569  glEnd();
570  glColorMask(1,1,1,1);
571  glDepthFunc(GL_LESS);
572  glMatrixMode(GL_PROJECTION);
573  glPopMatrix();
574  glMatrixMode(GL_MODELVIEW);
575  glPopMatrix();
576  glPopAttrib();
577  //------------------------
578  glDisable(GL_STENCIL_TEST);
579  }
580 
581  //now render a quad with the distoted fbo.textures on it.
582  //the main depth buffer is filled with the depth values from the fbo
583  if (EndRendering(renderTarget) != 0) {
584  return -1;
585  }
586  return 0;
587 }
588 
589 
590 #endif // BIAS_HAVE_CLASS_DISTORTIONRENDERING
void SetVertexBuffer(const glfVertexBuffer *vertexBuffer)
Sets the vertex buffer.
Definition: glfBatch.cpp:129
void Allocate(int width, int height, GLenum internalFormat, int mipmap=0)
Creates a texture with undefined content.
void AttachTexture(const glfTexture &texture, GLenum attachmentPoint, int attachedMipMapLevel=0, int zSlice=0, GLenum cubeMapSide=0)
Attaches a texture to an attachment point which can be.
void Create()
Creates the shader program.
void SetUniform(const std::string &varName, float value)
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
void SetPrimitiveType(GLenum primitiveType)
Sets the primitive type to rendering.
Definition: glfBatch.cpp:139
void SetDepthFunc(GLenum depthFunc)
Sets the depth buffer comparison function.
A 2D texture.
Definition: glfTexture2D.hh:40
virtual void Bind() const
Binds the viewport.
Definition: glfViewport.cpp:57
void Link()
Links the attached shaders.
void AttachShader(const glfShader &shader)
Attaches a shader to the program.
void Create()
Creates the texture but does not upload any data yet.
Definition: glfTexture.cpp:80
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
void SetDepthBufferMode(const glfDepthBufferMode *depthBufferMode)
Sets the depth buffer mode.
Definition: glfBatch.cpp:106
void Create(GLenum type)
Creates the shader without the GLSL source code, use other Create() methods to upload source afterwar...
Definition: glfShader.cpp:55
void Draw()
Draws the batch.
Definition: glfBatch.cpp:218
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
Definition: HomgPoint2D.hh:215
int Init(BIAS::ProjectionParametersPerspective *projParams)
void SetWrapS(GLenum wrapS)
Sets the wrapping mode for the 1st texture coordinate.
Definition: glfTexture.cpp:105
void Set(const T &scalar)
set all elements to a scalat value
Definition: Vector4.hh:421
int DrawScenes(std::vector< SceneBase * > &scenes, bool &FirstRenderingPassFinished, bool &informScenesOfChange, BIAS::ProjectionParametersPerspective *projParams, BIAS::glfRenderTarget *renderTarget, bool useStencil=false)
void UploadImage(const BIAS::ImageBase &image, GLenum internalFormat=0, int mipmap=0)
Uploads a BIAS::Image to a mipmap of the texture.
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
int BeginRendering(BIAS::ProjectionParametersPerspective *projParams, bool useStencil=false)
void Create(int numVertices, const glfVertexFormat &format, const void *data=NULL, bool useBufferIfPossible=true)
Creates the vertex buffer for the given number of vertices and vertex format.
const std::string & GetMessageString() const
Returns the description of the error including the file name and line number where the error occured...
void SetMinFilter(GLenum minFilter)
Sets the minifying function.
Definition: glfTexture.cpp:89
void SetViewport(const glfViewport *viewport)
Sets the viewport.
Definition: glfBatch.cpp:65
int EndRendering(BIAS::glfRenderTarget *renderTarget)
void CheckComplete() const
Checks whether the framebuffer object is supported in its current state.
virtual void Bind() const =0
Makes this render target the currently used render target.
void AddAttribute(Attribute attrib, int index, GLenum type, int size, bool normalized=false)
Adds a vertex attribute to the format.
void SetTexture(const glfTexture *texture, int textureUnit)
Sets the texture of a texture unit.
Definition: glfBatch.cpp:71
void SetWrapT(GLenum wrapT)
Sets the wrapping mode for the 2nd texture coordinate.
Definition: glfTexture.cpp:113
The image template class for specific storage types.
Definition: Image.hh:78
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
Definition: ImageIO.cpp:725
void SetRenderTarget(const glfRenderTarget *renderTarget)
Sets the render target.
Definition: glfBatch.cpp:59
void ClearDepthBuffer(float depth=1.0f)
Clears the depth buffer of the render target with the given value.
virtual int GetImageSize(unsigned int &Width, unsigned int &Height) const
Obtain image dimensions.
void Create(int numIndices, GLenum type, GLenum mode, const void *indices)
Creates the element buffer for the given number of indices.
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
Definition: Image.hh:137
virtual bool Undistort(BIAS::HomgPoint2D &point2d) const
Using the Matlab camera calibration toolbox parameters for an undistortion of distorted coordinates...
void SetShaderProgram(const glfShaderProgram *shaderProgram)
Sets the shader program.
Definition: glfBatch.cpp:124
const T * GetData() const
get the data pointer the member function itself is const (before {..}) because it doesn&#39;t change the...
Definition: Vector4.hh:177
A vertex format describes the attributes of a vertex.
void SetDepthTest(bool enable)
Sets whether to use depth buffer tests.
void SetSize(int width, int height)
Sets the size of the viewport in pixel coordinates.
Definition: glfViewport.cpp:51
void GenerateMipMap()
Explicitly generates the mipmaps of the texture in hardware.
Definition: glfTexture.cpp:194
virtual void Bind() const
Makes this render target the currently used render target.
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
void SetOrigin(int x, int y)
Sets the position of the upper-left corner of the viewport in pixel coordinates.
Definition: glfViewport.cpp:45
void SetElementBuffer(const glfElementBuffer *elementBuffer)
Sets the element buffer.
Definition: glfBatch.cpp:134
void ClearStencilBuffer(int s=0)
Clears the stencil buffer of the render target with the given value.
void ClearColorBuffer(float red=0.0f, float green=0.0f, float blue=0.0f, float alpha=0.0f)
Clears the color buffer of the render target with the given color.
void GetIdealImageSize(unsigned int &width, unsigned int &height) const
KMatrix Invert() const
returns analyticaly inverted matrix
Definition: KMatrix.cpp:31
Interface for render targets.
void SetRange(int first, int count)
Sets the range of vertices to be rendered if no element buffer is set, or the range of vertex indices...
Definition: glfBatch.cpp:144
void Create()
Creates the framebuffer object.
void SetMagFilter(GLenum magFilter)
Sets the magnification function.
Definition: glfTexture.cpp:97