Implements glRenderbufferMultisampleStorage
TRAC #12714
Signed-off-by: Nicolas Capens
Signed-off-by: Daniel Koch

Author:    Shannon Woods

git-svn-id: https://angleproject.googlecode.com/svn/trunk@390 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Framebuffer.cpp b/src/libGLESv2/Framebuffer.cpp
index 95c1913..d030379 100644
--- a/src/libGLESv2/Framebuffer.cpp
+++ b/src/libGLESv2/Framebuffer.cpp
@@ -272,6 +272,7 @@
 {
     int width = 0;
     int height = 0;
+    int samples = -1;
 
     if (mColorbufferType != GL_NONE)
     {
@@ -289,6 +290,7 @@
 
         width = colorbuffer->getWidth();
         height = colorbuffer->getHeight();
+        samples = colorbuffer->getSamples();
     }
     else
     {
@@ -321,6 +323,15 @@
         {
             return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
         }
+
+        if (samples == -1)
+        {
+            samples = depthbuffer->getSamples();
+        }
+        else if (samples != depthbuffer->getSamples())
+        {
+            return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE;
+        }
     }
 
     if (mStencilbufferType != GL_NONE)
@@ -346,6 +357,15 @@
         {
             return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
         }
+
+        if (samples == -1)
+        {
+            samples = stencilbuffer->getSamples();
+        }
+        else if (samples != stencilbuffer->getSamples())
+        {
+            return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE;
+        }
     }
 
     if (mDepthbufferType == GL_RENDERBUFFER && mStencilbufferType == GL_RENDERBUFFER)
@@ -374,6 +394,18 @@
     mStencilbufferPointer.set(depthStencilRenderbuffer);
 }
 
+int Framebuffer::getSamples()
+{
+    if (completeness() == GL_FRAMEBUFFER_COMPLETE)
+    {
+        return getColorbuffer()->getSamples();
+    }
+    else
+    {
+        return 0;
+    }
+}
+
 GLenum DefaultFramebuffer::completeness()
 {
     return GL_FRAMEBUFFER_COMPLETE;