load Texture problem

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;



What hardware are you using?

What are the dimensions of your texture?

Are you getting any errors? (glGetError)

Assuming you have a hw accelerated context, really slow performance in light rendering situations usually indicates a software path, which is usually the result of an improper combination of OpenGL state.


Are you using auxDIBImageLoad??

If I remember correctly those aux functions have memory leaks, that could be the problem but I’m not sure.

1.Are you sure you call loadGLTextures only once?
2.What is your GPU and what is the size of texture? (perhaps you’re using NPOT texture that is not supported by your GPU)

Are you running this function every frame, because if you do then don’t, you only need to use glBindTexture( GL_TEXTURE_2D, texture[0]);

it seems to be working ok in my home computer. I have 6600GT video card here. and yes i am using that function only once at the constructor. thanks all of you.