我有一個問題,關於在opengl(手動)渲染位圖文件: 如何從無符號字符指針獲取數據以便在glDrawPixels函數中使用它們? (無符號字符* bitmap_Image)C++類的私有成員
class bitmap
{
private:
unsigned long BPP;
unsigned long width;
unsigned long height;
unsigned long size;
unsigned char *bitmap_Image; // how use this member??
unsigned int bps;
public:
bitmap();
~bitmap();
bool Load(const char *filename);
#pragma pack(push,1)
typedef struct
{
WORD bfType;
DWORD bfSize;
DWORD bfReserved;
DWORD bfOffBits;
}BITMAPFILEHEADER;
//BITMAPINFOHEADER
typedef struct
{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
}BITMAPINFOHEADER;
#pragma pack(pop)
BITMAPFILEHEADER FileHeader;
BITMAPINFOHEADER InfoHeader;
};
太感謝你了 –
我會想辦法讓這個常數函數(也返回指向常量數據的指針) – datenwolf
@datenwolf:起初我只是不確定glDrawPixels參數(const或非const),現在我查找了文檔並將const修飾符添加到GetImageData中。 –