X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frenderbuffer.h;h=751374bd4a4258f70ca9afa74d1e16bf543b49a3;hp=040dad44bfdbaf896194d1c9bdf9adf579d0b768;hb=9d1fa012a23693768bbe287371e97751c03acc50;hpb=98c810b6d2256aa65986bbde12c38917678121bb diff --git a/source/renderbuffer.h b/source/renderbuffer.h index 040dad44..751374bd 100644 --- a/source/renderbuffer.h +++ b/source/renderbuffer.h @@ -1,15 +1,8 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_GL_RENDERBUFFER_H_ #define MSP_GL_RENDERBUFFER_H_ +#include "bindable.h" #include "pixelformat.h" -#include "types.h" namespace Msp { namespace GL { @@ -17,28 +10,47 @@ 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. +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. +Requires the GL_EXT_framebuffer_object extension. Multisample renderbuffers +additionally require the GL_EXT_framebuffer_multisample extension. */ -class Renderbuffer +class Renderbuffer: public Bindable { private: - uint id; - sizei width; - sizei height; + unsigned id; + unsigned width; + unsigned height; public: Renderbuffer(); ~Renderbuffer(); - uint get_id() const { return id; } - sizei get_width() const { return width; } - sizei get_height() const { return height; } + unsigned get_id() const { return id; } + unsigned get_width() const { return width; } + unsigned get_height() const { return height; } + +private: + static PixelFormat normalize_format(PixelFormat); + +public: + /** 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; - void storage(PixelFormat fmt, sizei width, sizei height); + static void unbind(); }; } // namespace GL