Hi,
My program is very simple:
no complicated equations, 1 light source,
while(1) loop with RenderScene() inside.
But I think I found a problem I set polygon mode to glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) and I had 80 FPS!!! I checked the texture files one of them I’m using only is 1024x1024 bmp file !!! I think that texture slows down my program but I’m not sure that it is only this one reason. I’m sure that the problem is in texture mapping. I should experiment with texture parameters and environment. Maybe something is wrong with loading a texture and later it slows down my program? I don’t know that’s why I’m placing my loading code, If somebody can tell that is that something wrong I’ll be grateful.
AUX_RGBImageRec* LoadBMP(char *path)
{
FILE *file = NULL;
char errInfo[100];
file = fopen(path,“r”);
if (!path)
{
strcpy(errInfo,"Nie mozna odnalezc pliku: ");
strcat(errInfo, path);
MessageBox(NULL, errInfo,“Blad”, MB_OK);
return NULL;
}
// if file exists
if (file)
{
fclose(file);
return auxDIBImageLoad(path);
}
strcpy(errInfo,"Nie mozna zaladowac pliku: ");
strcat(errInfo, path);
MessageBox(NULL,errInfo,“Blad”,MB_OK);
return NULL;
}
// loads a texture BMP
AUX_RGBImageRec* LoadTexBMP(char *FileName)
{
char path[100] ;
strcpy(path, TEX_PATH);
strcat(path, FileName);
return LoadBMP(path);
}
void LoadTextures()
{
AUX_RGBImageRec* TextureImage[MAX_TEXTURES];
for (int i=0; i < MAX_TEXTURES; i++) TextureImage[i] = NULL;
memset(TextureImage,0,sizeof(void *)*MAX_TEXTURES);
TextureImage[TEX_FLOOR_OUT] = LoadTexBMP(“floor001.bmp”);
TextureImage[TEX_FLOOR_IN] = LoadTexBMP(“floor01.bmp”);
TextureImage[TEX_CEIL_OUT] = LoadTexBMP(“ceil02.bmp”);
TextureImage[TEX_WALL_OUT] = LoadTexBMP(“wall02.bmp”);
TextureImage[TEX_WIN] = LoadTexBMP(“win01.bmp”);
// load fonts
TextureImage[TEX_FONT_01] = LoadFontBMP(“font01.bmp”);
glGenTextures(MAX_TEXTURES, &textureArray[0]);
for (i=0; i<MAX_TEXTURES; i++)
// this is a guard
// if any texture pointer doesn’t exists this
// will protect the program before crash
if (TextureImage[i])
{
glBindTexture(GL_TEXTURE_2D, textureArray[i]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[i]->sizeX, TextureImage[i]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[i]->data);
}
for (i=0; i<MAX_TEXTURES; i++)
{
if (TextureImage[i])
{
if (TextureImage[i]->data)
free(TextureImage[i]->data);
free(TextureImage[i]);
}
}
}