KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gr_fbo_offscreen.h
Go to the documentation of this file.
1 /* $Id: gr_fbo_offscreen.h 18278 2014-11-25 01:42:10Z ksimek $ */
2 /* {{{=========================================================================== *
3  |
4  | Copyright (c) 1994-2011 by Kobus Barnard (author)
5  |
6  | Personal and educational use of this code is granted, provided that this
7  | header is kept intact, and that the authorship is not misrepresented, that
8  | its use is acknowledged in publications, and relevant papers are cited.
9  |
10  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
11  |
12  | Please note that the code in this file has not necessarily been adequately
13  | tested. Naturally, there is no guarantee of performance, support, or fitness
14  | for any particular task. Nonetheless, I am interested in hearing about
15  | problems that you encounter.
16  |
17  | Author: Kyle Simek
18  * =========================================================================== }}}*/
19 
21 #include <gr_cpp/gr_renderable.h>
22 
23 #include <boost/scoped_ptr.hpp>
24 
25 // vim: tabstop=4 shiftwidth=4 foldmethod=marker
26 #ifndef KJB_GR_FBO_OFFSCREEN_H
27 #define KJB_GR_FBO_OFFSCREEN_H
28 
29 #ifdef KJB_HAVE_OPENGL
30 #ifdef KJB_HAVE_GLEW
31 
32 namespace kjb
33 {
34 namespace opengl
35 {
36 
41 class Fbo_offscreen_buffer
42 {
43 public:
44  Fbo_offscreen_buffer(int width_in, int height_in, bool grayscale=true);
45 
52  void bind() const;
53 
54 
61  void unbind() const;
62 
64  void render(const Renderable& object);
65 
66 
67  void init_color_fbo();
68  void init_grayscale_fbo();
69 
70  int get_width() const { return width_; }
71  int get_height() const { return height_; }
72 
73  ::kjb::opengl::Framebuffer_object& get_fbo() { return *fbo_; }
74  ::kjb::opengl::Renderbuffer& get_depth_buffer() { return *depth_; }
75  ::kjb::opengl::Renderbuffer& get_color_buffer() { return *color_; }
76 private:
77 
78  int width_;
79  int height_;
80 
81  boost::scoped_ptr<kjb::opengl::Framebuffer_object> fbo_;
82  boost::scoped_ptr<kjb::opengl::Renderbuffer> depth_;
83  boost::scoped_ptr<kjb::opengl::Renderbuffer> color_;
84 
85  bool grayscale_;
86 
87  mutable GLint viewport_[4];
88  mutable bool viewport_saved_;
89 };
90 
91 } // namespace opengl
92 } // namespace kjb
93 
94 #endif /* KJB_HAVE_GLEW */
95 #endif /* KJB_HAVE_OPENGL */
96 #endif
Abstract class to render this object with GL.
void render(const Cuboid &c)
Definition: psi_weighted_box.cpp:56