当前位置: 首页>>代码示例>>C++>>正文


C++ ImageReader::getOpenGLInternalFormat方法代码示例

本文整理汇总了C++中ImageReader::getOpenGLInternalFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageReader::getOpenGLInternalFormat方法的具体用法?C++ ImageReader::getOpenGLInternalFormat怎么用?C++ ImageReader::getOpenGLInternalFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageReader的用法示例。


在下文中一共展示了ImageReader::getOpenGLInternalFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getImageFileByExtension

void LoadTextureAMT::processCPU_Texture2D(const RJNode& header)
{
    if(ji::hasChild(header, "images"))
    {
        const RJNode& images = ji::getChild(header, "images");
        if(images.is_array() && images.size() > 0)
        {
            m_target = GL_TEXTURE_2D;

            const RJNode& img = images.at(0);
            std::string imageFilePath = ji::read(img, "filePath", DV_STRING);

            // Fail loading if given extension is not supported or file is invalid.
            ImageReader* reader = getImageFileByExtension(imageFilePath);
            if(!reader || !reader->isValid())
            {
                utils::deleteAndNull(reader);
                return;
            }

            m_imageReaders[0] = reader;
            m_imageGLFormat = reader->getOpenGLInternalFormat();
        }
    }
}
开发者ID:creepydragon,项目名称:r2,代码行数:25,代码来源:LoadTextureAMT.cpp

示例2: CTextureResource

C2DTextureResource::C2DTextureResource(const std::string &filePath, const int flags) : CTextureResource(filePath)
{
    GLenum iFormat;
    int levels;
	//uint32_t size;
    ImageReader *img;

    m_textureId = 0;
    m_target = GL_TEXTURE_2D;
    m_type = ETT_TEX2D;

    // Fail loading if given extension is not supported.
    if((img = getImageFileByExtension(filePath)) == 0) { return; }

    // Fail loading if loaded file was invalid.
    if(!img->isValid()) { return; }

    iFormat = img->getOpenGLInternalFormat(flags);

    glActiveTexture(GL_TEXTURE0);
    glGenTextures(1, &m_textureId);
    glBindTexture(m_target, m_textureId);

    if(flags & ETF_MIPMAPS)
    {
        levels = img->getLevelAmount();

		if(levels == 1)
		{
            // If need mipmaps and image has only base level, set number of mipmap levels to generate
            levels = gmath::imageLevelCount(img->getWidth(0), img->getHeight(0), 1);
		}
    }
    else
    {
        levels = 1;
    }

	glTexStorage2D(m_target, levels, iFormat, img->getWidth(0), img->getHeight(0));

    for(int i = 0; i < img->getLevelAmount(); i++)
    {
        if(img->isCompressedFormat())
        {
            glCompressedTexSubImage2D(m_target, i, 0, 0, img->getWidth(i), img->getHeight(i), img->getFormat(), img->getLevelSize(i), img->getData(i));
        }
        else
        {
            glTexSubImage2D(m_target, i, 0, 0, img->getWidth(i), img->getHeight(i), img->getFormat(), GL_UNSIGNED_BYTE, img->getData(i));
        }
    }

	glTexParameteri(m_target, GL_TEXTURE_BASE_LEVEL, 0);

	if((img->getLevelAmount() == 1) && (flags & ETF_MIPMAPS))
	{
        glGenerateMipmap(m_target);
	}

	if(flags & ETF_MIPMAPS)
	{
		glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	}
    else
    {
        glTexParameteri(m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameteri(m_target, GL_TEXTURE_MAX_LEVEL, 0);
	}

    // Anisotropy filtering
	float maximumAnistropy;
	glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnistropy);
	glTexParameterf(m_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, maximumAnistropy);

	//size = approxSize(iFormat, img->getXBlocks(0), img->getYBlocks(0), 1, flags & ETF_MIPMAPS);

    glBindTexture(m_target, 0);

    delete img;

    m_loaded = true;
}
开发者ID:creepydragon,项目名称:revision1,代码行数:84,代码来源:C2DTextureResource.cpp


注:本文中的ImageReader::getOpenGLInternalFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。