X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexture.cpp;h=b8a2614a1da9b697410067a7daaad807476ace7c;hb=e70662d7812464159f2e47f4bebb69d88f89ae93;hp=5f21229fa8abc2d80c3e0029364bb519bd961bee;hpb=b274dc87db4422498e72823649358114dfca0096;p=libs%2Fgl.git diff --git a/source/core/texture.cpp b/source/core/texture.cpp index 5f21229f..b8a2614a 100644 --- a/source/core/texture.cpp +++ b/source/core/texture.cpp @@ -26,28 +26,8 @@ Texture::Texture(unsigned t): void Texture::set_format(PixelFormat fmt) { PixelComponents comp = get_components(fmt); - PixelComponents st_comp = comp; - FormatSwizzle swiz = NO_SWIZZLE; - switch(comp) - { - case LUMINANCE: - st_comp = RED; - swiz = R_TO_LUMINANCE; - break; - case LUMINANCE_ALPHA: - st_comp = RG; - swiz = RG_TO_LUMINANCE_ALPHA; - break; - case BGR: - st_comp = RGB; - swiz = RGB_TO_BGR; - break; - case BGRA: - st_comp = RGBA; - swiz = RGB_TO_BGR; - break; - default:; - } + ComponentSwizzle swiz = get_required_swizzle(comp); + PixelComponents st_comp = unswizzle_components(comp, swiz); PixelFormat st_fmt = make_pixelformat(st_comp, get_component_type(fmt), is_srgb(fmt)); require_pixelformat(st_fmt);