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);

 

你可能感兴趣的:(OpenGL)