Hi all.
I wanted to create a scene with a sphere that reflects all objects in its environment.
My first step is now to set up the cube env mapping textures to the sphere but
my program always crashes, when i use my makeCubeMap() method. But i don’t know where
to put it either. I put it in my DrawGLScene() method but there must be something wrong.
It runs when it don’t use this command, but then i only see a white sphere with no
textures.
I hope somebody can help me.
Thanx
</font><blockquote><font size=“1” face=“Verdana, Arial”>code:</font><hr /><pre style=“font-size:x-small; font-family: monospace;”>AUX_RGBImageRec *LoadBMP(char *Filename)
{
FILE *File=NULL;
if(!Filename)
return NULL;
File=fopen(Filename,"r");
if(File)
{
fclose(File);
return auxDIBImageLoad(Filename);
}
return NULL;
}
int LoadGLTextures(GLenum target, char *filename)
{
int Status=FALSE;
AUX_RGBImageRec *TextureImage[1];
memset(TextureImage,0,sizeof(void *)*1);
if (mipmaps) {
gluBuild2DMipmaps(target, GL_RGB8, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
else
{
glTexImage2D(target, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
return Status;
}
void makeCubeMap(void)
{
int i;
for (i=0; i<6; i++)
{
LoadGLTextures(faceTarget[i], faceFile[i]);
}
if (mipmaps)
{
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
} else
{
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
glEnable(GL_TEXTURE_CUBE_MAP_EXT);
assert(mode == GL_NORMAL_MAP_EXT