Implement black margins in GLES2, which was missing, fixes #24556
This commit is contained in:
parent
6af8b7c955
commit
ee3eadf345
1 changed files with 58 additions and 0 deletions
|
@ -1733,6 +1733,64 @@ void RasterizerCanvasGLES2::draw_lens_distortion_rect(const Rect2 &p_rect, float
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_image) {
|
void RasterizerCanvasGLES2::draw_window_margins(int *black_margin, RID *black_image) {
|
||||||
|
|
||||||
|
Vector2 window_size = OS::get_singleton()->get_window_size();
|
||||||
|
int window_h = window_size.height;
|
||||||
|
int window_w = window_size.width;
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, storage->system_fbo);
|
||||||
|
glViewport(0, 0, window_size.width, window_size.height);
|
||||||
|
canvas_begin();
|
||||||
|
|
||||||
|
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));
|
||||||
|
} else if (black_margin[MARGIN_LEFT]) {
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
|
||||||
|
|
||||||
|
draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
} else if (black_margin[MARGIN_RIGHT]) {
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
|
||||||
|
|
||||||
|
draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (black_image[MARGIN_TOP].is_valid()) {
|
||||||
|
_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));
|
||||||
|
|
||||||
|
} else if (black_margin[MARGIN_TOP]) {
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
|
||||||
|
|
||||||
|
draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (black_image[MARGIN_BOTTOM].is_valid()) {
|
||||||
|
|
||||||
|
_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));
|
||||||
|
|
||||||
|
} else if (black_margin[MARGIN_BOTTOM]) {
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
|
||||||
|
|
||||||
|
draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, 1, 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerCanvasGLES2::initialize() {
|
void RasterizerCanvasGLES2::initialize() {
|
||||||
|
|
Loading…
Reference in a new issue