예제 #1
0
	void OGLMapping::MappingVertexFormat(GLenum& gltype, GLboolean& normalized, ElementFormat ef)
	{
		switch (ef)
		{
		case EF_A8:
		case EF_R8:
		case EF_GR8:
		case EF_BGR8:
		case EF_ARGB8:
		case EF_ABGR8:
			gltype = GL_UNSIGNED_BYTE;
			normalized = GL_TRUE;
			break;

		case EF_R8UI:
		case EF_GR8UI:
		case EF_BGR8UI:
		case EF_ABGR8UI:
			gltype = GL_UNSIGNED_BYTE;
			normalized = GL_FALSE;
			break;

		case EF_SIGNED_R8:
		case EF_SIGNED_GR8:
		case EF_SIGNED_BGR8:
		case EF_SIGNED_ABGR8:
			gltype = GL_BYTE;
			normalized = GL_TRUE;
			break;

		case EF_R8I:
		case EF_GR8I:
		case EF_BGR8I:
		case EF_ABGR8I:
			gltype = GL_BYTE;
			normalized = GL_FALSE;
			break;

		case EF_A2BGR10:
			gltype = GL_UNSIGNED_INT_2_10_10_10_REV;
			normalized = GL_TRUE;
			break;

		case EF_SIGNED_A2BGR10:
			if (glloader_GL_VERSION_3_3() || glloader_GL_ARB_vertex_type_2_10_10_10_rev())
			{
				gltype = GL_INT_2_10_10_10_REV;
			}
			else
			{
				gltype = GL_UNSIGNED_INT_2_10_10_10_REV;
			}
			normalized = GL_TRUE;
			break;

		case EF_R16:
		case EF_GR16:
		case EF_BGR16:
		case EF_ABGR16:
			gltype = GL_UNSIGNED_SHORT;
			normalized = GL_TRUE;
			break;

		case EF_R16UI:
		case EF_GR16UI:
		case EF_BGR16UI:
		case EF_ABGR16UI:
			gltype = GL_UNSIGNED_SHORT;
			normalized = GL_FALSE;
			break;

		case EF_SIGNED_R16:
		case EF_SIGNED_GR16:
		case EF_SIGNED_BGR16:
		case EF_SIGNED_ABGR16:
			gltype = GL_SHORT;
			normalized = GL_TRUE;
			break;

		case EF_R16I:
		case EF_GR16I:
		case EF_BGR16I:
		case EF_ABGR16I:
			gltype = GL_SHORT;
			normalized = GL_FALSE;
			break;

		case EF_R32UI:
		case EF_GR32UI:
		case EF_BGR32UI:
		case EF_ABGR32UI:
			gltype = GL_UNSIGNED_INT;
			normalized = GL_FALSE;
			break;

		case EF_R32I:
		case EF_GR32I:
		case EF_BGR32I:
		case EF_ABGR32I:
			gltype = GL_INT;
			normalized = GL_FALSE;
			break;

		case EF_R16F:
		case EF_GR16F:
		case EF_BGR16F:
		case EF_ABGR16F:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				gltype = GL_HALF_FLOAT_ARB;
			}
			else
			{
				gltype = GL_FLOAT;
			}
			normalized = GL_FALSE;
			break;

		case EF_B10G11R11F:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_packed_float())
			{
				gltype = GL_UNSIGNED_INT_10F_11F_11F_REV;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			normalized = GL_FALSE;
			break;

		case EF_R32F:
		case EF_GR32F:
		case EF_BGR32F:
		case EF_ABGR32F:
			gltype = GL_FLOAT;
			normalized = GL_FALSE;
			break;

		default:
			THR(errc::function_not_supported);
		}
	}
예제 #2
0
	void OGLMapping::MappingFormat(GLint& internalFormat, GLenum& glformat, GLenum& gltype, ElementFormat ef)
	{
		switch (ef)
		{
		case EF_A8:
			internalFormat = GL_ALPHA8;
			glformat = GL_ALPHA;
			gltype = GL_UNSIGNED_BYTE;
			break;

		case EF_R5G6B5:
			internalFormat = GL_RGB565;
			glformat = GL_BGRA;
			gltype = GL_UNSIGNED_SHORT_5_6_5_REV;
			break;

		case EF_A1RGB5:
			internalFormat = GL_RGB5_A1;
			glformat = GL_BGRA;
			gltype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
			break;

		case EF_ARGB4:
			internalFormat = GL_RGBA4;
			glformat = GL_BGRA;
			gltype = GL_UNSIGNED_SHORT_4_4_4_4_REV;
			break;

		case EF_R8:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_R8;
				glformat = GL_RED;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				internalFormat = GL_LUMINANCE8;
				glformat = GL_LUMINANCE;
				gltype = GL_UNSIGNED_BYTE;
			}
			break;

		case EF_SIGNED_R8:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_R8;
				glformat = GL_RED;
				gltype = GL_BYTE;
			}
			else
			{
				internalFormat = GL_LUMINANCE8;
				glformat = GL_LUMINANCE;
				gltype = GL_BYTE;
			}
			break;

		case EF_GR8:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_RG8;
				glformat = GL_RG;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_SIGNED_GR8:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_RG8;
				glformat = GL_RG;
				gltype = GL_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BGR8:
			internalFormat = GL_RGB8;
			glformat = GL_RGB;
			gltype = GL_UNSIGNED_BYTE;
			break;

		case EF_SIGNED_BGR8:
			if (glloader_GL_VERSION_3_1() || glloader_GL_EXT_texture_snorm())
			{
				internalFormat = GL_RGB8_SNORM;
				glformat = GL_RGB;
				gltype = GL_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_ARGB8:
			internalFormat = GL_RGBA8;
			glformat = GL_BGRA;
			gltype = GL_UNSIGNED_INT_8_8_8_8_REV;
			break;

		case EF_ABGR8:
			internalFormat = GL_RGBA8;
			glformat = GL_RGBA;
			gltype = GL_UNSIGNED_BYTE;
			break;

		case EF_SIGNED_ABGR8:
			if (glloader_GL_VERSION_3_1() || glloader_GL_EXT_texture_snorm())
			{
				internalFormat = GL_RGBA8_SNORM;
				glformat = GL_RGBA;
				gltype = GL_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_A2BGR10:
			internalFormat = GL_RGB10_A2;
			glformat = GL_RGBA;
			gltype = GL_UNSIGNED_INT_2_10_10_10_REV;
			break;

		case EF_SIGNED_A2BGR10:
			internalFormat = GL_RGB10_A2;
			glformat = GL_RGBA;
			if (glloader_GL_VERSION_3_3() || glloader_GL_ARB_vertex_type_2_10_10_10_rev())
			{
				gltype = GL_INT_2_10_10_10_REV;
			}
			else
			{
				gltype = GL_UNSIGNED_INT_2_10_10_10_REV;
			}
			break;

		case EF_R8UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_R8UI;
				glformat = GL_RED_INTEGER_EXT;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_R8I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_R8I;
				glformat = GL_RED_INTEGER_EXT;
				gltype = GL_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_GR8UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RG8UI;
				glformat = GL_RG_INTEGER;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_GR8I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RG8I;
				glformat = GL_RG_INTEGER;
				gltype = GL_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BGR8UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGB8UI;
				glformat = GL_RGB_INTEGER;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BGR8I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGB8I;
				glformat = GL_RGB_INTEGER;
				gltype = GL_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_ABGR8UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGBA8UI;
				glformat = GL_RGBA_INTEGER;
				gltype = GL_UNSIGNED_INT_8_8_8_8;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_ABGR8I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGBA8I;
				glformat = GL_RGBA_INTEGER;
				gltype = GL_UNSIGNED_INT_8_8_8_8;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_R16:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_R16;
				glformat = GL_RED;
				gltype = GL_UNSIGNED_SHORT;
			}
			else
			{
				internalFormat = GL_LUMINANCE16;
				glformat = GL_LUMINANCE;
				gltype = GL_UNSIGNED_SHORT;
			}
			break;

		case EF_SIGNED_R16:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_R16;
				glformat = GL_RED;
				gltype = GL_SHORT;
			}
			else
			{
				internalFormat = GL_LUMINANCE16;
				glformat = GL_LUMINANCE;
				gltype = GL_SHORT;
			}
			break;

		case EF_GR16:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_RG16;
				glformat = GL_RG;
				gltype = GL_UNSIGNED_SHORT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_SIGNED_GR16:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_RG16;
				glformat = GL_RG;
				gltype = GL_SHORT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BGR16:
			internalFormat = GL_RGB16;
			glformat = GL_RGB;
			gltype = GL_UNSIGNED_SHORT;
			break;

		case EF_SIGNED_BGR16:
			internalFormat = GL_RGB16;
			glformat = GL_RGB;
			gltype = GL_SHORT;
			break;

		case EF_ABGR16:
			internalFormat = GL_RGBA16;
			glformat = GL_RGBA;
			gltype = GL_UNSIGNED_SHORT;
			break;

		case EF_SIGNED_ABGR16:
			internalFormat = GL_RGBA16;
			glformat = GL_RGBA;
			gltype = GL_SHORT;
			break;

		case EF_R16UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_R16UI;
				glformat = GL_RED_INTEGER_EXT;
				gltype = GL_UNSIGNED_SHORT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_R16I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_R16I;
				glformat = GL_RED_INTEGER_EXT;
				gltype = GL_SHORT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_GR16UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RG16UI;
				glformat = GL_RG_INTEGER;
				gltype = GL_UNSIGNED_SHORT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_GR16I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RG16I;
				glformat = GL_RG_INTEGER;
				gltype = GL_SHORT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BGR16UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGB16UI;
				glformat = GL_RGB_INTEGER;
				gltype = GL_UNSIGNED_SHORT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BGR16I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGB16I;
				glformat = GL_RGB_INTEGER;
				gltype = GL_SHORT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_ABGR16UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGBA16UI;
				glformat = GL_RGBA_INTEGER;
				gltype = GL_UNSIGNED_SHORT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_ABGR16I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGBA16I;
				glformat = GL_RGBA_INTEGER;
				gltype = GL_SHORT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_R32UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_R32UI;
				glformat = GL_RED_INTEGER_EXT;
				gltype = GL_UNSIGNED_INT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_R32I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_R32I;
				glformat = GL_RED_INTEGER_EXT;
				gltype = GL_INT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_GR32UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RG32UI;
				glformat = GL_RG_INTEGER;
				gltype = GL_UNSIGNED_INT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_GR32I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RG32I;
				glformat = GL_RG_INTEGER;
				gltype = GL_INT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BGR32UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGB32UI;
				glformat = GL_RGB_INTEGER;
				gltype = GL_UNSIGNED_INT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BGR32I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGB32I;
				glformat = GL_RGB_INTEGER;
				gltype = GL_INT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_ABGR32UI:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGBA32UI;
				glformat = GL_RGBA_INTEGER;
				gltype = GL_UNSIGNED_INT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_ABGR32I:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_texture_integer())
			{
				internalFormat = GL_RGBA32I;
				glformat = GL_RGBA_INTEGER;
				gltype = GL_INT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_R16F:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_R16F;
				glformat = GL_RED;
				gltype = GL_HALF_FLOAT_ARB;
			}
			else
			{
				internalFormat = GL_LUMINANCE16F_ARB;
				glformat = GL_LUMINANCE;
				gltype = GL_HALF_FLOAT_ARB;
			}
			break;

		case EF_GR16F:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_RG16F;
				glformat = GL_RG;
				gltype = GL_HALF_FLOAT_ARB;
			}
			else
			{
				internalFormat = GL_LUMINANCE_ALPHA16F_ARB;
				glformat = GL_LUMINANCE_ALPHA;
				gltype = GL_FLOAT;
			}
			break;

		case EF_B10G11R11F:
			if (glloader_GL_VERSION_3_0() || glloader_GL_EXT_packed_float())
			{
				internalFormat = GL_R11F_G11F_B10F;
				glformat = GL_RGB;
				gltype = GL_UNSIGNED_INT_10F_11F_11F_REV;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BGR16F:
			internalFormat = GL_RGB16F_ARB;
			glformat = GL_RGB;
			gltype = GL_HALF_FLOAT_ARB;
			break;

		case EF_ABGR16F:
			internalFormat = GL_RGBA16F_ARB;
			glformat = GL_RGBA;
			gltype = GL_HALF_FLOAT_ARB;
			break;

		case EF_R32F:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_R32F;
				glformat = GL_RED;
				gltype = GL_FLOAT;
			}
			else
			{
				internalFormat = GL_LUMINANCE32F_ARB;
				glformat = GL_LUMINANCE;
				gltype = GL_FLOAT;
			}
			break;

		case EF_GR32F:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_rg())
			{
				internalFormat = GL_RG32F;
				glformat = GL_RG;
				gltype = GL_FLOAT;
			}
			else
			{
				internalFormat = GL_LUMINANCE_ALPHA32F_ARB;
				glformat = GL_LUMINANCE_ALPHA;
				gltype = GL_FLOAT;
			}
			break;

		case EF_BGR32F:
			internalFormat = GL_RGB32F_ARB;
			glformat = GL_RGB;
			gltype = GL_FLOAT;
			break;

		case EF_ABGR32F:
			internalFormat = GL_RGBA32F_ARB;
			glformat = GL_RGBA;
			gltype = GL_FLOAT;
			break;

		case EF_BC1:
			if (glloader_GL_EXT_texture_compression_s3tc())
			{
				internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
				glformat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BC2:
			if (glloader_GL_EXT_texture_compression_s3tc())
			{
				internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
				glformat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BC3:
			if (glloader_GL_EXT_texture_compression_s3tc())
			{
				internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
				glformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BC4:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_compression_rgtc())
			{
				internalFormat = GL_COMPRESSED_RED_RGTC1;
				glformat = GL_COMPRESSED_LUMINANCE;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_BC5:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_compression_rgtc())
			{
				internalFormat = GL_COMPRESSED_RG_RGTC2;
				glformat = GL_COMPRESSED_LUMINANCE_ALPHA;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_SIGNED_BC4:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_compression_rgtc())
			{
				internalFormat = GL_COMPRESSED_SIGNED_RED_RGTC1;
				glformat = GL_COMPRESSED_LUMINANCE;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_SIGNED_BC5:
			if (glloader_GL_VERSION_3_0() || glloader_GL_ARB_texture_compression_rgtc())
			{
				internalFormat = GL_COMPRESSED_SIGNED_RG_RGTC2;
				glformat = GL_COMPRESSED_LUMINANCE_ALPHA;
				gltype = GL_UNSIGNED_BYTE;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_D16:
			internalFormat = GL_DEPTH_COMPONENT16;
			glformat = GL_DEPTH_COMPONENT;
			gltype = GL_UNSIGNED_SHORT;
			break;

		case EF_D24S8:
			if (glloader_GL_VERSION_3_0())
			{
				internalFormat = GL_DEPTH24_STENCIL8;
				glformat = GL_DEPTH_STENCIL;
				gltype = GL_UNSIGNED_INT_24_8;
			}
			else if (glloader_GL_EXT_packed_depth_stencil())
			{
				internalFormat = GL_DEPTH24_STENCIL8_EXT;
				glformat = GL_DEPTH_STENCIL_EXT;
				gltype = GL_UNSIGNED_INT_24_8_EXT;
			}
			else
			{
				THR(errc::function_not_supported);
			}
			break;

		case EF_D32F:
			internalFormat = GL_DEPTH_COMPONENT32F;
			glformat = GL_DEPTH_COMPONENT;
			gltype = GL_FLOAT;
			break;

		case EF_ARGB8_SRGB:
			internalFormat = GL_SRGB8_ALPHA8;
			glformat = GL_BGRA;
			gltype = GL_UNSIGNED_INT_8_8_8_8_REV;
			break;

		case EF_ABGR8_SRGB:
			internalFormat = GL_SRGB8_ALPHA8;
			glformat = GL_RGBA;
			gltype = GL_UNSIGNED_BYTE;
			break;

		case EF_BC1_SRGB:
			internalFormat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
			glformat = GL_BGRA;
			gltype = GL_UNSIGNED_BYTE;
			break;

		case EF_BC2_SRGB:
			internalFormat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
			glformat = GL_BGRA;
			gltype = GL_UNSIGNED_BYTE;
			break;

		case EF_BC3_SRGB:
			internalFormat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
			glformat = GL_BGRA;
			gltype = GL_UNSIGNED_BYTE;
			break;

		case EF_BC4_SRGB:
			internalFormat = GL_COMPRESSED_SLUMINANCE;
			glformat = GL_LUMINANCE;
			gltype = GL_UNSIGNED_BYTE;
			break;

		case EF_BC5_SRGB:
			internalFormat = GL_COMPRESSED_SLUMINANCE_ALPHA;
			glformat = GL_LUMINANCE_ALPHA;
			gltype = GL_UNSIGNED_BYTE;
			break;

		default:
			THR(errc::function_not_supported);
		}
	}
예제 #3
0
	void OGLTexture1D::CopyToSubTexture1D(Texture& target,
			uint32_t dst_array_index, uint32_t dst_level, uint32_t dst_x_offset, uint32_t dst_width,
			uint32_t src_array_index, uint32_t src_level, uint32_t src_x_offset, uint32_t src_width)
	{
		BOOST_ASSERT(type_ == target.Type());
		
		if ((format_ == target.Format()) && !IsCompressedFormat(format_) && (glloader_GL_VERSION_4_3() || glloader_GL_ARB_copy_image())
			&& (src_width == dst_width) && (1 == sample_count_))
		{
			OGLTexture& ogl_target = *checked_cast<OGLTexture*>(&target);
			glCopyImageSubData(
				texture_, target_type_, src_level,
				src_x_offset, 0, src_array_index,
				ogl_target.GLTexture(), ogl_target.GLType(), dst_level,
				dst_x_offset, 0, dst_array_index, src_width, 1, 1);
		}
		else
		{
			OGLRenderEngine& re = *checked_cast<OGLRenderEngine*>(&Context::Instance().RenderFactoryInstance().RenderEngineInstance());
			if ((sample_count_ > 1) && !IsCompressedFormat(format_) && (glloader_GL_ARB_texture_rg() || (4 == NumComponents(format_))))
			{
				GLuint fbo_src, fbo_dst;
				re.GetFBOForBlit(fbo_src, fbo_dst);

				GLuint old_fbo = re.BindFramebuffer();

				glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_src);
				if (array_size_ > 1)
				{
					glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture_, src_level, src_array_index);
				}
				else
				{
					if (sample_count_ <= 1)
					{
						glFramebufferTexture1D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target_type_, texture_, src_level);
					}
					else
					{
						glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER,
											GL_COLOR_ATTACHMENT0,
											GL_RENDERBUFFER, texture_);
					}
				}

				OGLTexture& ogl_target = *checked_cast<OGLTexture*>(&target);
				glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_dst);
				if (array_size_ > 1)
				{
					glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, ogl_target.GLTexture(), dst_level, dst_array_index);
				}
				else
				{
					glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target_type_, ogl_target.GLTexture(), dst_level);
				}

				glBlitFramebuffer(src_x_offset, 0, src_x_offset + src_width, 1,
								dst_x_offset, 0, dst_x_offset + dst_width, 1,
								GL_COLOR_BUFFER_BIT, (src_width == dst_width) ? GL_NEAREST : GL_LINEAR);

				re.BindFramebuffer(old_fbo, true);
			}
			else
			{
				if ((src_width == dst_width) && (format_ == target.Format()))
				{
					if (IsCompressedFormat(format_))
					{
						BOOST_ASSERT(0 == (src_x_offset & 0x3));
						BOOST_ASSERT(0 == (dst_x_offset & 0x3));
						BOOST_ASSERT(0 == (src_width & 0x3));
						BOOST_ASSERT(0 == (dst_width & 0x3));

						Texture::Mapper mapper_src(*this, src_array_index, src_level, TMA_Read_Only, 0, this->Width(src_level));
						Texture::Mapper mapper_dst(target, dst_array_index, dst_level, TMA_Write_Only, 0, target.Width(dst_level));

						uint32_t const block_size = NumFormatBytes(format_) * 4;
						uint8_t const * s = mapper_src.Pointer<uint8_t>() + (src_x_offset / 4 * block_size);
						uint8_t* d = mapper_dst.Pointer<uint8_t>() + (dst_x_offset / 4 * block_size);
						std::memcpy(d, s, src_width / 4 * block_size);
					}
					else
					{
						size_t const format_size = NumFormatBytes(format_);

						Texture::Mapper mapper_src(*this, src_array_index, src_level, TMA_Read_Only, src_x_offset, src_width);
						Texture::Mapper mapper_dst(target, dst_array_index, dst_level, TMA_Write_Only, dst_x_offset, dst_width);
						uint8_t const * s = mapper_src.Pointer<uint8_t>();
						uint8_t* d = mapper_dst.Pointer<uint8_t>();

						std::memcpy(d, s, src_width * format_size);
					}
				}
				else
				{
					this->ResizeTexture1D(target, dst_array_index, dst_level, dst_x_offset, dst_width,
						src_array_index, src_level, src_x_offset, src_width, true);
				}
			}
		}
	}