]> git.tdb.fi Git - libs/gl.git/blob - source/renderbuffer.h
Have Object provide an identity matrix from get_matrix
[libs/gl.git] / source / renderbuffer.h
1 #ifndef MSP_GL_RENDERBUFFER_H_
2 #define MSP_GL_RENDERBUFFER_H_
3
4 #include "bindable.h"
5 #include "pixelformat.h"
6
7 namespace Msp {
8 namespace GL {
9
10 /**
11 A Renderbuffer contains a single renderable image.  It can be attached to a
12 Framebuffer to provide a logical buffer that is required to render the scene
13 correctly but that is not needed as a texture later.  Renderbuffers also
14 provide a capability for multisampling, which is not available in textures.
15
16 Requires the GL_EXT_framebuffer_object extension.  Multisample renderbuffers
17 additionally require the GL_EXT_framebuffer_multisample extension.
18 */
19 class Renderbuffer: public Bindable<Renderbuffer>
20 {
21 private:
22         unsigned id;
23         unsigned width;
24         unsigned height;
25
26 public:
27         Renderbuffer();
28         ~Renderbuffer();
29
30         unsigned get_id() const { return id; }
31         unsigned get_width() const { return width; }
32         unsigned get_height() const { return height; }
33
34 private:
35         static PixelFormat normalize_format(PixelFormat);
36
37 public:
38         /** Allocates storage for the renderbuffer. */
39         void storage(PixelFormat fmt, unsigned wd, unsigned ht);
40
41         /** Returns the maximum supported sample count for multisampling.  If
42         multisampling is not supported, returns 0. */
43         static unsigned get_max_samples();
44
45         /** Allocates multisample storage for the renderbuffer.  All attachments in
46         a framebuffer must have the same number of samples.  To transfer the
47         contents to a texture for furter processing, use the framebuffer blit
48         functions.*/
49         void storage_multisample(unsigned samples, PixelFormat fmt, unsigned wd, unsigned ht);
50
51         void bind() const;
52
53         static void unbind();
54 };
55
56 } // namespace GL
57 } // namespace Msp
58
59 #endif