Advertisement

Loading BMP's from resource files

Started by April 03, 2001 07:57 PM
0 comments, last by trigger 23 years, 10 months ago
hi! I am wondering if there is a way to load BMP''s with less than 16 bit colordepth!? is there any way? the following code works only with 16 bit BMP''s:
  
int LoadGLTextures()		
{
	HBITMAP hBMP;
	BITMAP	BMP;

	int	loop = 0;
	int	Status = TRUE;
	byte	Texture[]={IDB_LOGO, IDB_EXTRASHIP};

	glGenTextures(sizeof(Texture), &texture[0]);

	for (loop = 0; loop < sizeof(Texture); loop++)
	{
		hBMP = (HBITMAP)LoadImage(GetModuleHandle (NULL),MAKEINTRESOURCE(Texture[loop]), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);

		if (hBMP)
		{
			GetObject(hBMP,sizeof(BMP), &BMP);
			glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
			glBindTexture(GL_TEXTURE_2D, texture[loop]);
			if ((loop > 6) && (loop < 11) || (loop == 12))
			{
				glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
				glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
				glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
			}
			else
			{
				glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
				glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
				gluBuild2DMipmaps(GL_TEXTURE_2D, 3, BMP.bmWidth, BMP.bmHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
			}
		}
		else
		{
			Status=FALSE;
		}
	}
	return Status;
}

  
Does anybody know how to change it so that i can load BMP''s with less then 16 bit colordepth?? thanx... cu trigger// axion demo division
http://trigger.xenyon.net/
Maybe you can create a tmp. 24-bit bitmap and use BitBlt to copy
the 8-bit bitmap to the new 24-bitmap.

This topic is closed to new replies.

Advertisement