【发布时间】:2018-02-18 23:16:45
【问题描述】:
我正在尝试将 mipmap 实现到 OpenGL 框架中。在尝试使用http://www.swiftless.com/tutorials/opengl/mipmap_generation.html 的教程后,我尝试了以下方法
for (int i=0;i<used_textures;i++)
{
//glEnable( GL_TEXTURE_2D );
GLGETERROR("Texture set up a");
glActiveTexture(GL_TEXTURE0+i);
glBindTexture(GL_TEXTURE_2D,texhandles[i]);//bind texture - assume all are 2D
GLGETERROR("Texture set up aa");
for (int d=0;d<global_textures[i].depth;d++)
{
switch(global_textures[i].comp)
{
//There are 4 cases in the actual code but case 3 is the only one that is used based on the data file.
case 3:
//REMOVED - glTexImage2D( GL_TEXTURE_2D, d, GL_RGB32F, global_textures[i].sx>>d, global_textures[i].sy>>d, 0, GL_RGB, GL_UNSIGNED_BYTE, global_textures[i].texMap[d] );
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, global_textures[i].sx >> d, global_textures[i].sy >> d, GL_RGB32F, GL_UNSIGNED_BYTE, global_textures[i].texMap[d]);
break;
}
}
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_LINEAR );
//REMOVED - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
//REMOVED - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
}
其中以 REMOVED - 开头的注释行是我根据 swiftless.com 教程删除到 minmap 的内容。获取错误代码正在创建this error window,在我看来,错误出现在 glActiveTexture 或 glBindTexture 行中,但我只是更改了代码。对于 gluBuild2DMipmaps 中的第二个参数,我尝试过使用 d、1、2、3 和 4,但我仍然不太确定这意味着什么。
谁能解释无效的枚举错误以及我需要在哪里解决这个问题?
【问题讨论】: