Click here to Skip to main content
15,881,600 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: What wrong with this loop? Pin
Andrew Brock14-Jan-11 21:10
Andrew Brock14-Jan-11 21:10 
AnswerRe: What wrong with this loop? Pin
jixuduxing14-Jan-11 22:37
jixuduxing14-Jan-11 22:37 
GeneralRe: What wrong with this loop? Pin
Andrew Brock14-Jan-11 23:39
Andrew Brock14-Jan-11 23:39 
AnswerRe: What wrong with this loop? Pin
cp987614-Jan-11 23:49
cp987614-Jan-11 23:49 
AnswerRe: What wrong with this loop? Pin
Richard MacCutchan15-Jan-11 0:02
mveRichard MacCutchan15-Jan-11 0:02 
AnswerRe: What wrong with this loop? Pin
CPallini15-Jan-11 2:39
mveCPallini15-Jan-11 2:39 
AnswerRe: What wrong with this loop? Pin
yu-jian15-Jan-11 3:43
yu-jian15-Jan-11 3:43 
Question(OpenGL/MFC/Win32) glReadPixels and CreateBitmap question... Pin
Maximilien14-Jan-11 7:57
Maximilien14-Jan-11 7:57 
Facing an uphill batte against OpenGL vs. Vista/Win7 ...

Seems we cannot use GDI to BitBlt to do a screenshot when Aero is turned on.

Reading a lot on the web (opengl.org,gamedev.net, ...) about this, it looks like I need to use glReadPixels to get the RGB(A) values from the OpenGL buffer.

The issue is that I'm not certain how to transfer the resulting pixel array ( RGB(A) ) to something that Windows can use.

	glPushAttrib(GL_PIXEL_MODE_BIT);
	glReadBuffer(GL_FRONT);

	glFlush(); 
	glFinish();

	unsigned char *glBuffer = new unsigned char [width*height*4];
	ASSERT( glBuffer) ;

	glPixelStorei(GL_PACK_ALIGNMENT, 1);
	glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, glBuffer);

        /// transmorgrify because of different format between opengl and windows
	unsigned char* Buffer = new unsigned char [width*height*3];
	unsigned char* ptmp = Buffer;
	unsigned char* pbuffer = glBuffer;
	for (int j=0; j<height; j++)
	{
		for (int i=0;i<width; i++)
		{
			*ptmp++ = *pbuffer++;
			*ptmp++ = *pbuffer++;
			*ptmp++ = *pbuffer++;
			pbuffer++;
		}
	}
	delete [] glBuffer;

	HBITMAP hBitmap= ::CreateBitmap(width, height, 3, 24, Buffer);
	ASSERT( hBitmap);

///...


The array returns by glReadPixels looks ok, but creating the bitmap returns a NULL handle; at first, even if it did not work, I half expected to have a corrupted bitmap, but not just a NULL.

I'm certainly missing a lot of things, but I'm not certain what; probably mixing up context and some things ... all that I can find is that people say use glReadPixels and it works!

Any idea ?
Thanks.

Max.
Watched code never compiles.

AnswerRe: (OpenGL/MFC/Win32) glReadPixels and CreateBitmap question... Pin
User 742933814-Jan-11 10:03
professionalUser 742933814-Jan-11 10:03 
QuestionString Problem Pin
john563214-Jan-11 1:22
john563214-Jan-11 1:22 
AnswerRe: String Problem Pin
Stephen Hewitt14-Jan-11 1:34
Stephen Hewitt14-Jan-11 1:34 
AnswerRe: String Problem Pin
Maximilien14-Jan-11 1:59
Maximilien14-Jan-11 1:59 
Questioncreate dimmed icon with magick++ (ImageMagick) Pin
Thue Andersen13-Jan-11 22:10
Thue Andersen13-Jan-11 22:10 
AnswerRe: create dimmed icon with magick++ (ImageMagick) Pin
Chris Losinger14-Jan-11 3:04
professionalChris Losinger14-Jan-11 3:04 
AnswerRe: create dimmed icon with magick++ (ImageMagick) [modified] Pin
User 742933814-Jan-11 11:33
professionalUser 742933814-Jan-11 11:33 
GeneralRe: create dimmed icon with magick++ (ImageMagick) Pin
Thue Andersen16-Jan-11 5:00
Thue Andersen16-Jan-11 5:00 
GeneralRe: create dimmed icon with magick++ (ImageMagick) Pin
Rozis18-Jan-11 8:08
Rozis18-Jan-11 8:08 
GeneralRe: create dimmed icon with magick++ (ImageMagick) Pin
Thue Andersen18-Jan-11 22:13
Thue Andersen18-Jan-11 22:13 
QuestionIsalpha Function Issue. Pin
Mike Certini13-Jan-11 18:00
Mike Certini13-Jan-11 18:00 
AnswerRe: Isalpha Function Issue. Pin
Cool_Dev13-Jan-11 18:11
Cool_Dev13-Jan-11 18:11 
GeneralRe: Isalpha Function Issue. Pin
Andrew Brock13-Jan-11 18:15
Andrew Brock13-Jan-11 18:15 
GeneralRe: Isalpha Function Issue. Pin
Mike Certini13-Jan-11 18:28
Mike Certini13-Jan-11 18:28 
AnswerRe: Isalpha Function Issue. Pin
Luc Pattyn14-Jan-11 0:56
sitebuilderLuc Pattyn14-Jan-11 0:56 
GeneralRe: Isalpha Function Issue. Pin
Mike Certini13-Jan-11 18:28
Mike Certini13-Jan-11 18:28 
AnswerRe: Isalpha Function Issue. Pin
Richard MacCutchan13-Jan-11 22:00
mveRichard MacCutchan13-Jan-11 22:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.