Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
OffscreenRendering.cpp
1 #include <GLviewer/OffscreenRendering.hh>
2 #include <OpenGLFramework/Base/glfScreen.hh>
3 
4 #ifdef BIAS_HAVE_CLASS_OFFSCREENRENDERING
5 
6 using namespace BIAS;
7 using namespace std;
8 
10 {
11  initialized_ = false;
12 }
13 
15 {
16 }
17 
18 int OffscreenRendering::Init(int imgWidth, int imgHeight)
19 {
20  try {
21 
22  depthBuffer_.Create(GL_DEPTH_COMPONENT24, imgWidth, imgHeight);
23  colorBuffer_.Create(GL_RGBA8, imgWidth, imgHeight);
24 
25  fbo_.Create();
26  fbo_.AttachRenderbuffer(depthBuffer_, GL_DEPTH_ATTACHMENT_EXT);
27  fbo_.AttachRenderbuffer(colorBuffer_, GL_COLOR_ATTACHMENT0_EXT);
28  fbo_.CheckComplete();
29  fbo_.ClearDepthBuffer();
30  fbo_.ClearColorBuffer();
31 
32  // bind default render target
34 
35  } catch (glfException& e) {
36  BIASERR("Failed to create offscreen fbo: " << e.GetMessageString());
37  return -1;
38  }
39 
40  initialized_ = true;
41  return 0;
42 }
43 
45 {
46  return initialized_;
47 }
48 
50 {
51  if(!initialized_){
52  BIASWARN("OffscreenRendering has no valid framebuffer object, not initialised, returning NULL");
53  return NULL;
54  }
55  return &fbo_;
56 }
57 
58 #endif
bool IsInitialized() const
int Init(int imgWidth, int imgHeight)
Exception class used for run-time errors in the OpenGLFramework.
Definition: glfException.hh:79
const std::string & GetMessageString() const
Returns the description of the error including the file name and line number where the error occured...
static glfScreen & GetInstance()
Returns the global screen instance.
Definition: glfScreen.cpp:30
virtual void Bind() const
Makes this render target the currently used render target.
Definition: glfScreen.cpp:36
BIAS::glfFramebufferObject * GetFBO()