]> git.tdb.fi Git - libs/gl.git/commitdiff
Also convert RenderBuffer formats to sized variants if possible
authorMikko Rasa <tdb@tdb.fi>
Sat, 5 Nov 2016 15:12:20 +0000 (17:12 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 5 Nov 2016 15:12:20 +0000 (17:12 +0200)
source/renderbuffer.cpp
source/renderbuffer.h

index 17d36846e696cdccb36d4b5a28e14d2e301b6025..5098362261e45743d396c81ea9bc5b9878d3c9ae 100644 (file)
@@ -21,8 +21,20 @@ Renderbuffer::~Renderbuffer()
        glDeleteRenderbuffers(1, &id);
 }
 
+PixelFormat Renderbuffer::normalize_format(PixelFormat fmt)
+{
+       if(!get_component_size(fmt) && MSP_sized_internal_formats)
+       {
+               unsigned size = (fmt==DEPTH_COMPONENT ? get_gl_api()==OPENGL_ES2 ? 2 : 4 : 1);
+               return get_sized_pixelformat(fmt, size);
+       }
+
+       return fmt;
+}
+
 void Renderbuffer::storage(PixelFormat fmt, unsigned wd, unsigned ht)
 {
+       fmt = normalize_format(fmt);
        require_pixelformat(fmt);
        width = wd;
        height = ht;
@@ -38,6 +50,7 @@ void Renderbuffer::storage(PixelFormat fmt, unsigned wd, unsigned ht)
 void Renderbuffer::storage_multisample(unsigned samples, PixelFormat fmt, unsigned wd, unsigned ht)
 {
        static Require _req(EXT_framebuffer_multisample);
+       fmt = normalize_format(fmt);
        require_pixelformat(fmt);
 
        width = wd;
index efcf5658872982f3aaf6f3ca97471c363a797ec5..0ccf49675897c6b9864da27adb708eed45c458e8 100644 (file)
@@ -31,6 +31,10 @@ public:
        unsigned get_width() const { return width; }
        unsigned get_height() const { return height; }
 
+private:
+       static PixelFormat normalize_format(PixelFormat);
+
+public:
        /** Allocates storage for the renderbuffer. */
        void storage(PixelFormat fmt, unsigned wd, unsigned ht);