Hello there, i have a load texture routine, it seems to be working but the problem is that, if i call function anywhere in the program ( not necessary in main loop ), the cpu goes way up, program is really sluggish and frame rate goes down to 2 - 5 fps. anybody has clue what’s going on. below is the code.
size of bmp is 34KB
int loadGLTextures()
{
int status = 0;
AUX_RGBImageRec* TextureImage[1];//create storage space for the texture
memset( TextureImage, 0, sizeof( void*)1 );//size of void 4
if( TextureImage[0] = loadBMP( "data/grass.bmp")){
status =1;
glGenTextures(1,&texture[0]);//create the texture
glBindTexture( GL_TEXTURE_2D, texture[0]);
glTexImage2D( GL_TEXTURE_2D, //2D texture
0, //level of detail,usually 0
3,//3 data components ie red data, green data, blue data
TextureImage[0]->sizeX,//bmp width
TextureImage[0]->sizeY, //bmp height
0,//border, usually 0
GL_RGB,//image consists of RGB
GL_UNSIGNED_BYTE,//data made up unsigned bytes
TextureImage[0]->data//actually data
);
//Following functions to stretch if image is smaller and filter if image is bigger
//GL_LINEAR for best result, however costly than GL_NEAREST
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);// Linear Filtering
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);// Linear Filtering
}
//Free resources
if( TextureImage[0] ) {
if( TextureImage[0]->data ) delete TextureImage[0]->data;
delete TextureImage[0];
}
return status;
}