niyodanie
07-21-2012, 03:30 PM
Hi everyone,
I'm trying to implement a really fast method of pixel change detection.
This has two main parts: capturing and comparing screenshots.
For capturing:
I'm using PBO so that glReadPixels() will return after the call.
Extract of this part of the code is here:
if(pboUsed){ //with PBO
// OpenGL performs asynch DMA transfer, so glReadPixels() will return immediately.
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,pboIds[index]);
glReadPixels(posx,posy,500,500, GL_BGR_EXT, GL_UNSIGNED_BYTE,0);// posx and posy are given by the mouse position
GLubyte* screenshot = (GLubyte*)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
//ptr does now point to my screenshot..}
For two screenshots, I'll basically have two GLubyte* screenshot1 and screenshot2
For comparison :
I tried to use simple and efficient memcmp: memcmp(screenshot1,screenshot2,500*500*3) but it doesn't always detect differences.
And I'd like to detect any single pixel color change.
Are there any OGL methods that can help me achieve this ?
Thanks
I'm trying to implement a really fast method of pixel change detection.
This has two main parts: capturing and comparing screenshots.
For capturing:
I'm using PBO so that glReadPixels() will return after the call.
Extract of this part of the code is here:
if(pboUsed){ //with PBO
// OpenGL performs asynch DMA transfer, so glReadPixels() will return immediately.
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB,pboIds[index]);
glReadPixels(posx,posy,500,500, GL_BGR_EXT, GL_UNSIGNED_BYTE,0);// posx and posy are given by the mouse position
GLubyte* screenshot = (GLubyte*)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
//ptr does now point to my screenshot..}
For two screenshots, I'll basically have two GLubyte* screenshot1 and screenshot2
For comparison :
I tried to use simple and efficient memcmp: memcmp(screenshot1,screenshot2,500*500*3) but it doesn't always detect differences.
And I'd like to detect any single pixel color change.
Are there any OGL methods that can help me achieve this ?
Thanks