I posted recently a topic where I had some questions about light but now after that being resolved there is another thing.After pressing a certain key Moon rotates around Earth (my scene is about that)but in a few moments the memory starts to leak.My first guess is that I’m doing something wrong with textures so here is that part of the code:
void Texture()
{
glGenTextures(2,tekstura);
if(!glIsTexture(tekstura[0]))
{
glBindTexture(GL_TEXTURE_2D,tekstura[0]);
//AUX_RGBImageRec *teximage;
memset(teximage,0,sizeof(void *)*1);
teximage[0] = auxDIBImageLoad("Earth1.bmp");
glPixelStoref(GL_UNPACK_ALIGNMENT,1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, teximage[0]->sizeX,
teximage[0]->sizeY,0, GL_RGB,GL_UNSIGNED_BYTE,teximage[0]->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
free(teximage[0]->data);
free(teximage[0]);
}
if(!glIsTexture(tekstura[1]))
{
glBindTexture(GL_TEXTURE_2D,tekstura[1]);
//AUX_RGBImageRec *teximage;
memset(teximage,0,sizeof(void *)*1);
teximage[1] = auxDIBImageLoad("MoonMap.bmp");
glPixelStoref(GL_UNPACK_ALIGNMENT,1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, teximage[1]->sizeX,
teximage[1]->sizeY,0, GL_RGB,GL_UNSIGNED_BYTE,teximage[1]->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
free(teximage[1]->data);
free(teximage[1]);
}
}
Maybe there is something wrong there?