]> git.tdb.fi Git - libs/gl.git/commitdiff
Add a get_default_sized_pixelformat function
authorMikko Rasa <tdb@tdb.fi>
Mon, 4 Dec 2017 11:13:27 +0000 (13:13 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 4 Dec 2017 11:13:27 +0000 (13:13 +0200)
Floating point depth buffers are now preferred also on OpenGL ES when
available.

source/pixelformat.cpp
source/pixelformat.h
source/renderbuffer.cpp
source/texture.cpp

index 6655c6b22c3b3205e06be0bbe338e643209d2da9..0b13f3ccefa7fe53cf2e5868b157a7d0c0e5588b 100644 (file)
@@ -173,6 +173,20 @@ PixelFormat get_sized_pixelformat(PixelFormat pf, unsigned size)
        }
 }
 
        }
 }
 
+PixelFormat get_default_sized_pixelformat(PixelFormat pf)
+{
+       pf = get_unsized_pixelformat(pf);
+       unsigned size = 1;
+       if(pf==DEPTH_COMPONENT)
+       {
+               if(get_gl_api()==OPENGL_ES2 && !ARB_depth_buffer_float)
+                       size = 2;
+               else
+                       size = 4;
+       }
+       return get_sized_pixelformat(pf, size);
+}
+
 PixelFormat get_srgb_pixelformat(PixelFormat pf)
 {
        switch(pf)
 PixelFormat get_srgb_pixelformat(PixelFormat pf)
 {
        switch(pf)
index 5d59c255ea2c40e42aa2a9e20240e47607c22201..2db894a78447ed0d6b7b2892f7c5e8a499509774 100644 (file)
@@ -70,6 +70,7 @@ PixelFormat storage_pixelformat_from_graphics(Graphics::PixelFormat, bool = fals
 PixelFormat get_base_pixelformat(PixelFormat);
 PixelFormat get_unsized_pixelformat(PixelFormat);
 PixelFormat get_sized_pixelformat(PixelFormat, unsigned = 1);
 PixelFormat get_base_pixelformat(PixelFormat);
 PixelFormat get_unsized_pixelformat(PixelFormat);
 PixelFormat get_sized_pixelformat(PixelFormat, unsigned = 1);
+PixelFormat get_default_sized_pixelformat(PixelFormat);
 PixelFormat get_srgb_pixelformat(PixelFormat);
 unsigned get_component_count(PixelFormat);
 unsigned get_component_size(PixelFormat);
 PixelFormat get_srgb_pixelformat(PixelFormat);
 unsigned get_component_count(PixelFormat);
 unsigned get_component_size(PixelFormat);
index 5098362261e45743d396c81ea9bc5b9878d3c9ae..9d19e08b814c7b6976236e61ba2bb32c36f59e6c 100644 (file)
@@ -23,11 +23,8 @@ Renderbuffer::~Renderbuffer()
 
 PixelFormat Renderbuffer::normalize_format(PixelFormat fmt)
 {
 
 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;
 }
 
        return fmt;
 }
index 185ed7feea582b53194e7a7a61183845b576f065..a8b2f6d0db3e243a05548e6f452ae8d71fd015f8 100644 (file)
@@ -95,11 +95,8 @@ DataType Texture::get_alloc_type(PixelFormat fmt)
 
 void Texture::set_internal_format(PixelFormat fmt)
 {
 
 void Texture::set_internal_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);
-               fmt = get_sized_pixelformat(fmt, size);
-       }
+       if(!get_component_size(fmt) && OES_required_internalformat)
+               fmt = get_default_sized_pixelformat(fmt);
 
        FormatSwizzle swiz = NO_SWIZZLE;
        if(ARB_texture_rg && ARB_texture_swizzle)
 
        FormatSwizzle swiz = NO_SWIZZLE;
        if(ARB_texture_rg && ARB_texture_swizzle)