From: Mikko Rasa Date: Sat, 5 Nov 2016 15:12:20 +0000 (+0200) Subject: Also convert RenderBuffer formats to sized variants if possible X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=96fb9a0237a7c3f6fc23406ce50cd1c6fe484111;p=libs%2Fgl.git Also convert RenderBuffer formats to sized variants if possible --- diff --git a/source/renderbuffer.cpp b/source/renderbuffer.cpp index 17d36846..50983622 100644 --- a/source/renderbuffer.cpp +++ b/source/renderbuffer.cpp @@ -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; diff --git a/source/renderbuffer.h b/source/renderbuffer.h index efcf5658..0ccf4967 100644 --- a/source/renderbuffer.h +++ b/source/renderbuffer.h @@ -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);