]> git.tdb.fi Git - libs/gl.git/blob - source/renderbuffer.cpp
Adapt exporter to Blender 2.63
[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 w, unsigned h)
22 {
23         Bind _bind(this, true);
24         width = w;
25         height = h;
26         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, fmt, width, height);
27 }
28
29 void Renderbuffer::storage_multisample(unsigned samples, PixelFormat fmt, unsigned w, unsigned h)
30 {
31         static RequireExtension _ext("GL_EXT_framebuffer_multisample");
32
33         Bind _bind(this, true);
34         width = w;
35         height = h;
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