X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frendertarget.cpp;h=239180f5e52b9032807a6a9943ecf468e736bc18;hp=8a53e66d2bac06b7adead7bebac9c7d3104f26ef;hb=ca52c492bd4f2fa1a1db3a85e50eaf7c43474830;hpb=fce91f4eda14f5f9e9a7490835b7e62c05243572 diff --git a/source/rendertarget.cpp b/source/rendertarget.cpp index 8a53e66d..239180f5 100644 --- a/source/rendertarget.cpp +++ b/source/rendertarget.cpp @@ -46,7 +46,7 @@ RenderTargetFormat RenderTargetFormat::operator,(PixelFormat f) const } else { - if(unsized!=RGB && unsized!=RGBA) + if(unsized!=RED && unsized!=RG && unsized!=RGB && unsized!=RGBA) throw invalid_argument("RenderTargetformat::operator,"); if(size>3) --size; @@ -72,7 +72,6 @@ int RenderTargetFormat::index(RenderOutput o) const PixelFormat get_output_pixelformat(unsigned char o) { - unsigned ncomp = (o&3)+1; unsigned size = ((o>>2)&3); PixelFormat base; if(get_output_type(o)>=get_output_type(RENDER_DEPTH)) @@ -83,7 +82,8 @@ PixelFormat get_output_pixelformat(unsigned char o) } else { - base = (ncomp==4 ? RGBA : RGB); + static PixelFormat base_formats[4] = { RED, RG, RGB, RGBA }; + base = base_formats[o&3]; if(size==3) ++size; } @@ -133,7 +133,7 @@ void RenderTarget::init(unsigned w, unsigned h, unsigned s, const RenderTargetFo else { tgt.texture = new Texture2D; - tgt.texture->storage(pf, width, height); + tgt.texture->storage(pf, width, height, 1); tgt.texture->set_filter(NEAREST); tgt.texture->set_wrap(CLAMP_TO_EDGE); fbo.attach(att, *tgt.texture);