首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenGL FreeImage纹理加载错误

OpenGL FreeImage纹理加载错误
EN

Stack Overflow用户
提问于 2013-08-29 01:19:26
回答 1查看 460关注 0票数 1

目前,我的渲染工作,除了纹理渲染全黑。在这段代码中调用glTexture2D之后,我立即得到了错误1380或GL_INVALID_ENUM。我已经尝试了我能想到的所有方法,但错误不会消失。

在此代码块-Texture是2 (128 X 128)次幂-Using新的24位photoshop .bmp之前,photoshop get error

代码语言:javascript
复制
    glEnable(GL_TEXTURE_2D);

    FREE_IMAGE_FORMAT imageFormat = FreeImage_GetFileType(filename, 0);
    FIBITMAP* bmpImage = FreeImage_ConvertTo32Bits(FreeImage_Load(imageFormat, filename));

    int width = FreeImage_GetWidth(bmpImage);
    int height = FreeImage_GetHeight(bmpImage);
    int nBPP =  FreeImage_GetBPP(bmpImage);

    if (nBPP == 32)
    {
        // Generate an ID for the texture.
        glGenTextures(1, &m_texture);

        // Bind the texture as a 2D texture.
        glBindTexture(GL_TEXTURE_2D, m_texture);

        // Load the image data into the texture unit.
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)FreeImage_GetBits(bmpImage));

        if(auto temp = glGetError())
        {
            // GL_INVALID_ENUM/1380 here
        }
    }

    FreeImage_Unload(bmpImage);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
EN

回答 1

Stack Overflow用户

发布于 2013-09-03 21:41:22

你说图像是24位的,但在你的代码中你写道:

if (nBPP == 32)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18494309

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档