Work-around for no front buffer access on GLES.

Buffer swap now occurs after update but before render.
This commit is contained in:
Aloshi 2013-06-19 19:56:45 -05:00
parent 56569e5425
commit 5619674c55
2 changed files with 13 additions and 4 deletions

View file

@ -359,13 +359,20 @@ void ImageComponent::copyScreen()
{
unloadImage();
glReadBuffer(GL_FRONT);
int width = Renderer::getScreenWidth();
int height = Renderer::getScreenHeight();
//glReadBuffer(GL_FRONT);
/*char* data = new char[width*height*3];
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);*/
glGenTextures(1, &mTextureID);
glBindTexture(GL_TEXTURE_2D, mTextureID);
int width = Renderer::getScreenWidth();
int height = Renderer::getScreenHeight();
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
//delete[] data;
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, width, height, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

View file

@ -190,6 +190,7 @@ int main(int argc, char* argv[])
lastTime = curTime;
window.update(deltaTime);
Renderer::swapBuffers(); //swap here so we can read the last screen state during updates (see ImageComponent::copyScreen())
window.render();
if(Settings::getInstance()->getBool("DRAWFRAMERATE"))
@ -221,9 +222,10 @@ int main(int argc, char* argv[])
sleeping = true;
timeSinceLastEvent = 0;
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000A0);
Renderer::swapBuffers();
}
Renderer::swapBuffers();
Log::flush();
}