Commit 60d3caf0 authored by Janis Born's avatar Janis Born
Browse files

Added support for Multisampling to RenderBuffer

* Extended RenderBufferControl accordingly
parent feffe0fc
......@@ -24,6 +24,7 @@ public:
RenderBufferControl(void)
: mWidth(0),
mHeight(0),
mSamples(0),
mInternalFormat()
{}
virtual ~RenderBufferControl() {}
......@@ -33,6 +34,8 @@ public:
// ==================================================================================================== \/
public:
inline RenderBufferControl& size (GLsizei _width, GLsizei _height) { mWidth = _width; mHeight = _height; return *this; }
inline RenderBufferControl& size (GLsizei _width, GLsizei _height, GLsizei _samples) { mWidth = _width; mHeight = _height; mSamples = _samples; return *this; }
inline RenderBufferControl& samples (GLsizei _samples) { mSamples = _samples; return *this; }
inline RenderBufferControl& internalFormat (GLenum _internalFormat) { mInternalFormat = _internalFormat; return *this; }
// ===================================================================================================== \/
......@@ -42,7 +45,7 @@ public:
virtual SharedRenderBuffer create(void)
{
SharedRenderBuffer renderBuffer(new RenderBuffer(mInternalFormat));
renderBuffer->setSize(mWidth, mHeight);
renderBuffer->setSize(mWidth, mHeight, mSamples);
return renderBuffer;
}
......@@ -52,6 +55,7 @@ public:
protected:
GLsizei mWidth;
GLsizei mHeight;
GLsizei mSamples;
GLenum mInternalFormat;
};
......
......@@ -30,7 +30,8 @@ public:
: mObjectName(0),
mInternalFormat(_internalFormat),
mWidth(0),
mHeight(0)
mHeight(0),
mSamples(0)
{
glGenRenderbuffers(1, &mObjectName);
if (openGLCriticalErrorOccured() ) {
......@@ -55,6 +56,19 @@ public:
inline GLsizei getWidth (void) const { return mWidth; }
inline GLsizei getHeight (void) const { return mHeight; }
// ==================================================================================================== \/
// ============================================================================================ METHODS \/
// ==================================================================================================== \/
public:
//! Get the actual number of samples
inline int_t getSamples(void) const
{
glBindRenderbuffer(GL_RENDERBUFFER, mObjectName);
GLint samples;
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
return (int_t)samples;
}
// ===================================================================================================== \/
// ============================================================================================ WRAPPERS \/
// ===================================================================================================== \/
......@@ -68,12 +82,20 @@ public:
//! Set texture size and NULL data
inline void setSize(
GLsizei _width,
GLsizei _height)
GLsizei _height,
GLsizei _samples = 0)
{
mWidth = _width;
mHeight = _height;
mSamples = _samples;
glBindRenderbuffer(GL_RENDERBUFFER, mObjectName);
#if (ACGL_OPENGL_VERSION >= 30)
glRenderbufferStorageMultisample(GL_RENDERBUFFER, mSamples, mInternalFormat, mWidth, mHeight);
#else
glRenderbufferStorage(GL_RENDERBUFFER, mInternalFormat, mWidth, mHeight);
#endif // OpenGL >= 3.0
}
// =================================================================================================== \/
......@@ -84,6 +106,7 @@ protected:
GLenum mInternalFormat;
GLsizei mWidth;
GLsizei mHeight;
GLsizei mSamples;
};
ACGL_SHARED_TYPEDEF(RenderBuffer)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment