Ejemplo n.º 1
0
	OGLESTexture::OGLESTexture(TextureType type, uint32_t array_size, uint32_t sample_count, uint32_t sample_quality, uint32_t access_hint)
					: Texture(type, sample_count, sample_quality, access_hint),
						hw_res_ready_(false)
	{
		array_size_ = array_size;

		if ((array_size > 1) && !glloader_GLES_VERSION_3_0())
		{
			THR(errc::function_not_supported);
		}

		switch (type_)
		{
		case TT_1D:
		case TT_2D:
			if (array_size > 1)
			{
				target_type_ = GL_TEXTURE_2D_ARRAY;
			}
			else
			{
				target_type_ = GL_TEXTURE_2D;
			}
			break;

		case TT_3D:
			if (!glloader_GLES_VERSION_3_0() && !glloader_GLES_OES_texture_3D())
			{
				THR(errc::function_not_supported);
			}
			if (glloader_GLES_VERSION_3_0())
			{
				target_type_ = GL_TEXTURE_3D;
			}
			else
			{
				target_type_ = GL_TEXTURE_3D_OES;
			}
			break;

		case TT_Cube:
			target_type_ = GL_TEXTURE_CUBE_MAP;
			break;

		default:
			BOOST_ASSERT(false);
			target_type_ = GL_TEXTURE_2D;
			break;
		}

		glGenTextures(1, &texture_);
		glBindTexture(target_type_, texture_);
		glTexParameteri(target_type_, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
		glTexParameteri(target_type_, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	}
Ejemplo n.º 2
0
OGLESTexture::OGLESTexture(TextureType type, uint32_t array_size, uint32_t sample_count, uint32_t sample_quality, uint32_t access_hint)
    : Texture(type, sample_count, sample_quality, access_hint)
{
    if (array_size > 1)
    {
        THR(errc::function_not_supported);
    }

    switch (type_)
    {
    case TT_1D:
    case TT_2D:
        target_type_ = GL_TEXTURE_2D;
        break;

    case TT_3D:
        if (!glloader_GLES_VERSION_3_0() && !glloader_GLES_OES_texture_3D())
        {
            THR(errc::function_not_supported);
        }
        if (glloader_GLES_VERSION_3_0())
        {
            target_type_ = GL_TEXTURE_3D;
        }
        else
        {
            target_type_ = GL_TEXTURE_3D_OES;
        }
        break;

    case TT_Cube:
        target_type_ = GL_TEXTURE_CUBE_MAP;
        break;

    default:
        BOOST_ASSERT(false);
        target_type_ = GL_TEXTURE_2D;
        break;
    }
}
Ejemplo n.º 3
0
	OGLESTexture3D::OGLESTexture3D(uint32_t width, uint32_t height, uint32_t depth, uint32_t numMipMaps, uint32_t array_size, ElementFormat format,
							uint32_t sample_count, uint32_t sample_quality, uint32_t access_hint)
					: OGLESTexture(TT_3D, array_size, sample_count, sample_quality, access_hint)
	{
		if (!glloader_GLES_VERSION_3_0() && !glloader_GLES_OES_texture_3D())
		{
			THR(errc::function_not_supported);
		}

		if (IsSRGB(format))
		{
			format = this->SRGBToRGB(format);
		}

		format_ = format;

		if (0 == numMipMaps)
		{
			num_mip_maps_ = 1;
			uint32_t w = width;
			uint32_t h = height;
			uint32_t d = depth;
			while ((w > 1) && (h > 1) && (d > 1))
			{
				++ num_mip_maps_;

				w = std::max<uint32_t>(1U, w / 2);
				h = std::max<uint32_t>(1U, h / 2);
				d = std::max<uint32_t>(1U, d / 2);
			}
		}
		else
		{
			num_mip_maps_ = numMipMaps;
		}
		array_size_ = 1;

		width_ = width;
		height_ = height;
		depth_ = depth;

		tex_data_.resize(num_mip_maps_);

		glBindTexture(target_type_, texture_);
		if (glloader_GLES_VERSION_3_0())
		{
			glTexParameteri(target_type_, GL_TEXTURE_BASE_LEVEL, 0);
			glTexParameteri(target_type_, GL_TEXTURE_MAX_LEVEL, num_mip_maps_ - 1);
		}
		else if (glloader_GLES_APPLE_texture_max_level())
		{
			glTexParameteri(target_type_, GL_TEXTURE_MAX_LEVEL_APPLE, num_mip_maps_ - 1);
		}
		else
		{
			OGLESRenderEngine& re = *checked_cast<OGLESRenderEngine*>(&Context::Instance().RenderFactoryInstance().RenderEngineInstance());
			if (re.HackForTegra())
			{
				glTexParameteri(target_type_, GL_TEXTURE_MAX_LEVEL, num_mip_maps_ - 1);
			}
		}
	}