Fix gl error when cubemap faces are not found

This commit is contained in:
cholleme 2003-07-31 18:53:10 +00:00
parent 046322fa9f
commit 03993e69f1

View file

@ -1499,6 +1499,8 @@ int GL_LoadCubemapTexture (gltexture_t *glt)
texturemode = GL_RGBA;
}
glt->type = GL_TEXTURE_CUBE_MAP_ARB;
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, glt->texnum);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
@ -1508,10 +1510,14 @@ int GL_LoadCubemapTexture (gltexture_t *glt)
for (i = 0; i < 6; i++)
{
sprintf(filename,"%i%s.tga", glt->identifier, face_names[i]);
sprintf(filename,"%s%s.tga", glt->identifier, face_names[i]);
LoadTextureInPlace(filename, 4, (unsigned char*)&trans[0], &width, &height);
if ((width == 0) || (height == 0)) {
Con_Printf("Texture not found: %s\n",filename);
} else {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+i, 0, texturemode, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &trans[0]);
}
}
//glEnable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
@ -1586,8 +1592,12 @@ int GL_LoadCubeMap (int identifier)
{
sprintf(filename,"cubemaps/%i%s.tga", identifier, face_names[i]);
LoadTextureInPlace(filename, 4, (unsigned char*)&trans[0], &width, &height);
if ((width == 0) || (height == 0)) {
Con_Printf("Texture not found: %s\n",filename);
} else {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+i, 0, texturemode, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &trans[0]);
}
}
//glEnable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_CUBE_MAP_ARB);