diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2017-12-10 20:38:26 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2018-04-07 17:11:45 +0300 |
commit | ddae098deec89d67228a74623ebe7f5db39f425b (patch) | |
tree | 87aa891c0447ce6db35bd4676ff3a7cb2265e9cf /drivers/gles3/rasterizer_gles3.cpp | |
parent | ec110076caca7a75ffb4795c32362bc52151dbcc (diff) |
Experimental support for windows with per-pixel transparency (macOS, X11 and Windows).
Diffstat (limited to 'drivers/gles3/rasterizer_gles3.cpp')
-rw-r--r-- | drivers/gles3/rasterizer_gles3.cpp | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index ca39d9f966..5f57deef17 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -292,7 +292,11 @@ void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_c glViewport(0, 0, window_w, window_h); glDisable(GL_BLEND); glDepthMask(GL_FALSE); - glClearColor(p_color.r, p_color.g, p_color.b, 1.0); + if (OS::get_singleton()->get_window_per_pixel_transparency_enabled()) { + glClearColor(0.0, 0.0, 0.0, 0.0); + } else { + glClearColor(p_color.r, p_color.g, p_color.b, 1.0); + } glClear(GL_COLOR_BUFFER_BIT); canvas->canvas_begin(); @@ -331,6 +335,27 @@ void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_c storage->free(texture); // free since it's only one frame that stays there + if (OS::get_singleton()->is_layered_allowed()) { + if (OS::get_singleton()->get_window_per_pixel_transparency_enabled()) { +#ifdef WINDOWS_ENABLED + Size2 wndsize = OS::get_singleton()->get_layered_buffer_size(); + uint8_t *data = OS::get_singleton()->get_layered_buffer_data(); + if (data) { + glReadPixels(0, 0, wndsize.x, wndsize.y, GL_BGRA, GL_UNSIGNED_BYTE, data); + OS::get_singleton()->swap_layered_buffer(); + + return; + } +#endif + } else { + //clear alpha + glColorMask(false, false, false, true); + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + glColorMask(true, true, true, true); + } + } + OS::get_singleton()->swap_buffers(); } @@ -367,6 +392,27 @@ void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target, const Re void RasterizerGLES3::end_frame(bool p_swap_buffers) { + if (OS::get_singleton()->is_layered_allowed()) { + if (OS::get_singleton()->get_window_per_pixel_transparency_enabled()) { +#ifdef WINDOWS_ENABLED + Size2 wndsize = OS::get_singleton()->get_layered_buffer_size(); + uint8_t *data = OS::get_singleton()->get_layered_buffer_data(); + if (data) { + glReadPixels(0, 0, wndsize.x, wndsize.y, GL_BGRA, GL_UNSIGNED_BYTE, data); + OS::get_singleton()->swap_layered_buffer(); + + return; + } +#endif + } else { + //clear alpha + glColorMask(false, false, false, true); + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + glColorMask(true, true, true, true); + } + } + if (p_swap_buffers) OS::get_singleton()->swap_buffers(); else |