]> git.tdb.fi Git - libs/gl.git/commitdiff
Always use swizzle to implement luminance formats
authorMikko Rasa <tdb@tdb.fi>
Mon, 1 Feb 2021 12:52:05 +0000 (14:52 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 1 Feb 2021 17:01:40 +0000 (19:01 +0200)
ARB_texture_swizzle was promoted to core in OpenGL 3.3 and hardware not
supporting that is obsolete.

source/texture.cpp

index 90e3bb17f11de1c318f6670a28ce61a17a13a88b..772f2d16e8b578fac2fbadbb6ef0f3da6f6f8954 100644 (file)
@@ -53,26 +53,28 @@ DataType Texture::get_alloc_type(PixelFormat fmt)
 
 void Texture::set_internal_format(PixelFormat fmt)
 {
-       swizzle = NO_SWIZZLE;
-       if(ARB_texture_rg && ARB_texture_swizzle)
+       FormatSwizzle swiz = NO_SWIZZLE;
+       switch(get_base_pixelformat(fmt))
        {
-               if(fmt==LUMINANCE)
-               {
-                       fmt = RED;
-                       swizzle = R_TO_LUMINANCE;
-               }
-               else if(fmt==LUMINANCE_ALPHA)
-               {
-                       fmt = RG;
-                       swizzle = RG_TO_LUMINANCE_ALPHA;
-               }
+       case LUMINANCE:
+               fmt = RED;
+               swiz = R_TO_LUMINANCE;
+               break;
+       case LUMINANCE_ALPHA:
+               fmt = RG;
+               swiz = RG_TO_LUMINANCE_ALPHA;
+               break;
+       default:;
        }
 
        if(!get_component_size(fmt) && OES_required_internalformat)
                fmt = get_default_sized_pixelformat(fmt);
 
        require_pixelformat(fmt);
+       if(swiz!=NO_SWIZZLE)
+               static Require _req(ARB_texture_swizzle);
        ifmt = fmt;
+       swizzle = swiz;
 }
 
 PixelFormat Texture::get_upload_format(PixelFormat fmt) const