HBITMAP hBMP;//定义BMP头
BITMAP BMP;//BMP结构体
//byte Texture[]={IDB_BITMAP3};
byte Texture[]={IDB_BITMAP4};
glGenTextures(sizeof(Texture), &texture[0]);// Generate 6 Textures (sizeof(Texture)=6 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_MAG_FILTER,GL_LINEAR); // Linear Filtering
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); // Mipmap Linear Filtering
// Generate Mipmapped Texture (3 Bytes, Width, Height And Data From The BMP)
gluBuild2DMipmaps(GL_TEXTURE_2D,3,BMP.bmWidth,BMP.bmHeight,GL_BGR_EXT,GL_UNSIGNED_BYTE,BMP.bmBits);
DeleteObject(hBMP);// Delete The Bitmap Object
}
}
glClearColor(0.0f,0.0f,0.0f,1.0f);//清除背景颜色
glEnable(GL_TEXTURE_2D);//启用纹理模式
glEnable(GL_DEPTH_TEST);//启动深度测试
glMatrixMode(GL_PROJECTION);//投影
glLoadIdentity();