SLProject
4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLGLFrameBuffer.h
Go to the documentation of this file.
1
/**
2
* \file SLGLFrameBuffer.h
3
* \brief Wrapper class around OpenGL Frame Buffer Objects (FBO)
4
* \date April 2018
5
* \authors Carlos Arauz, Marcus Hudritsch
6
* \copyright http://opensource.org/licenses/GPL-3.0
7
* \remarks Please use clangformat to format the code. See more code style on
8
* https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9
*/
10
11
#ifndef SLGLFRAMEBUFFER_H
12
#define SLGLFRAMEBUFFER_H
13
14
#include <
SLGLTexture.h
>
15
16
//-----------------------------------------------------------------------------
17
/*!
18
The frame buffer class generates a frame buffer and a render buffer, with the
19
default size of 512x512, this can also in run time be changed.
20
*/
21
class
SLGLFrameBuffer
22
{
23
public
:
24
SLGLFrameBuffer
(
SLsizei
rboWidth
,
SLsizei
rboHeight
);
25
virtual
~SLGLFrameBuffer
() {
clear
(); }
26
27
//! Calls delete and clears data
28
void
clear
();
29
30
//! Deletes this buffers
31
void
deleteGL
();
32
33
//! Generates the framebuffer
34
void
generate
();
35
36
//! Binds the framebuffer and renderbuffer
37
void
bind
();
38
39
//! Unbinds the framebuffer and renderbuffer
40
void
unbind
();
41
42
//! Sets the size of the buffer storage
43
void
bindAndSetBufferStorage
(
SLsizei
width,
44
SLsizei
height);
45
46
//! Attaches texture image to framebuffer
47
void
attachTexture2D
(
SLenum
attachment,
48
SLenum
target,
49
SLGLTexture
* texture,
50
SLint
level = 0);
51
52
// Getters
53
SLuint
fboId
() {
return
this->
_fboId
; }
54
SLuint
rboId
() {
return
this->
_rboId
; }
55
SLsizei
rboWidth
() {
return
this->
_rboWidth
; }
56
SLsizei
rboHeight
() {
return
this->
_rboHeight
; }
57
58
// Some statistics
59
static
SLuint
totalBufferCount
;
//! static total no. of buffers in use
60
static
SLuint
totalBufferSize
;
//! static total size of all buffers in bytes
61
62
protected
:
63
SLuint
_fboId
;
//!< frame buffer identifier
64
SLuint
_prevFboId
;
//!< previously active frame buffer identifier
65
SLuint
_rboId
;
//!< render buffer identifier
66
SLuint
_sizeBytes
;
//!< size in bytes of this buffer
67
SLsizei
_rboWidth
;
//!< width of the render buffer
68
SLsizei
_rboHeight
;
//!< height of the render buffer
69
};
70
//-----------------------------------------------------------------------------
71
#endif
SLenum
unsigned int SLenum
Definition:
SL.h:176
SLuint
unsigned int SLuint
Definition:
SL.h:171
SLsizei
int SLsizei
Definition:
SL.h:172
SLint
int SLint
Definition:
SL.h:170
SLGLTexture.h
SLGLFrameBuffer
Definition:
SLGLFrameBuffer.h:22
SLGLFrameBuffer::fboId
SLuint fboId()
Definition:
SLGLFrameBuffer.h:53
SLGLFrameBuffer::_prevFboId
SLuint _prevFboId
previously active frame buffer identifier
Definition:
SLGLFrameBuffer.h:64
SLGLFrameBuffer::rboWidth
SLsizei rboWidth()
Definition:
SLGLFrameBuffer.h:55
SLGLFrameBuffer::attachTexture2D
void attachTexture2D(SLenum attachment, SLenum target, SLGLTexture *texture, SLint level=0)
Attaches texture image to framebuffer.
Definition:
SLGLFrameBuffer.cpp:116
SLGLFrameBuffer::_rboHeight
SLsizei _rboHeight
height of the render buffer
Definition:
SLGLFrameBuffer.h:68
SLGLFrameBuffer::clear
void clear()
Calls delete and clears data.
Definition:
SLGLFrameBuffer.cpp:29
SLGLFrameBuffer::bindAndSetBufferStorage
void bindAndSetBufferStorage(SLsizei width, SLsizei height)
Sets the size of the buffer storage.
Definition:
SLGLFrameBuffer.cpp:103
SLGLFrameBuffer::totalBufferCount
static SLuint totalBufferCount
Definition:
SLGLFrameBuffer.h:59
SLGLFrameBuffer::_fboId
SLuint _fboId
static total size of all buffers in bytes
Definition:
SLGLFrameBuffer.h:63
SLGLFrameBuffer::~SLGLFrameBuffer
virtual ~SLGLFrameBuffer()
Definition:
SLGLFrameBuffer.h:25
SLGLFrameBuffer::_rboWidth
SLsizei _rboWidth
width of the render buffer
Definition:
SLGLFrameBuffer.h:67
SLGLFrameBuffer::SLGLFrameBuffer
SLGLFrameBuffer(SLsizei rboWidth, SLsizei rboHeight)
Constructor.
Definition:
SLGLFrameBuffer.cpp:18
SLGLFrameBuffer::generate
void generate()
Generates the framebuffer.
Definition:
SLGLFrameBuffer.cpp:55
SLGLFrameBuffer::totalBufferSize
static SLuint totalBufferSize
static total no. of buffers in use
Definition:
SLGLFrameBuffer.h:60
SLGLFrameBuffer::unbind
void unbind()
Unbinds the framebuffer and renderbuffer.
Definition:
SLGLFrameBuffer.cpp:94
SLGLFrameBuffer::_rboId
SLuint _rboId
render buffer identifier
Definition:
SLGLFrameBuffer.h:65
SLGLFrameBuffer::_sizeBytes
SLuint _sizeBytes
size in bytes of this buffer
Definition:
SLGLFrameBuffer.h:66
SLGLFrameBuffer::rboId
SLuint rboId()
Definition:
SLGLFrameBuffer.h:54
SLGLFrameBuffer::bind
void bind()
Binds the framebuffer and renderbuffer.
Definition:
SLGLFrameBuffer.cpp:78
SLGLFrameBuffer::rboHeight
SLsizei rboHeight()
Definition:
SLGLFrameBuffer.h:56
SLGLFrameBuffer::deleteGL
void deleteGL()
Deletes this buffers.
Definition:
SLGLFrameBuffer.cpp:37
SLGLTexture
Texture object for OpenGL texturing.
Definition:
SLGLTexture.h:110
modules
sl
source
gl
SLGLFrameBuffer.h
Generated by
1.9.1