hi
here is a piece of code that should check for all the screen, and is faster than the previous code (stops checking after finding a pixel that is not black), but it seems to bug, if you could correct it :p
// [ fix for Fragile by kamui_kun ...
bool Renderer::IsBlack()
{
char pixels [3];
int x, y;
for(x = 0; x < (int) OpenGL_GetBackbufferHeight(); x++)
{
for(y = 0; y < (int) OpenGL_GetBackbufferWidth(); y++)
{
glReadPixels(x, y, 1, 1, GL_RED, GL_BYTE, &pixels[0]);
glReadPixels(x, y, 1, 1, GL_GREEN, GL_BYTE, &pixels[1]);
glReadPixels(x, y, 1, 1, GL_BLUE, GL_BYTE, &pixels[2]);
if((pixels[0] != 0) || (pixels[1] != 0) || (pixels[2] != 0)) return false;
}
}
return true;
}
void Renderer::SwapBuffers()
{
// [ fix for Fragile by kamui_kun ...
bool pass = false;
if(Renderer::IsBlack()) pass = true;
// ...]
...
if (!pass) OpenGL_SwapBuffers();
...
here is a piece of code that should check for all the screen, and is faster than the previous code (stops checking after finding a pixel that is not black), but it seems to bug, if you could correct it :p
// [ fix for Fragile by kamui_kun ...
bool Renderer::IsBlack()
{
char pixels [3];
int x, y;
for(x = 0; x < (int) OpenGL_GetBackbufferHeight(); x++)
{
for(y = 0; y < (int) OpenGL_GetBackbufferWidth(); y++)
{
glReadPixels(x, y, 1, 1, GL_RED, GL_BYTE, &pixels[0]);
glReadPixels(x, y, 1, 1, GL_GREEN, GL_BYTE, &pixels[1]);
glReadPixels(x, y, 1, 1, GL_BLUE, GL_BYTE, &pixels[2]);
if((pixels[0] != 0) || (pixels[1] != 0) || (pixels[2] != 0)) return false;
}
}
return true;
}
void Renderer::SwapBuffers()
{
// [ fix for Fragile by kamui_kun ...
bool pass = false;
if(Renderer::IsBlack()) pass = true;
// ...]
...
if (!pass) OpenGL_SwapBuffers();
...