Ejemplo n.º 1
0
// Check if the given image format and datatype are compatible.
// Also check for types/formats defined by GL extensions here.
bool
PixelFormatsTest::CompatibleFormatAndType(GLenum format, GLenum datatype) const
{
	// Special case: GL_BGR can't be used with packed types!
	// This has to do with putting the most color bits in red and green,
	// not blue.
	if (format == GL_BGR && IsPackedType(datatype))
		return false;

	if (datatype == GL_HALF_FLOAT_ARB && !haveHalfFloat)
		return false;

	if (format == GL_ABGR_EXT && !haveABGR)
		return false;

	// Special case: GL_ABGR_EXT can't be used with packed types
	// because the packed formats specs (which were all written after the
	// GL_EXT_abgr) explicitly say that the packed formats can only be used
	// with GL_RGB, GL_BGR, GL_RGBA, or GL_BGRA and do not mention
	// GL_ABGR_EXT.
	if (format == GL_ABGR_EXT && IsPackedType(datatype))
		return false;

	if (format == GL_RG && !haveRG)
		return false;

	if (datatype == GL_UNSIGNED_INT_5_9_9_9_REV && !haveTexSharedExp)
		return false;

	const int formatComps = NumberOfComponentsInFormat(format);
	const int typeComps = NumberOfComponentsInPackedType(datatype);
	return formatComps == typeComps || typeComps == 0;
}
Ejemplo n.º 2
0
// Check if the given image format and datatype are compatible.
// Also check for types/formats defined by GL extensions here.
bool
PixelFormatsTest::CompatibleFormatAndType(GLenum format, GLenum datatype) const
{
    // Special case: GL_BGR can't be used with packed types!
    // This has to do with putting the most color bits in red and green,
    // not blue.
    if (format == GL_BGR && IsPackedType(datatype))
        return false;

#ifdef GL_ARB_half_float_pixel
    if (datatype == GL_HALF_FLOAT_ARB && !haveHalfFloat)
        return false;
#endif

#ifdef GL_EXT_abgr
    if (format == GL_ABGR_EXT && !haveABGR)
        return false;
#endif

    const int formatComps = NumberOfComponentsInFormat(format);
    const int typeComps = NumberOfComponentsInPackedType(datatype);
    return formatComps == typeComps || typeComps == 0;
}
Ejemplo n.º 3
0
static int
IsPackedType(GLenum datatype)
{
	return NumberOfComponentsInPackedType(datatype) > 0;
}