Hi i tryed glReadPixels with 256 … but it doesnt work … i get the same picture…and i have tryed GL_FONT and GL_BACK … its still the same … I think its a problem with
glReadPixels(…GL_RGB …) , i think it must be GL_BGR ???
The complete codes is the following …
int Out::uebergabe(int x, int y, int Width, int Height, const char *fname)
{
BITMAPFILEHEADER bf;
BITMAPINFOHEADER bi;
unsigned char *image = (unsigned char*)malloc(sizeof(unsigned char)*Width*Height*3);
FILE *file = fopen(fname, "wb");
if( image!=NULL )
{
if( file!=NULL )
{
int* viewport = new int[4];
glGetIntegerv( GL_VIEWPORT, viewport);
void* image = malloc(3 * viewport[2] * viewport[3]);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, viewport[2], viewport[3], GL_RGB, GL_UNSIGNED_BYTE, image);
char buff[400];
sprintf(buff,"Results: %f %f
",viewport[2],viewport[3] );
msgout(“Result”, buff);
memset( &bf, 0, sizeof( bf ) );
memset( &bi, 0, sizeof( bi ) );
bf.bfType = 'MB';
bf.bfSize = sizeof(bf)+sizeof(bi)+Width*Height*3;
bf.bfOffBits = sizeof(bf)+sizeof(bi);
bi.biSize = sizeof(bi);
bi.biWidth = Width;
bi.biHeight = Height;
bi.biPlanes = 1;
bi.biBitCount = 24;
bi.biSizeImage = Width*Height*3;
fwrite( &bf, sizeof(bf), 1, file );
fwrite( &bi, sizeof(bi), 1, file );
fwrite( image, sizeof(unsigned char), Height*Width*3, file );
fclose( file );
}
free( image );
}
return 0;
}