OpenGL 加载位图(BMP)贴图

GLuint Texture[1];
HBITMAP hBMP;
BITMAP BMP;

glGenTextures(1, &Texture[0]);
hBMP = (HBITMAP)LoadImage(NULL, L"xxx.bmp", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
if (!hBMP) return FALSE;
GetObject(hBMP, sizeof(BMP), &BMP);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glBindTexture(GL_TEXTURE_2D, Texture[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);

DeleteObject(hBMP);

 

posted @ 2014-08-29 20:03  idoublewei  阅读(1317)  评论(0编辑  收藏  举报