render_target.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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