Commit 7b46d868 authored by nadro's avatar nadro

- Added partial support for R8 and R8G8 color formats (at now OpenGL only)....

- Added partial support for R8 and R8G8 color formats (at now OpenGL only). Thanks Hendu for this patch.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4982 dfc29bdd-3216-0410-991c-e03cc46cb475
parent bea36566
...@@ -125,6 +125,14 @@ public: ...@@ -125,6 +125,14 @@ public:
case ECF_DXT4: case ECF_DXT4:
case ECF_DXT5: case ECF_DXT5:
return 32; return 32;
case ECF_R8:
return 8;
case ECF_R8G8:
return 16;
case ECF_R16:
return 16;
case ECF_R16G16:
return 32;
case ECF_R16F: case ECF_R16F:
return 16; return 16;
case ECF_G16R16F: case ECF_G16R16F:
...@@ -170,6 +178,11 @@ public: ...@@ -170,6 +178,11 @@ public:
case ECF_R5G6B5: case ECF_R5G6B5:
case ECF_R8G8B8: case ECF_R8G8B8:
case ECF_A8R8G8B8: case ECF_A8R8G8B8:
case ECF_DXT1:
case ECF_DXT2:
case ECF_DXT3:
case ECF_DXT4:
case ECF_DXT5:
return false; return false;
default: default:
return true; return true;
......
...@@ -48,24 +48,40 @@ namespace video ...@@ -48,24 +48,40 @@ namespace video
//! DXT5 color format. //! DXT5 color format.
ECF_DXT5, ECF_DXT5,
/** Floating Point formats. The following formats may only be used for render target textures. */ /** The following formats may only be used for render target textures. */
//! 16 bit floating point format using 16 bits for the red channel. /** Unsigned normalized integer formats. */
//! 8 bit format using 8 bits for the red channel.
ECF_R8,
//! 16 bit format using 8 bits for the red and green channels.
ECF_R8G8,
//! 16 bit format using 16 bits for the red channel.
ECF_R16,
//! 32 bit format using 16 bits for the red and green channels.
ECF_R16G16,
/** Floating point formats. */
//! 16 bit format using 16 bits for the red channel.
ECF_R16F, ECF_R16F,
//! 32 bit floating point format using 16 bits for the red channel and 16 bits for the green channel. //! 32 bit format using 16 bits for the red and green channels.
ECF_G16R16F, ECF_G16R16F,
//! 64 bit floating point format 16 bits are used for the red, green, blue and alpha channels. //! 64 bit format using 16 bits for the red, green, blue and alpha channels.
ECF_A16B16G16R16F, ECF_A16B16G16R16F,
//! 32 bit floating point format using 32 bits for the red channel. //! 32 bit format using 32 bits for the red channel.
ECF_R32F, ECF_R32F,
//! 64 bit floating point format using 32 bits for the red channel and 32 bits for the green channel. //! 64 bit format using 32 bits for the red and green channels.
ECF_G32R32F, ECF_G32R32F,
//! 128 bit floating point format. 32 bits are used for the red, green, blue and alpha channels. //! 128 bit format using 32 bits for the red, green, blue and alpha channels.
ECF_A32B32G32R32F, ECF_A32B32G32R32F,
//! Unknown color format: //! Unknown color format:
......
...@@ -4675,16 +4675,21 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE ...@@ -4675,16 +4675,21 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
if (target==video::ERT_MULTI_RENDER_TEXTURES || target==video::ERT_RENDER_TEXTURE || target==video::ERT_STEREO_BOTH_BUFFERS) if (target==video::ERT_MULTI_RENDER_TEXTURES || target==video::ERT_RENDER_TEXTURE || target==video::ERT_STEREO_BOTH_BUFFERS)
return 0; return 0;
if (format==video::ECF_UNKNOWN)
format=getColorFormat();
if (IImage::isRenderTargetOnlyFormat(format))
return 0;
// allows to read pixels in top-to-bottom order // allows to read pixels in top-to-bottom order
#ifdef GL_MESA_pack_invert #ifdef GL_MESA_pack_invert
if (FeatureAvailable[IRR_MESA_pack_invert]) if (FeatureAvailable[IRR_MESA_pack_invert])
glPixelStorei(GL_PACK_INVERT_MESA, GL_TRUE); glPixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
#endif #endif
if (format==video::ECF_UNKNOWN)
format=getColorFormat();
GLenum fmt; GLenum fmt;
GLenum type; GLenum type;
switch (format) switch (format)
{ {
case ECF_A1R5G5B5: case ECF_A1R5G5B5:
...@@ -4706,70 +4711,6 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE ...@@ -4706,70 +4711,6 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
else else
type = GL_UNSIGNED_BYTE; type = GL_UNSIGNED_BYTE;
break; break;
case ECF_R16F:
if (FeatureAvailable[IRR_ARB_texture_rg])
fmt = GL_RED;
else
fmt = GL_LUMINANCE;
#ifdef GL_ARB_half_float_pixel
if (FeatureAvailable[IRR_ARB_half_float_pixel])
type = GL_HALF_FLOAT_ARB;
else
#endif
{
type = GL_FLOAT;
format = ECF_R32F;
}
break;
case ECF_G16R16F:
#ifdef GL_ARB_texture_rg
if (FeatureAvailable[IRR_ARB_texture_rg])
fmt = GL_RG;
else
#endif
fmt = GL_LUMINANCE_ALPHA;
#ifdef GL_ARB_half_float_pixel
if (FeatureAvailable[IRR_ARB_half_float_pixel])
type = GL_HALF_FLOAT_ARB;
else
#endif
{
type = GL_FLOAT;
format = ECF_G32R32F;
}
break;
case ECF_A16B16G16R16F:
fmt = GL_BGRA;
#ifdef GL_ARB_half_float_pixel
if (FeatureAvailable[IRR_ARB_half_float_pixel])
type = GL_HALF_FLOAT_ARB;
else
#endif
{
type = GL_FLOAT;
format = ECF_A32B32G32R32F;
}
break;
case ECF_R32F:
if (FeatureAvailable[IRR_ARB_texture_rg])
fmt = GL_RED;
else
fmt = GL_LUMINANCE;
type = GL_FLOAT;
break;
case ECF_G32R32F:
#ifdef GL_ARB_texture_rg
if (FeatureAvailable[IRR_ARB_texture_rg])
fmt = GL_RG;
else
#endif
fmt = GL_LUMINANCE_ALPHA;
type = GL_FLOAT;
break;
case ECF_A32B32G32R32F:
fmt = GL_BGRA;
type = GL_FLOAT;
break;
default: default:
fmt = GL_BGRA; fmt = GL_BGRA;
type = GL_UNSIGNED_BYTE; type = GL_UNSIGNED_BYTE;
......
...@@ -198,95 +198,130 @@ GLint COpenGLTexture::getOpenGLFormatAndParametersFromColorFormat(ECOLOR_FORMAT ...@@ -198,95 +198,130 @@ GLint COpenGLTexture::getOpenGLFormatAndParametersFromColorFormat(ECOLOR_FORMAT
type = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; type = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
internalformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; internalformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
break; break;
case ECF_R8:
if (Driver->FeatureAvailable[Driver->IRR_ARB_texture_rg])
{
colorformat = GL_RED;
type = GL_UNSIGNED_BYTE;
internalformat = GL_R8;
}
else
os::Printer::log("ECF_R8 color format is unsupported", ELL_ERROR);
break;
case ECF_R8G8:
if (Driver->FeatureAvailable[Driver->IRR_ARB_texture_rg])
{
colorformat = GL_RG;
type = GL_UNSIGNED_BYTE;
internalformat = GL_RG8;
}
else
os::Printer::log("ECF_R8G8 color format is unsupported", ELL_ERROR);
break;
case ECF_R16:
if (Driver->FeatureAvailable[Driver->IRR_ARB_texture_rg])
{
colorformat = GL_RED;
type = GL_UNSIGNED_SHORT;
internalformat = GL_R16;
}
else
os::Printer::log("ECF_R16 color format is unsupported", ELL_ERROR);
break;
case ECF_R16G16:
if (Driver->FeatureAvailable[Driver->IRR_ARB_texture_rg])
{
colorformat = GL_RG;
type = GL_UNSIGNED_SHORT;
internalformat = GL_RG16;
}
else
os::Printer::log("ECF_R16G16 color format is unsupported", ELL_ERROR);
break;
case ECF_R16F: case ECF_R16F:
{ if (Driver->FeatureAvailable[Driver->IRR_ARB_texture_rg])
#ifdef GL_ARB_texture_rg {
filtering = GL_NEAREST; filtering = GL_NEAREST;
colorformat = GL_RED; colorformat = GL_RED;
type = GL_FLOAT; internalformat = GL_R16F;
#ifdef GL_ARB_half_float_pixel
internalformat = GL_R16F; if (Driver->FeatureAvailable[Driver->IRR_ARB_half_float_pixel])
#else type = GL_HALF_FLOAT_ARB;
ColorFormat = ECF_A8R8G8B8; else
internalformat = GL_RGB8;
#endif #endif
} type = GL_FLOAT;
}
else
os::Printer::log("ECF_R16F color format is unsupported", ELL_ERROR);
break; break;
case ECF_G16R16F: case ECF_G16R16F:
{ if (Driver->FeatureAvailable[Driver->IRR_ARB_texture_rg])
#ifdef GL_ARB_texture_rg {
filtering = GL_NEAREST; filtering = GL_NEAREST;
colorformat = GL_RG; colorformat = GL_RG;
type = GL_FLOAT; internalformat = GL_RG16F;
#ifdef GL_ARB_half_float_pixel
internalformat = GL_RG16F; if (Driver->FeatureAvailable[Driver->IRR_ARB_half_float_pixel])
#else type = GL_HALF_FLOAT_ARB;
ColorFormat = ECF_A8R8G8B8; else
internalformat = GL_RGB8;
#endif #endif
} type = GL_FLOAT;
}
else
os::Printer::log("ECF_G16R16F color format is unsupported", ELL_ERROR);
break; break;
case ECF_A16B16G16R16F: case ECF_A16B16G16R16F:
{ if (Driver->FeatureAvailable[Driver->IRR_ARB_texture_float])
#ifdef GL_ARB_texture_rg {
filtering = GL_NEAREST; filtering = GL_NEAREST;
colorformat = GL_RGBA; colorformat = GL_RGBA;
type = GL_FLOAT; internalformat = GL_RGBA16F_ARB;
#ifdef GL_ARB_half_float_pixel
internalformat = GL_RGBA16F_ARB; if (Driver->FeatureAvailable[Driver->IRR_ARB_half_float_pixel])
#else type = GL_HALF_FLOAT_ARB;
ColorFormat = ECF_A8R8G8B8; else
internalformat = GL_RGBA8;
#endif #endif
} type = GL_FLOAT;
}
else
os::Printer::log("ECF_A16B16G16R16F color format is unsupported", ELL_ERROR);
break; break;
case ECF_R32F: case ECF_R32F:
{ if (Driver->FeatureAvailable[Driver->IRR_ARB_texture_rg])
#ifdef GL_ARB_texture_rg {
filtering = GL_NEAREST; filtering = GL_NEAREST;
colorformat = GL_RED; colorformat = GL_RED;
type = GL_FLOAT; internalformat = GL_R32F;
type = GL_FLOAT;
internalformat = GL_R32F; }
#else else
ColorFormat = ECF_A8R8G8B8; os::Printer::log("ECF_R32F color format is unsupported", ELL_ERROR);
internalformat = GL_RGB8;
#endif
}
break; break;
case ECF_G32R32F: case ECF_G32R32F:
{ if (Driver->FeatureAvailable[Driver->IRR_ARB_texture_rg])
#ifdef GL_ARB_texture_rg {
filtering = GL_NEAREST; filtering = GL_NEAREST;
colorformat = GL_RG; colorformat = GL_RG;
type = GL_FLOAT; internalformat = GL_RG32F;
type = GL_FLOAT;
internalformat = GL_RG32F; }
#else else
ColorFormat = ECF_A8R8G8B8; os::Printer::log("ECF_G32R32F color format is unsupported", ELL_ERROR);
internalformat = GL_RGB8;
#endif
}
break; break;
case ECF_A32B32G32R32F: case ECF_A32B32G32R32F:
{ if (Driver->FeatureAvailable[Driver->IRR_ARB_texture_float])
#ifdef GL_ARB_texture_float {
filtering = GL_NEAREST; filtering = GL_NEAREST;
colorformat = GL_RGBA; colorformat = GL_RGBA;
type = GL_FLOAT; internalformat = GL_RGBA32F_ARB;
type = GL_FLOAT;
internalformat = GL_RGBA32F_ARB; }
#else else
ColorFormat = ECF_A8R8G8B8; os::Printer::log("ECF_A32B32G32R32F color format is unsupported", ELL_ERROR);
internalformat = GL_RGBA8;
#endif
}
break; break;
default: default:
{
os::Printer::log("Unsupported texture format", ELL_ERROR); os::Printer::log("Unsupported texture format", ELL_ERROR);
internalformat = GL_RGBA8; break;
}
} }
#if defined(GL_ARB_framebuffer_sRGB) || defined(GL_EXT_framebuffer_sRGB) #if defined(GL_ARB_framebuffer_sRGB) || defined(GL_EXT_framebuffer_sRGB)
if (Driver->Params.HandleSRGB) if (Driver->Params.HandleSRGB)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment