Merge pull request #69581 from dsnopek/openxr-opengl-flip-screen
[opengl] Don't flip render target when blitting it to screen if it wasn't rendered upside down
This commit is contained in:
commit
09a128761a
1 changed files with 10 additions and 2 deletions
|
@ -285,6 +285,15 @@ void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, Display
|
||||||
|
|
||||||
ERR_FAIL_COND(!rt);
|
ERR_FAIL_COND(!rt);
|
||||||
|
|
||||||
|
// We normally render to the render target upside down, so flip Y when blitting to the screen.
|
||||||
|
bool flip_y = true;
|
||||||
|
if (rt->overridden.color.is_valid()) {
|
||||||
|
// If we've overridden the render target's color texture, that means we
|
||||||
|
// didn't render upside down, so we don't need to flip it.
|
||||||
|
// We're probably rendering directly to an XR device.
|
||||||
|
flip_y = false;
|
||||||
|
}
|
||||||
|
|
||||||
GLuint read_fbo = 0;
|
GLuint read_fbo = 0;
|
||||||
if (rt->view_count > 1) {
|
if (rt->view_count > 1) {
|
||||||
glGenFramebuffers(1, &read_fbo);
|
glGenFramebuffers(1, &read_fbo);
|
||||||
|
@ -296,10 +305,9 @@ void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, Display
|
||||||
|
|
||||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, GLES3::TextureStorage::system_fbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, GLES3::TextureStorage::system_fbo);
|
||||||
// Flip content upside down to correct for coordinates.
|
|
||||||
Vector2i screen_rect_end = p_screen_rect.get_end();
|
Vector2i screen_rect_end = p_screen_rect.get_end();
|
||||||
glBlitFramebuffer(0, 0, rt->size.x, rt->size.y,
|
glBlitFramebuffer(0, 0, rt->size.x, rt->size.y,
|
||||||
p_screen_rect.position.x, screen_rect_end.y, screen_rect_end.x, p_screen_rect.position.y,
|
p_screen_rect.position.x, flip_y ? screen_rect_end.y : p_screen_rect.position.y, screen_rect_end.x, flip_y ? p_screen_rect.position.y : screen_rect_end.y,
|
||||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
|
||||||
if (read_fbo != 0) {
|
if (read_fbo != 0) {
|
||||||
|
|
Loading…
Reference in a new issue