MCPcopy Create free account
hub / github.com/bluescan/tacentview / GetGLFormatInfo

Method GetGLFormatInfo

Src/Image.cpp:1685–1763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1683
1684
1685void Image::GetGLFormatInfo(GLint& srcFormat, GLenum& srcType, GLint& dstFormat, bool& compressed, tPixelFormat pixelFormat)
1686{
1687 srcFormat = GL_INVALID_VALUE;
1688 srcType = GL_INVALID_ENUM;
1689 dstFormat = GL_INVALID_VALUE;
1690 compressed = false;
1691
1692 // Note that the destination format only specifies the resolution of each colour component, not the order or the
1693 // specifics -- they're up to the OpenGL driver. For example, nVidia cards use an internal BGRA format when GL_RGBA8
1694 // is specified -- that's why having srcFormat = GL_BGRA and dstFormat = RGBA8 is very efficient (no swizzling).
1695 tAssert(GL_EXT_texture_compression_s3tc);
1696 switch (pixelFormat)
1697 {
1698 case tPixelFormat::R8G8B8:
1699 srcFormat = GL_RGB; srcType = GL_UNSIGNED_BYTE;
1700 dstFormat = GL_RGB8;
1701 break;
1702
1703 case tPixelFormat::R8G8B8A8:
1704 srcFormat = GL_RGBA; srcType = GL_UNSIGNED_BYTE;
1705 dstFormat = GL_RGBA8;
1706 break;
1707
1708 case tPixelFormat::B8G8R8:
1709 srcFormat = GL_BGR; srcType = GL_UNSIGNED_BYTE;
1710 dstFormat = GL_RGB8;
1711 break;
1712
1713 case tPixelFormat::B8G8R8A8:
1714 srcFormat = GL_BGRA; srcType = GL_UNSIGNED_BYTE;
1715 dstFormat = GL_RGBA8;
1716 break;
1717
1718 case tPixelFormat::BC1DXT1A:
1719 dstFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; compressed = true;
1720 break;
1721
1722 case tPixelFormat::BC1DXT1:
1723 dstFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; compressed = true;
1724 break;
1725
1726 case tPixelFormat::BC2DXT2DXT3:
1727 dstFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; compressed = true;
1728 break;
1729
1730 case tPixelFormat::BC3DXT4DXT5:
1731 dstFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; compressed = true;
1732 break;
1733
1734 case tPixelFormat::BC7:
1735 dstFormat = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; compressed = true;
1736 break;
1737
1738 case tPixelFormat::BC6S:
1739 dstFormat = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB; compressed = true;
1740 break;
1741
1742 case tPixelFormat::G3B5R5G3:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected