问题:我一直试图弄清楚我在glTexSubImage3D
时遇到的这个错误。 VS2010抛出错误:glTexSubImage3D: identifier not found
用法:我正在尝试创建一个3D纹理,其中包含沿z维度放置的十个切片(图像)。它类似于这篇文章中的问题:C++ - place multiple images in an array pointer
但是,我一直在尝试使用glTexSubImage3D以避免这些访问冲突错误。
我已将glext.h
包含在我的项目中,因为glTexImage3D
不是OpenGL库的一部分,我使用了提供的函数指针PFNGLTEXIMAGE3DPROC glTexImage3D
:{{3 }}
代码:
我一直在关注NeHe的纹理映射教程和体积渲染教程:http://content.gpwiki.org/index.php/OpenGL:Tutorials:3D_Textures
GLuint m_nTexId;
unsigned char *tex;
int h = 1024;
int w = 256;
int slices = 10;
PFNGLTEXIMAGE3DPROC glTexImage3D = (PFNGLTEXIMAGE3DPROC) wglGetProcAddress("glTexImage3D");
int LoadGLTextures()
{
glGenTextures(1,(GLuint*)&m_nTexId );
if(m_nTexId == 0)
return false;
glBindTexture( GL_TEXTURE_3D, m_nTexId );
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, w, h , slices, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
tex = (unsigned char *)SOIL_load_image("Data/PA_170090.png", &w, &h, NULL, 0);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, h, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) tex);
tex = (unsigned char*) SOIL_load_image("Data/PA_170091.png", &w, &h, NULL, 0);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 1, h, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) tex);
tex = (unsigned char *)SOIL_load_image("Data/PA_170092.png", &w, &h, NULL, 0);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 2, h, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) tex);
tex = (unsigned char *)SOIL_load_image("Data/PA_170093.png", &w, &h, NULL, 0);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 3, h, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) tex);
tex = (unsigned char *)SOIL_load_image("Data/PA_170094.png", &w, &h, NULL, 0);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 4, h, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) tex);
tex = (unsigned char *)SOIL_load_image("Data/PA_170095.png", &w, &h, NULL, 0);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 5, h, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) tex);
tex = (unsigned char*) SOIL_load_image("Data/PA_170096.png", &w, &h, NULL, 0);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 6, h, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) tex);
tex = (unsigned char*) SOIL_load_image("Data/PA_170097.png", &w, &h, NULL, 0);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 7, h, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) tex);
tex = (unsigned char*) SOIL_load_image("Data/PA_170098.png", &w, &h, NULL, 0);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 8, h, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) tex);
tex = (unsigned char*) SOIL_load_image("Data/PA_170099.png", &w, &h, NULL, 0);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 9, h, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) tex);
//glBindTexture( GL_TEXTURE_3D, 0 );
return true;
}
答案 0 :(得分:1)
问题与您最初尝试使用glTexImage3D (...)
时的问题相同。也就是说,3D纹理是OpenGL 1.2的一个特性,而Windows只为您提供OpenGL 1.1而无需运行时扩展。
您需要像glTexSubImage3D (...)
一样加载glTexImage3D (...)
功能。
PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D =
(PFNGLTEXSUBIMAGE3DPROC) wglGetProcAddress("glTexSubImage3D");