]> git.tdb.fi Git - libs/gl.git/blob - source/renderbuffer.cpp
Move Program::bind to its proper place
[libs/gl.git] / source / renderbuffer.cpp
1 #include "extension.h"
2 #include "ext_framebuffer_multisample.h"
3 #include "ext_framebuffer_object.h"
4 #include "renderbuffer.h"
5
6 namespace Msp {
7 namespace GL {
8
9 Renderbuffer::Renderbuffer()
10 {
11         static RequireExtension _ext("GL_EXT_framebuffer_object");
12
13         glGenRenderbuffersEXT(1, &id);
14 }
15
16 Renderbuffer::~Renderbuffer()
17 {
18         glDeleteRenderbuffersEXT(1, &id);
19 }
20
21 void Renderbuffer::storage(PixelFormat fmt, unsigned wd, unsigned ht)
22 {
23         Bind _bind(this, true);
24         width = wd;
25         height = ht;
26         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, fmt, width, height);
27 }
28
29 void Renderbuffer::storage_multisample(unsigned samples, PixelFormat fmt, unsigned wd, unsigned ht)
30 {
31         static RequireExtension _ext("GL_EXT_framebuffer_multisample");
32
33         Bind _bind(this, true);
34         width = wd;
35         height = ht;
36         glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, fmt, width, height);
37 }
38
39 void Renderbuffer::bind() const
40 {
41         if(set_current(this))
42                 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, id);
43 }
44
45 void Renderbuffer::unbind()
46 {
47         if(set_current(0))
48                 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
49 }
50
51 } // namespace GL
52 } // namespace Msp