render_target.hpp

Go to the documentation of this file.
00001 /*
00002     RenderStack  Support library for OpenGL 3+
00003     Copyright (C) 2010  Timo Suoranta
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2.1 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 */
00019 
00027 #ifndef RENDER_TARGET_HPP
00028 #define RENDER_TARGET_HPP
00029 
00030 #include "renderstack/rs.h"
00031 #include "renderstack/texture.hpp"
00032 #include <vector>
00033 
00034 namespace renderstack {
00035 
00036 enum attachment_type
00037 {
00038     attachment_renderbuffer,
00039     attachment_texture
00040 };
00041 
00042 class window;
00043 
00045 class framebuffer_attachment
00046 {
00047 public:
00048     framebuffer_attachment();
00049     framebuffer_attachment(int gl_attachment_point, enum attachment_type type)
00050     :   m_gl_attachment_point(gl_attachment_point)
00051     ,   m_type(type)
00052     {
00053     }
00054 
00055 public:
00056     int                         gl_attachment_point() const { return m_gl_attachment_point; }
00057     enum attachment_type        type() const { return m_type; }
00058     class texture               &texture() { return m_texture; }
00059     class texture const         &texture() const { return m_texture; }
00060     class renderbuffer          &renderbuffer() { return m_renderbuffer; }
00061     class renderbuffer const    &renderbuffer() const { return m_renderbuffer; }
00062 
00063 private:
00064     int                     m_gl_attachment_point;
00065     enum attachment_type    m_type;
00066     class renderbuffer      m_renderbuffer;
00067     class texture           m_texture;
00068 };
00069 
00071 class render_target
00072 {
00073 public:
00074     render_target();
00075     render_target(int width, int height);
00076     render_target(int width, int height, int gl_framebuffer_object);
00077 
00078     int             width           () const { return m_width; }
00079     int             height          () const { return m_height; }
00080     unsigned int    gl_framebuffer_object() const { return m_gl_framebuffer_object; }
00081 
00082     framebuffer_attachment &attach_texture(int gl_attachment, int gl_format);
00083     framebuffer_attachment &attach_renderbuffer(int gl_attachment, int gl_format, int sample_count);
00084 
00085     void resize(int width, int height);
00086     void begin () const;
00087     void end   () const;
00088     void blit  (render_target const &dst) const;
00089     void check () const;
00090     void debug () const;
00091 
00092 private:
00093     int                                 m_width;
00094     int                                 m_height;
00095     unsigned int                        m_gl_framebuffer_object;
00096     std::vector<framebuffer_attachment> m_attachments;
00097 };
00098 
00099 class default_render_target
00100 :   public render_target
00101 {
00102 public:
00103     default_render_target(int width, int height);
00104     default_render_target(class window const &window);
00105 };
00106 
00107 }
00108 
00109 #endif
00110 
Generated on Sun Apr 11 12:23:08 2010 for RenderStack by  doxygen 1.6.3