X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frenderbuffer.cpp;h=5bea07fc81e60a70c26c7744f3e7d5a6434bc621;hp=5098362261e45743d396c81ea9bc5b9878d3c9ae;hb=bf1f59c4dca6b651e39c126c63a0780b65a34927;hpb=96fb9a0237a7c3f6fc23406ce50cd1c6fe484111 diff --git a/source/renderbuffer.cpp b/source/renderbuffer.cpp index 50983622..5bea07fc 100644 --- a/source/renderbuffer.cpp +++ b/source/renderbuffer.cpp @@ -1,8 +1,11 @@ #include #include #include +#include "misc.h" #include "renderbuffer.h" +using namespace std; + namespace Msp { namespace GL { @@ -23,11 +26,8 @@ Renderbuffer::~Renderbuffer() 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); - } + if(!get_component_size(fmt) && OES_required_internalformat) + return get_default_sized_pixelformat(fmt); return fmt; } @@ -47,9 +47,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); + if(samples>get_max_samples()) + throw out_of_range("Renderbuffer::storage_multisample"); + fmt = normalize_format(fmt); require_pixelformat(fmt);