void BufferCanvas::Commit(Canvas &other) { assert(IsDefined()); assert(active); assert(GetWidth() == other.GetWidth()); assert(GetHeight() == other.GetHeight()); if (frame_buffer != NULL) { frame_buffer->Unbind(); /* restore the old viewport */ assert(OpenGL::translate == RasterPoint(0, 0)); OpenGL::SetupViewport(old_size); OpenGL::translate = old_translate; glPopMatrix(); /* copy frame buffer to screen */ CopyTo(other); } else { assert(offset == other.offset); /* copy screen to texture */ CopyToTexture(*texture, GetRect()); } active = false; }
void BufferCanvas::Commit(Canvas &other) { assert(IsDefined()); assert(active); assert(GetWidth() == other.GetWidth()); assert(GetHeight() == other.GetHeight()); if (frame_buffer != nullptr) { assert(OpenGL::translate.x == 0); assert(OpenGL::translate.y == 0); frame_buffer->Unbind(); /* restore the old viewport */ assert(OpenGL::translate == RasterPoint(0, 0)); #ifdef HAVE_GLES /* there's no glPopAttrib() on GL/ES; emulate it */ glViewport(old_viewport[0], old_viewport[1], old_viewport[2], old_viewport[3]); #else glPopAttrib(); #endif #ifdef USE_GLSL OpenGL::projection_matrix = old_projection_matrix; OpenGL::UpdateShaderProjectionMatrix(); #else glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); #endif OpenGL::translate = old_translate; OpenGL::viewport_size = old_size; #ifdef USE_GLSL glVertexAttrib4f(OpenGL::Attribute::TRANSLATE, OpenGL::translate.x, OpenGL::translate.y, 0, 0); #endif #ifdef SOFTWARE_ROTATE_DISPLAY OpenGL::display_orientation = old_orientation; #endif /* copy frame buffer to screen */ CopyTo(other); } else { assert(offset == other.offset); /* copy screen to texture */ CopyToTexture(*texture, GetRect()); } active = false; }