Hello cocos2d- community,
i would like to get all pixels with their color.
I put this in my draw() method:
for( int x=screenXStart; x<screenXEnd; x++ )
{
for( int y=screenYStart; y< screenYEnd; y++ )
{
glReadPixels(x,y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixelColor[0]);
if( (pixelColor[0] == 255) && (pixelColor[1] == 0) && (pixelColor[2] == 0) ) //RED
{
pixelColorCount++;
}
i++;
}
}
NSLog(@"There are %f red pixels!",pixelColorCount);
The problem is that i can only read the pixels that are shown on the screen ( x:0-320 and y:0-480 ). If i would like to read the pixels outside the screen - that are not visible to the user - i don't get the right one.
I test it with a red 320x480 picture on the position ccp( (320/2) + 320 , 480/2 ). It is not visible to the user but when i would read the pixels on that position i dont get that one ...
If i set my node to the position ccp( -(320) , 0 ) i am getting the right result - but that isn't what i want!