25 #include <Base/Image/ImageBase.hh>
26 #include "glfRenderbuffer.hh"
27 #include "glfException.hh"
28 #include "glfFormatDB.hh"
41 glDeleteRenderbuffersEXT(1, &id_);
47 if(!GLEW_EXT_framebuffer_object) {
48 GLF_THROW_EXCEPTION(
"GLEW_EXT_framebuffer_object:objects of this type can only be used"
49 " with EXT_framebuffer_object OpenGL extension");
53 glGenRenderbuffersEXT(1, &id_);
57 if(samples > 0 && !GLEW_EXT_framebuffer_multisample) {
58 BIASWARN(
"Multisampling is not supported.");
60 if(samples==0 || !GLEW_EXT_framebuffer_multisample) {
61 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
66 glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
67 if(maxSamples<samples) {
69 BIASWARN(
"requested number samples are not support, reducing to "<<samples<<
" samples");
71 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT,
77 GLF_THROW_ON_OPENGL_ERROR;
83 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, id_);
84 GLF_THROW_ON_OPENGL_ERROR;
96 glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_WIDTH_EXT, &width);
97 glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_HEIGHT_EXT, &height);
106 glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
107 GL_RENDERBUFFER_SAMPLES_EXT,
110 GLF_THROW_EXCEPTION(
"num samples must be zero to read out buffer.");
113 GLint internalFormat;
114 glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
115 GL_RENDERBUFFER_INTERNAL_FORMAT_EXT,
127 image.
Init(width, height, numChannels, storageType);
133 glPixelStorei(GL_PACK_ALIGNMENT, 1);
135 glReadPixels( 0, 0, width, height, format, type, image.
GetImageData());
136 GLF_THROW_ON_OPENGL_ERROR;
void Create(GLenum internalFormat, int width, int height, GLsizei samples=0)
Creates the renderbuffer with the given format and size.
unsigned int GetWidth() const
const void * GetImageData() const
void GetSize(GLint &width, GLint &height)
void CopyToImage(ImageBase &image)
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
unsigned int GetHeight() const
void Init(unsigned int width, unsigned int height, unsigned int nChannels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
Initialize image size and channels.
enum EStorageType GetStorageType() const
GLuint GetRenderbufferID() const
Returns the OpenGL id of the renderbuffer.
This is the base class for images in BIAS.
void Bind() const
Binds the renderbuffer.