Can't get rid of gluBuild2DMipmaps (solved)

I’m using gluBuild2DMipmaps simply because glTexImage2D does not want to work. I tried everything. I followed this: http://www.opengl.org/wiki/Common_Mistakes

I have 24bpp .bmp in my windows form and load them this way:

GLuint texture[3];												// Storage For 3 Textures

void LoadGLTextures()											// Creates Textures From Bitmaps In The Resource File
{
	HBITMAP hBMP;												// Handle Of The Bitmap
	BITMAP	BMP;												// Bitmap Structure

	// The ID Of The 3 Bitmap Images We Want To Load From The Resource File
	byte	Texture[]={	IDB_FONT_NORMAL_1, IDB_FONT_LARGE_1 };

	glGenTextures(sizeof(Texture), &texture[0]);				// Generate 3 Textures (sizeof(Texture)=3 ID's)
	for (int loop=0; loop<sizeof(Texture); loop++)				// Loop Through All The ID's (Bitmap Images)
	{
		hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(Texture[loop]), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
		if (hBMP)												// Does The Bitmap Exist?
		{														// If So...
			GetObject(hBMP,sizeof(BMP), &BMP);					// Get The Object
																// hBMP: Handle To Graphics Object
																// sizeof(BMP): Size Of Buffer For Object Information
																// Buffer For Object Information
			glPixelStorei(GL_UNPACK_ALIGNMENT,4);				// Pixel Storage Mode (Word Alignment / 4 Bytes)
			glBindTexture(GL_TEXTURE_2D, texture[loop]);		// Bind Our Texture
			glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); 
			glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

			// Generate Mipmapped Texture (3 Bytes, Width, Height And Data From The BMP)
			gluBuild2DMipmaps(GL_TEXTURE_2D, 3, BMP.bmWidth, BMP.bmHeight, GL_BGR, GL_UNSIGNED_BYTE, BMP.bmBits);
			//glTexImage2D(GL_TEXTURE_2D,0,3,BMP.bmWidth,BMP.bmHeight,0,GL_BGR,GL_UNSIGNED_SHORT,BMP.bmBits);

			DeleteObject(hBMP);									// Delete The Bitmap Object
		}
	}
}

Help?

Nowadays, I believe it is preferrable to use glGenerateMipmapEXT(GL_TEXTURE_2D) instead to tell the driver/GPU to build MIPmaps.

However, let’s see how you were trying to populate the MIP levels of the texture via glTexImage2D. Then you won’t even need the MIPmap gen.

What do you mean “with does not want to work” exactly ?
Why do you want to do without gluBuild2DMipmaps, if you can not find a way to replace it ?
Did you check that bmWidth and bmHeight are within allowed bounds for your hardware ?
Do you check if your hardware accept NPOT textures ?

Read again the documentation about gluBuild2DMipmaps, to be sure to re-implement everything needed :
http://www.opengl.org/sdk/docs/man/xhtml/gluBuild2DMipmaps.xml

He does not need mipmap gen, as GL_NEAREST is already used for minification filter.

see below

Edit, I found it myself. It was this:

		glTexImage2D(GL_TEXTURE_2D,0,3,BMP.bmWidth,BMP.bmHeight,0,GL_BGR,GL_UNSIGNED_SHORT,BMP.bmBits);

To:

glTexImage2D(GL_TEXTURE_2D,0,3,BMP.bmWidth,BMP.bmHeight,0,GL_BGR,GL_UNSIGNED_BYTE,BMP.bmBits);

Sorry, for all the trouble. :frowning: