]> git.tdb.fi Git - libs/gl.git/blobdiff - source/renderbuffer.cpp
Remove the deprecated ProgramBuilder class
[libs/gl.git] / source / renderbuffer.cpp
index f146a915d64d27c213ef42b192068e4c8d14cd56..e86a97a50b63393d3220c02dd96e9d0e5037b85c 100644 (file)
@@ -1,8 +1,11 @@
 #include <msp/gl/extensions/arb_direct_state_access.h>
 #include <msp/gl/extensions/ext_framebuffer_multisample.h>
 #include <msp/gl/extensions/ext_framebuffer_object.h>
+#include "misc.h"
 #include "renderbuffer.h"
 
+using namespace std;
+
 namespace Msp {
 namespace GL {
 
@@ -21,17 +24,8 @@ Renderbuffer::~Renderbuffer()
        glDeleteRenderbuffers(1, &id);
 }
 
-PixelFormat Renderbuffer::normalize_format(PixelFormat fmt)
-{
-       if(!get_component_size(fmt) && OES_required_internalformat)
-               return get_default_sized_pixelformat(fmt);
-
-       return fmt;
-}
-
 void Renderbuffer::storage(PixelFormat fmt, unsigned wd, unsigned ht)
 {
-       fmt = normalize_format(fmt);
        require_pixelformat(fmt);
        width = wd;
        height = ht;
@@ -44,13 +38,21 @@ void Renderbuffer::storage(PixelFormat fmt, unsigned wd, unsigned ht)
        }
 }
 
+unsigned Renderbuffer::get_max_samples()
+{
+       static unsigned max_samples = (EXT_framebuffer_multisample ? get_i(GL_MAX_SAMPLES) : 0);
+       return max_samples;
+}
+
 void Renderbuffer::storage_multisample(unsigned samples, PixelFormat fmt, unsigned wd, unsigned ht)
 {
        if(!samples)
                return storage(fmt, wd, ht);
 
        static Require _req(EXT_framebuffer_multisample);
-       fmt = normalize_format(fmt);
+       if(samples>get_max_samples())
+               throw out_of_range("Renderbuffer::storage_multisample");
+
        require_pixelformat(fmt);
 
        width = wd;