注册 登录
编程论坛 C# 论坛

openGL管理纹理对象

zzllvlv 发布于 2017-08-19 20:39, 2046 次点击
蓝宝书上生成三个mip贴图的代码如下:
for(iLoop = 0; iLoop < TEXTURE-COUNT; iLoop++)
        {
        // Bind to next texture object
        glBindTexture(GL_TEXTURE_2D, textures[iLoop]);
        
        // Load texture, set filter and wrap modes
        pBytes = gltReadTGABits(szTextureFiles[iLoop],&iWidth, &iHeight,
                              &iComponents, &eFormat);

        // Load texture, set filter and wrap modes
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        glTexImage2D(GL_TEXTURE_2D, 0, iComponents, iWidth, iHeight, 0, eFormat, GL_UNSIGNED_BYTE, pBytes);
        glGenerateMipmap(GL_TEXTURE_2D);
        // Don't need original texture data any more
        free(pBytes);
        }
                示例代码通过不断的调用 glBindTexture(GL_TEXTURE_2D, textures[i])来使用这三个纹理对像。我想知道这三个纹理对象是如何管理的。是在GL_TEXTURE_2D这个变量中分别储存多个纹理,并通过纹理对象名来调用的吗?
0 回复
1