X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Frenderbuffer.h;fp=source%2Fcore%2Frenderbuffer.h;h=afc6ed204298a7bbcfe02d6c95a87af83c6a1bba;hb=7aaec9a70b8d7733429bec043f8e33e02956f266;hp=0000000000000000000000000000000000000000;hpb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;p=libs%2Fgl.git diff --git a/source/core/renderbuffer.h b/source/core/renderbuffer.h new file mode 100644 index 00000000..afc6ed20 --- /dev/null +++ b/source/core/renderbuffer.h @@ -0,0 +1,55 @@ +#ifndef MSP_GL_RENDERBUFFER_H_ +#define MSP_GL_RENDERBUFFER_H_ + +#include "bindable.h" +#include "pixelformat.h" + +namespace Msp { +namespace GL { + +/** +A Renderbuffer contains a single renderable image. It can be attached to a +Framebuffer to provide a logical buffer that is required to render the scene +correctly but that is not needed as a texture later. Renderbuffers also +provide a capability for multisampling, which is not available in textures. + +Requires the GL_EXT_framebuffer_object extension. Multisample renderbuffers +additionally require the GL_EXT_framebuffer_multisample extension. +*/ +class Renderbuffer: public Bindable +{ +private: + unsigned id; + unsigned width; + unsigned height; + +public: + Renderbuffer(); + ~Renderbuffer(); + + unsigned get_id() const { return id; } + unsigned get_width() const { return width; } + unsigned get_height() const { return height; } + + /** Allocates storage for the renderbuffer. */ + void storage(PixelFormat fmt, unsigned wd, unsigned ht); + + /** Returns the maximum supported sample count for multisampling. If + multisampling is not supported, returns 0. */ + static unsigned get_max_samples(); + + /** Allocates multisample storage for the renderbuffer. All attachments in + a framebuffer must have the same number of samples. To transfer the + contents to a texture for furter processing, use the framebuffer blit + functions.*/ + void storage_multisample(unsigned samples, PixelFormat fmt, unsigned wd, unsigned ht); + + void bind() const; + + static void unbind(); +}; + +} // namespace GL +} // namespace Msp + +#endif