私は現在、OpenGL で簡単なスクリーン キャプチャ アプリケーションを作成しようとしています。私の現在のソースは次のようになります。
#include <Windows.h>
#include <iostream>
#include <gl/GL.h>
#include <fstream>
using namespace std;
void main()
{
int nWidth = 1920; // use these dimentions, We'll work work out a calculation to get the real dimentions later.
int nHeight = 1080;
unsigned char* buffer;//declair the buffer here plox
int size = nWidth*nHeight*3; //number of bytes the image will take up.
char input;
buffer = (GLubyte *)malloc(size); // acctually assign some RAM for the program
glReadBuffer ( GL_BACK ); //which buffer we are reading from.
glReadPixels ( 0, 0, nWidth, nHeight, GL_RGB, GL_UNSIGNED_BYTE,buffer);
const char* out=(const char*)buffer;
std::ofstream outfile ("out.crw",std::ifstream::binary);
outfile.write (out,size);
cout << out;
cin>> input;
return;
}
エラーは発生しません。ただし、GLReadPixels からの戻り値は、出力ファイルで何度も繰り返される文字 "í" です。「í」の 16 進値は「CD」、「CD」は色の値で赤 205 であるため、少なくとも色を出力するようです。
複数の色を含む画像を示す複数の値が返されることを期待していました。私は何を間違えましたか?