[QUOTE=GClements;1255959]Post all relevant code. Preferably a minimal, complete program.
Saying “I’m doing it like this tutorial, except I’m not actually doing it like that” doesn’t tell us anything useful.[/QUOTE]
I figured someone may have had a similar issue, but alright.
Loading the images:
const GLenum cubemapTargets[6] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, // Top
GL_TEXTURE_CUBE_MAP_NEGATIVE_X, // Left
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, // Front
GL_TEXTURE_CUBE_MAP_POSITIVE_X, // Right
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, // Back
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y // Bottom
};
const char *postfix[6] = {"up","lf","ft","rt","bk","dn"};
GLuint DDSLoader::LoadCubemap(const char *imgFile,DDSTextureInfo **texture)
{
std::string pathCache = FileManager::GetNormalizedPath(imgFile);
std::map<std::string,GLuint>::iterator i = m_texIds.find(pathCache);
if(i != m_texIds.end())
{
if(texture != NULL)
*texture = &m_textures[i->second];
return i->second;
}
GLuint textureID;
glGenTextures(1,&textureID);
glBindTexture(GL_TEXTURE_CUBE_MAP,textureID);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
std::string path = "materials/";
path += imgFile;
if(path.substr(path.length() -4) == ".dds")
path = path.substr(0,path.length() -4);
StringToLower(path);
for(unsigned int j=0;j<6;j++)
{
std::string subPath = path +postfix[j] +".dds";
const char *cPath = subPath.c_str();
nv_dds::CDDSImage img;
if(!img.load(cPath))
{
glDeleteTextures(1,&textureID);
DDSLOADER_ERR;
}
glCompressedTexImage2D(cubemapTargets[j],0,img.get_format(),img.get_width(),img.get_height(),0,img.get_size(),img);
for(int i=0;i<img.get_num_mipmaps();i++)
{
nv_dds::CSurface mipmap = img.get_mipmap(i);
glCompressedTexImage2D(cubemapTargets[j],i +1,img.get_format(),mipmap.get_width(),mipmap.get_height(),0,mipmap.get_size(),mipmap);
}
}
GLint width,height;
glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP,0,GL_TEXTURE_WIDTH,&width);
glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP,0,GL_TEXTURE_HEIGHT,&height);
DDSTextureInfo text;
text.ID = textureID;
text.width = width;
text.height = height;
m_texIds.insert(std::map<std::string,GLuint>::value_type(pathCache,textureID));
m_textures.insert(std::map<GLuint,DDSTextureInfo>::value_type(textureID,text));
if(texture != NULL)
*texture = &m_textures[textureID];
return textureID;
}
The nv_dds class stems from the nvidia SDK.
The rendering code is fairly wide-spread, it would be difficult to extract and post it in a compact form, but I believe the problem originates from the code above.