From 3305783bac9ce5408c5c28bf7afcc4a60e6e1d19 Mon Sep 17 00:00:00 2001 From: azagaya Date: Wed, 3 Jun 2020 18:33:33 -0300 Subject: [PATCH] Fixed images in black margins --- drivers/gles2/rasterizer_canvas_base_gles2.cpp | 12 ++++++++---- drivers/gles3/rasterizer_canvas_gles3.cpp | 13 +++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/gles2/rasterizer_canvas_base_gles2.cpp b/drivers/gles2/rasterizer_canvas_base_gles2.cpp index 5ecbcf0e137..37963eaf287 100644 --- a/drivers/gles2/rasterizer_canvas_base_gles2.cpp +++ b/drivers/gles2/rasterizer_canvas_base_gles2.cpp @@ -250,7 +250,8 @@ void RasterizerCanvasBaseGLES2::draw_window_margins(int *black_margin, RID *blac if (black_image[MARGIN_LEFT].is_valid()) { _bind_canvas_texture(black_image[MARGIN_LEFT], RID()); Size2 sz(storage->texture_get_width(black_image[MARGIN_LEFT]), storage->texture_get_height(black_image[MARGIN_LEFT])); - draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, sz.x, sz.y)); + draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), + Rect2(0, 0, (float)black_margin[MARGIN_LEFT] / sz.x, (float)(window_h) / sz.y)); } else if (black_margin[MARGIN_LEFT]) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); @@ -261,7 +262,8 @@ void RasterizerCanvasBaseGLES2::draw_window_margins(int *black_margin, RID *blac if (black_image[MARGIN_RIGHT].is_valid()) { _bind_canvas_texture(black_image[MARGIN_RIGHT], RID()); Size2 sz(storage->texture_get_width(black_image[MARGIN_RIGHT]), storage->texture_get_height(black_image[MARGIN_RIGHT])); - draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, sz.x, sz.y)); + draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), + Rect2(0, 0, (float)black_margin[MARGIN_RIGHT] / sz.x, (float)window_h / sz.y)); } else if (black_margin[MARGIN_RIGHT]) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); @@ -273,7 +275,8 @@ void RasterizerCanvasBaseGLES2::draw_window_margins(int *black_margin, RID *blac _bind_canvas_texture(black_image[MARGIN_TOP], RID()); Size2 sz(storage->texture_get_width(black_image[MARGIN_TOP]), storage->texture_get_height(black_image[MARGIN_TOP])); - draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, sz.x, sz.y)); + draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), + Rect2(0, 0, (float)window_w / sz.x, (float)black_margin[MARGIN_TOP] / sz.y)); } else if (black_margin[MARGIN_TOP]) { glActiveTexture(GL_TEXTURE0); @@ -287,7 +290,8 @@ void RasterizerCanvasBaseGLES2::draw_window_margins(int *black_margin, RID *blac _bind_canvas_texture(black_image[MARGIN_BOTTOM], RID()); Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM])); - draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, sz.x, sz.y)); + draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), + Rect2(0, 0, (float)window_w / sz.x, (float)black_margin[MARGIN_BOTTOM] / sz.y)); } else if (black_margin[MARGIN_BOTTOM]) { diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 71c85bc9728..07ccacba9c0 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -2143,7 +2143,9 @@ void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_im if (black_image[MARGIN_LEFT].is_valid()) { _bind_canvas_texture(black_image[MARGIN_LEFT], RID()); Size2 sz(storage->texture_get_width(black_image[MARGIN_LEFT]), storage->texture_get_height(black_image[MARGIN_LEFT])); - draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, sz.x, sz.y)); + + draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), + Rect2(0, 0, (float)black_margin[MARGIN_LEFT] / sz.x, (float)(window_h) / sz.y)); } else if (black_margin[MARGIN_LEFT]) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); @@ -2154,7 +2156,8 @@ void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_im if (black_image[MARGIN_RIGHT].is_valid()) { _bind_canvas_texture(black_image[MARGIN_RIGHT], RID()); Size2 sz(storage->texture_get_width(black_image[MARGIN_RIGHT]), storage->texture_get_height(black_image[MARGIN_RIGHT])); - draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, sz.x, sz.y)); + draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), + Rect2(0, 0, (float)black_margin[MARGIN_RIGHT] / sz.x, (float)window_h / sz.y)); } else if (black_margin[MARGIN_RIGHT]) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); @@ -2166,7 +2169,8 @@ void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_im _bind_canvas_texture(black_image[MARGIN_TOP], RID()); Size2 sz(storage->texture_get_width(black_image[MARGIN_TOP]), storage->texture_get_height(black_image[MARGIN_TOP])); - draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, sz.x, sz.y)); + draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), + Rect2(0, 0, (float)window_w / sz.x, (float)black_margin[MARGIN_TOP] / sz.y)); } else if (black_margin[MARGIN_TOP]) { glActiveTexture(GL_TEXTURE0); @@ -2180,7 +2184,8 @@ void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_im _bind_canvas_texture(black_image[MARGIN_BOTTOM], RID()); Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM])); - draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, sz.x, sz.y)); + draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), + Rect2(0, 0, (float)window_w / sz.x, (float)black_margin[MARGIN_BOTTOM] / sz.y)); } else if (black_margin[MARGIN_BOTTOM]) {