Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes
omni::visual::Framebuffer32F Class Reference

Framebuffer with 32-bit float pixel depth per channel. More...

#include <Framebuffer32F.h>

Public Member Functions

 Framebuffer32F ()
 
 Framebuffer32F (QSize const &)
 
 ~Framebuffer32F ()
 
int width () const
 Return width of framebuffer. More...
 
int height () const
 Return height of framebuffer. More...
 
QSize const & size () const
 Return size of framebuffer. More...
 
void initialize (QSize const &)
 
GLuint texture () const
 
void bind ()
 
void release ()
 
void destroy ()
 Free buffer from current context. More...
 

Private Attributes

QSize size_
 
GLuint fb_ = 0
 
GLuint colorTex_ = 0
 
GLuint depthRb_ = 0
 

Detailed Description

Framebuffer with 32-bit float pixel depth per channel.

Constructor & Destructor Documentation

omni::visual::Framebuffer32F::Framebuffer32F ( )
26  {
27 
28  }
omni::visual::Framebuffer32F::Framebuffer32F ( QSize const &  _size)
29  {
30  initialize(_size);
31  }
void initialize(QSize const &)
Definition: Framebuffer32F.cpp:37
omni::visual::Framebuffer32F::~Framebuffer32F ( )
33  {
34  destroy();
35  }
void destroy()
Free buffer from current context.
Definition: Framebuffer32F.cpp:94

Member Function Documentation

void omni::visual::Framebuffer32F::bind ( )
103  {
104  withCurrentContext([&](QOpenGLFunctions& _) {
105  _.glBindFramebuffer(GL_FRAMEBUFFER, fb_);
106  });
107  }
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
GLuint fb_
Definition: Framebuffer32F.h:56
void omni::visual::Framebuffer32F::destroy ( )

Free buffer from current context.

94  {
95  withCurrentContext([&](QOpenGLFunctions& _) {
96  if (colorTex_) _.glDeleteTextures(1, &colorTex_);
97  if (depthRb_) _.glDeleteRenderbuffers(1, &depthRb_);
98  if (fb_) _.glDeleteFramebuffers(1, &fb_);
99  size_ = QSize(0,0);
100  });
101  }
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
QSize size_
Definition: Framebuffer32F.h:55
GLuint colorTex_
Definition: Framebuffer32F.h:57
GLuint fb_
Definition: Framebuffer32F.h:56
GLuint depthRb_
Definition: Framebuffer32F.h:58
int omni::visual::Framebuffer32F::height ( ) const

Return height of framebuffer.

123  {
124 
125  return size().height();
126  }
QSize const & size() const
Return size of framebuffer.
Definition: Framebuffer32F.cpp:128
void omni::visual::Framebuffer32F::initialize ( QSize const &  _size)
37  {
38  if (_size == size()) return;
39 
40  withCurrentContext([&](QOpenGLFunctions& _) {
41  destroy();
42 
43  int _h = _size.height();
44  int _w = _size.width();
45  // RGBA32F 2D texture to render to
46  _.glGenTextures(1, &colorTex_);
47  _.glBindTexture(GL_TEXTURE_2D, colorTex_);
48  _.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
49  _.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
50  _.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
51  _.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
52 
53  // NULL means reserve texture memory, but texels are undefined
54  _.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F , _w, _h, 0, GL_RGBA,
55  GL_FLOAT, NULL);
56 
57  // -------------------------
58  _.glGenFramebuffers(1, &fb_);
59  bind();
60 
61  // Attach 2D texture to this FBO
62  _.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
63  GL_TEXTURE_2D, colorTex_, 0);
64 
65 
66  // -------------------------
67  _.glGenRenderbuffers(1, &depthRb_);
68  _.glBindRenderbuffer(GL_RENDERBUFFER, depthRb_);
69  _.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, _w,
70  _h);
71 
72  // -------------------------
73  // Attach depth buffer to FBO
74  _.glFramebufferRenderbuffer(GL_FRAMEBUFFER,
75  GL_DEPTH_ATTACHMENT,
76  GL_RENDERBUFFER, depthRb_);
77 
78  // -------------------------
79  // Does the GPU support current FBO configuration?
80  GLenum status;
81  status = _.glCheckFramebufferStatus(GL_FRAMEBUFFER);
82 
83  if (status != GL_FRAMEBUFFER_COMPLETE) {
84  destroy();
85  return;
86  }
87  size_ = QSize(_w,_h);
88  _.glBindTexture(GL_TEXTURE_2D,0);
89  _.glBindRenderbuffer(GL_RENDERBUFFER,0);
90  release();
91  });
92  }
void release()
Definition: Framebuffer32F.cpp:109
void destroy()
Free buffer from current context.
Definition: Framebuffer32F.cpp:94
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
QSize size_
Definition: Framebuffer32F.h:55
GLuint colorTex_
Definition: Framebuffer32F.h:57
GLuint fb_
Definition: Framebuffer32F.h:56
QSize const & size() const
Return size of framebuffer.
Definition: Framebuffer32F.cpp:128
GLuint depthRb_
Definition: Framebuffer32F.h:58
void bind()
Definition: Framebuffer32F.cpp:103
void omni::visual::Framebuffer32F::release ( )
109  {
110  withCurrentContext([&](QOpenGLFunctions& _) {
111  QOpenGLFramebufferObject::bindDefault();
112  });
113  }
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
QSize const & omni::visual::Framebuffer32F::size ( ) const

Return size of framebuffer.

128  {
129  return size_;
130  }
QSize size_
Definition: Framebuffer32F.h:55
GLuint omni::visual::Framebuffer32F::texture ( ) const
115  {
116  return colorTex_;
117  }
GLuint colorTex_
Definition: Framebuffer32F.h:57
int omni::visual::Framebuffer32F::width ( ) const

Return width of framebuffer.

119  {
120  return size().width();
121  }
QSize const & size() const
Return size of framebuffer.
Definition: Framebuffer32F.cpp:128

Field Documentation

GLuint omni::visual::Framebuffer32F::colorTex_ = 0
private
GLuint omni::visual::Framebuffer32F::depthRb_ = 0
private
GLuint omni::visual::Framebuffer32F::fb_ = 0
private
QSize omni::visual::Framebuffer32F::size_
private

The documentation for this class was generated from the following files: