Allolib  1.0
C++ Components For Interactive Multimedia
al_EasyFBO.hpp
1 #ifndef __EASYFBO_HPP__
2 #define __EASYFBO_HPP__
3 
4 /* Allocore --
5  Multimedia / virtual environment application class library
6 
7  Copyright (C) 2009. AlloSphere Research Group, Media Arts & Technology, UCSB.
8  Copyright (C) 2012. The Regents of the University of California.
9  All rights reserved.
10 
11  Redistribution and use in source and binary forms, with or without
12  modification, are permitted provided that the following conditions are met:
13 
14  Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16 
17  Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20 
21  Neither the name of the University of California nor the names of its
22  contributors may be used to endorse or promote products derived from
23  this software without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  POSSIBILITY OF SUCH DAMAGE.
36 
37  File description:
38  FBO helper, wrapper around fbo, rbo, texture, pose, projectionMatrix..
39 
40  File author(s):
41  Tim Wood, 2015, fishuyo@gmail.com
42  Keehong Youn, 2017, younkeehong@gmail.com
43 */
44 
45 #include "al/graphics/al_FBO.hpp"
46 #include "al/graphics/al_Texture.hpp"
47 
48 namespace al {
49 
51  // color attachment texture config
52  int internal = GL_RGBA8;
53  unsigned int format = GL_RGBA;
54  unsigned int type = GL_UNSIGNED_BYTE;
55 
56  // format for depth attachment
57  unsigned int depth_format = GL_DEPTH_COMPONENT24;
58 
59  // wrapping option for color texture
60  int wrapS = GL_CLAMP_TO_EDGE;
61  int wrapT = GL_CLAMP_TO_EDGE;
62  int wrapR = GL_CLAMP_TO_EDGE;
63 
64  // filtering option for color texture
65  int filterMin = GL_NEAREST;
66  int filterMag = GL_NEAREST;
67 
68  bool mUseMipmap = false; // config mipmap levels for result texture?
69 
70  bool use_depth_texture = false; // if true, use texture with depth_format
71  // for depth recording.
72  // else use rbo for depth recording
73 };
74 
84 class EasyFBO {
85  int mWidth, mHeight;
86  Texture mTex;
87  Texture mDepthTex;
88  RBO mRbo;
89  FBO mFbo;
90 
91 public:
92  void init(int width, int height,
93  EasyFBOSetting const &setting = EasyFBOSetting{});
94  int width() { return mWidth; }
95  int height() { return mHeight; }
96  FBO &fbo() { return mFbo; }
97  Texture &tex() { return mTex; }
98  Texture &depthTex() { return mDepthTex; }
99  RBO &rbo() { return mRbo; }
100  void begin() { mFbo.bind(); }
101  void end() { mFbo.unbind(); }
102  void bind() { mFbo.bind(); }
103 };
104 
105 } // namespace al
106 
107 #endif
Encapsulates FBO, depth buffer, and texture.
Definition: al_EasyFBO.hpp:84
Frame buffer object class.
Definition: al_FBO.hpp:150
void bind()
Bind object (start rendering to attached objects)
void unbind()
Unbind object.
Render buffer object class.
Definition: al_FBO.hpp:83
Definition: al_App.hpp:23