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: ...@@ -24,6 +24,7 @@ public:
RenderBufferControl(void) RenderBufferControl(void)
: mWidth(0), : mWidth(0),
mHeight(0), mHeight(0),
mSamples(0),
mInternalFormat() mInternalFormat()
{} {}
virtual ~RenderBufferControl() {} virtual ~RenderBufferControl() {}
...@@ -32,8 +33,10 @@ public: ...@@ -32,8 +33,10 @@ public:
// ============================================================================================ METHODS \/ // ============================================================================================ METHODS \/
// ==================================================================================================== \/ // ==================================================================================================== \/
public: public:
inline RenderBufferControl& size (GLsizei _width, GLsizei _height) { mWidth = _width; mHeight = _height; return *this; } inline RenderBufferControl& size (GLsizei _width, GLsizei _height) { mWidth = _width; mHeight = _height; return *this; }
inline RenderBufferControl& internalFormat (GLenum _internalFormat) { mInternalFormat = _internalFormat; 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; }
// ===================================================================================================== \/ // ===================================================================================================== \/
// ============================================================================================ OVERRIDE \/ // ============================================================================================ OVERRIDE \/
...@@ -42,7 +45,7 @@ public: ...@@ -42,7 +45,7 @@ public:
virtual SharedRenderBuffer create(void) virtual SharedRenderBuffer create(void)
{ {
SharedRenderBuffer renderBuffer(new RenderBuffer(mInternalFormat)); SharedRenderBuffer renderBuffer(new RenderBuffer(mInternalFormat));
renderBuffer->setSize(mWidth, mHeight); renderBuffer->setSize(mWidth, mHeight, mSamples);
return renderBuffer; return renderBuffer;
} }
...@@ -52,6 +55,7 @@ public: ...@@ -52,6 +55,7 @@ public:
protected: protected:
GLsizei mWidth; GLsizei mWidth;
GLsizei mHeight; GLsizei mHeight;
GLsizei mSamples;
GLenum mInternalFormat; GLenum mInternalFormat;
}; };
......
...@@ -30,7 +30,8 @@ public: ...@@ -30,7 +30,8 @@ public:
: mObjectName(0), : mObjectName(0),
mInternalFormat(_internalFormat), mInternalFormat(_internalFormat),
mWidth(0), mWidth(0),
mHeight(0) mHeight(0),
mSamples(0)
{ {
glGenRenderbuffers(1, &mObjectName); glGenRenderbuffers(1, &mObjectName);
if (openGLCriticalErrorOccured() ) { if (openGLCriticalErrorOccured() ) {
...@@ -55,10 +56,23 @@ public: ...@@ -55,10 +56,23 @@ public:
inline GLsizei getWidth (void) const { return mWidth; } inline GLsizei getWidth (void) const { return mWidth; }
inline GLsizei getHeight (void) const { return mHeight; } 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 \/ // ============================================================================================ WRAPPERS \/
// ===================================================================================================== \/ // ===================================================================================================== \/
public: public:
//! Bind the renderbuffer //! Bind the renderbuffer
inline void bind(void) const inline void bind(void) const
{ {
...@@ -68,12 +82,20 @@ public: ...@@ -68,12 +82,20 @@ public:
//! Set texture size and NULL data //! Set texture size and NULL data
inline void setSize( inline void setSize(
GLsizei _width, GLsizei _width,
GLsizei _height) GLsizei _height,
GLsizei _samples = 0)
{ {
mWidth = _width; mWidth = _width;
mHeight = _height; mHeight = _height;
mSamples = _samples;
glBindRenderbuffer(GL_RENDERBUFFER, mObjectName); glBindRenderbuffer(GL_RENDERBUFFER, mObjectName);
#if (ACGL_OPENGL_VERSION >= 30)
glRenderbufferStorageMultisample(GL_RENDERBUFFER, mSamples, mInternalFormat, mWidth, mHeight);
#else
glRenderbufferStorage(GL_RENDERBUFFER, mInternalFormat, mWidth, mHeight); glRenderbufferStorage(GL_RENDERBUFFER, mInternalFormat, mWidth, mHeight);
#endif // OpenGL >= 3.0
} }
// =================================================================================================== \/ // =================================================================================================== \/
...@@ -84,6 +106,7 @@ protected: ...@@ -84,6 +106,7 @@ protected:
GLenum mInternalFormat; GLenum mInternalFormat;
GLsizei mWidth; GLsizei mWidth;
GLsizei mHeight; GLsizei mHeight;
GLsizei mSamples;
}; };
ACGL_SHARED_TYPEDEF(RenderBuffer) 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