2020-11-18 18:11:30 +00:00
|
|
|
/*************************************************************************/
|
2021-10-26 15:18:39 +00:00
|
|
|
/* rasterizer_gles3.cpp */
|
2020-11-18 18:11:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/*************************************************************************/
|
2022-01-03 20:27:34 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2020-11-18 18:11:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
#include "rasterizer_gles3.h"
|
2020-11-18 18:11:30 +00:00
|
|
|
|
2021-11-16 15:25:42 +00:00
|
|
|
#ifdef GLES3_ENABLED
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
#include "core/config/project_settings.h"
|
|
|
|
#include "core/os/os.h"
|
|
|
|
|
|
|
|
#define _EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242
|
|
|
|
#define _EXT_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243
|
|
|
|
#define _EXT_DEBUG_CALLBACK_FUNCTION_ARB 0x8244
|
|
|
|
#define _EXT_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245
|
|
|
|
#define _EXT_DEBUG_SOURCE_API_ARB 0x8246
|
|
|
|
#define _EXT_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247
|
|
|
|
#define _EXT_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248
|
|
|
|
#define _EXT_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249
|
|
|
|
#define _EXT_DEBUG_SOURCE_APPLICATION_ARB 0x824A
|
|
|
|
#define _EXT_DEBUG_SOURCE_OTHER_ARB 0x824B
|
|
|
|
#define _EXT_DEBUG_TYPE_ERROR_ARB 0x824C
|
|
|
|
#define _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D
|
|
|
|
#define _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E
|
|
|
|
#define _EXT_DEBUG_TYPE_PORTABILITY_ARB 0x824F
|
|
|
|
#define _EXT_DEBUG_TYPE_PERFORMANCE_ARB 0x8250
|
|
|
|
#define _EXT_DEBUG_TYPE_OTHER_ARB 0x8251
|
|
|
|
#define _EXT_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143
|
|
|
|
#define _EXT_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144
|
|
|
|
#define _EXT_DEBUG_LOGGED_MESSAGES_ARB 0x9145
|
|
|
|
#define _EXT_DEBUG_SEVERITY_HIGH_ARB 0x9146
|
|
|
|
#define _EXT_DEBUG_SEVERITY_MEDIUM_ARB 0x9147
|
|
|
|
#define _EXT_DEBUG_SEVERITY_LOW_ARB 0x9148
|
|
|
|
#define _EXT_DEBUG_OUTPUT 0x92E0
|
|
|
|
|
|
|
|
#ifndef GLAPIENTRY
|
|
|
|
#if defined(WINDOWS_ENABLED) && !defined(UWP_ENABLED)
|
|
|
|
#define GLAPIENTRY APIENTRY
|
|
|
|
#else
|
|
|
|
#define GLAPIENTRY
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2021-10-25 17:16:40 +00:00
|
|
|
#if !defined(IPHONE_ENABLED) && !defined(JAVASCRIPT_ENABLED)
|
2020-11-18 18:11:30 +00:00
|
|
|
// We include EGL below to get debug callback on GLES2 platforms,
|
|
|
|
// but EGL is not available on iOS.
|
|
|
|
#define CAN_DEBUG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(GLES_OVER_GL) && defined(CAN_DEBUG)
|
2021-10-26 15:18:39 +00:00
|
|
|
#include <GLES3/gl3.h>
|
|
|
|
#include <GLES3/gl3ext.h>
|
|
|
|
#include <GLES3/gl3platform.h>
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
#include <EGL/egl.h>
|
|
|
|
#include <EGL/eglext.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(MINGW_ENABLED) || defined(_MSC_VER)
|
|
|
|
#define strcpy strcpy_s
|
|
|
|
#endif
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
void RasterizerGLES3::begin_frame(double frame_step) {
|
2020-11-18 18:11:30 +00:00
|
|
|
frame++;
|
|
|
|
delta = frame_step;
|
|
|
|
|
2021-11-16 15:25:42 +00:00
|
|
|
time_total += frame_step;
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
double time_roll_over = GLOBAL_GET("rendering/limits/time/time_rollover_secs");
|
|
|
|
time_total = Math::fmod(time_total, time_roll_over);
|
|
|
|
|
2021-11-16 15:25:42 +00:00
|
|
|
storage.frame.time = time_total;
|
2020-11-18 18:11:30 +00:00
|
|
|
storage.frame.count++;
|
|
|
|
storage.frame.delta = frame_step;
|
|
|
|
|
|
|
|
storage.update_dirty_resources();
|
|
|
|
|
|
|
|
storage.info.render_final = storage.info.render;
|
|
|
|
storage.info.render.reset();
|
|
|
|
|
|
|
|
//scene->iteration();
|
|
|
|
}
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
void RasterizerGLES3::end_frame(bool p_swap_buffers) {
|
2020-11-18 18:11:30 +00:00
|
|
|
// if (OS::get_singleton()->is_layered_allowed()) {
|
|
|
|
// if (!OS::get_singleton()->get_window_per_pixel_transparency_enabled()) {
|
|
|
|
//clear alpha
|
|
|
|
// glColorMask(false, false, false, true);
|
|
|
|
// glClearColor(0.5, 0, 0, 1);
|
|
|
|
// glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
// glColorMask(true, true, true, true);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// glClearColor(1, 0, 0, 1);
|
|
|
|
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
|
|
|
|
2021-11-16 15:25:42 +00:00
|
|
|
if (p_swap_buffers) {
|
2020-11-18 18:11:30 +00:00
|
|
|
DisplayServer::get_singleton()->swap_buffers();
|
2021-11-16 15:25:42 +00:00
|
|
|
} else {
|
2020-11-18 18:11:30 +00:00
|
|
|
glFinish();
|
2021-11-16 15:25:42 +00:00
|
|
|
}
|
2020-11-18 18:11:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CAN_DEBUG
|
|
|
|
static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const GLvoid *userParam) {
|
2022-01-27 16:34:33 +00:00
|
|
|
if (type == _EXT_DEBUG_TYPE_OTHER_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
return;
|
2022-01-27 16:34:33 +00:00
|
|
|
}
|
2020-11-18 18:11:30 +00:00
|
|
|
|
2022-01-27 16:34:33 +00:00
|
|
|
if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
return; //these are ultimately annoying, so removing for now
|
2022-01-27 16:34:33 +00:00
|
|
|
}
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
char debSource[256], debType[256], debSev[256];
|
|
|
|
|
2022-01-27 16:34:33 +00:00
|
|
|
if (source == _EXT_DEBUG_SOURCE_API_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debSource, "OpenGL");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (source == _EXT_DEBUG_SOURCE_WINDOW_SYSTEM_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debSource, "Windows");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (source == _EXT_DEBUG_SOURCE_SHADER_COMPILER_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debSource, "Shader Compiler");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (source == _EXT_DEBUG_SOURCE_THIRD_PARTY_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debSource, "Third Party");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (source == _EXT_DEBUG_SOURCE_APPLICATION_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debSource, "Application");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (source == _EXT_DEBUG_SOURCE_OTHER_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debSource, "Other");
|
2022-01-27 16:34:33 +00:00
|
|
|
}
|
2020-11-18 18:11:30 +00:00
|
|
|
|
2022-01-27 16:34:33 +00:00
|
|
|
if (type == _EXT_DEBUG_TYPE_ERROR_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debType, "Error");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (type == _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debType, "Deprecated behavior");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (type == _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debType, "Undefined behavior");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (type == _EXT_DEBUG_TYPE_PORTABILITY_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debType, "Portability");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debType, "Performance");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (type == _EXT_DEBUG_TYPE_OTHER_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debType, "Other");
|
2022-01-27 16:34:33 +00:00
|
|
|
}
|
2020-11-18 18:11:30 +00:00
|
|
|
|
2022-01-27 16:34:33 +00:00
|
|
|
if (severity == _EXT_DEBUG_SEVERITY_HIGH_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debSev, "High");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (severity == _EXT_DEBUG_SEVERITY_MEDIUM_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debSev, "Medium");
|
2022-01-27 16:34:33 +00:00
|
|
|
} else if (severity == _EXT_DEBUG_SEVERITY_LOW_ARB) {
|
2020-11-18 18:11:30 +00:00
|
|
|
strcpy(debSev, "Low");
|
2022-01-27 16:34:33 +00:00
|
|
|
}
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
String output = String() + "GL ERROR: Source: " + debSource + "\tType: " + debType + "\tID: " + itos(id) + "\tSeverity: " + debSev + "\tMessage: " + message;
|
|
|
|
|
|
|
|
ERR_PRINT(output);
|
|
|
|
}
|
2021-10-26 15:18:39 +00:00
|
|
|
#endif
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
typedef void (*DEBUGPROCARB)(GLenum source,
|
|
|
|
GLenum type,
|
|
|
|
GLuint id,
|
|
|
|
GLenum severity,
|
|
|
|
GLsizei length,
|
|
|
|
const char *message,
|
|
|
|
const void *userParam);
|
|
|
|
|
|
|
|
typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam);
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
void RasterizerGLES3::initialize() {
|
2021-09-26 23:07:10 +00:00
|
|
|
print_verbose("Using OpenGL video driver");
|
2020-11-18 18:11:30 +00:00
|
|
|
|
2022-03-12 11:19:59 +00:00
|
|
|
texture_storage.set_main_thread_id(Thread::get_caller_id());
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
#ifdef GLAD_ENABLED
|
|
|
|
if (!gladLoadGL()) {
|
|
|
|
ERR_PRINT("Error initializing GLAD");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef GLAD_ENABLED
|
|
|
|
if (OS::get_singleton()->is_stdout_verbose()) {
|
|
|
|
if (GLAD_GL_ARB_debug_output) {
|
|
|
|
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
2022-01-27 16:34:33 +00:00
|
|
|
glDebugMessageCallbackARB(_gl_debug_print, nullptr);
|
2020-11-18 18:11:30 +00:00
|
|
|
glEnable(_EXT_DEBUG_OUTPUT);
|
|
|
|
} else {
|
|
|
|
print_line("OpenGL debugging not supported!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // GLAD_ENABLED
|
|
|
|
|
|
|
|
// For debugging
|
|
|
|
#ifdef CAN_DEBUG
|
|
|
|
#ifdef GLES_OVER_GL
|
|
|
|
if (OS::get_singleton()->is_stdout_verbose() && GLAD_GL_ARB_debug_output) {
|
2022-01-27 16:34:33 +00:00
|
|
|
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_ERROR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
|
|
|
|
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
|
|
|
|
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
|
|
|
|
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PORTABILITY_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
|
|
|
|
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PERFORMANCE_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
|
|
|
|
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_OTHER_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
|
2020-11-18 18:11:30 +00:00
|
|
|
// glDebugMessageInsertARB(
|
|
|
|
// GL_DEBUG_SOURCE_API_ARB,
|
|
|
|
// GL_DEBUG_TYPE_OTHER_ARB, 1,
|
|
|
|
// GL_DEBUG_SEVERITY_HIGH_ARB, 5, "hello");
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (OS::get_singleton()->is_stdout_verbose()) {
|
|
|
|
DebugMessageCallbackARB callback = (DebugMessageCallbackARB)eglGetProcAddress("glDebugMessageCallback");
|
|
|
|
if (!callback) {
|
|
|
|
callback = (DebugMessageCallbackARB)eglGetProcAddress("glDebugMessageCallbackKHR");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (callback) {
|
|
|
|
print_line("godot: ENABLING GL DEBUG");
|
|
|
|
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
|
|
|
callback(_gl_debug_print, NULL);
|
|
|
|
glEnable(_EXT_DEBUG_OUTPUT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // GLES_OVER_GL
|
|
|
|
#endif // CAN_DEBUG
|
|
|
|
|
2021-09-26 23:07:10 +00:00
|
|
|
print_line("OpenGL Renderer: " + RS::get_singleton()->get_video_adapter_name());
|
2020-11-18 18:11:30 +00:00
|
|
|
storage.initialize();
|
|
|
|
canvas.initialize();
|
|
|
|
// scene.initialize();
|
|
|
|
|
|
|
|
// make sure the OS knows to only access the renderer from the main thread
|
|
|
|
OS::get_singleton()->set_render_main_thread_mode(OS::RENDER_MAIN_THREAD_ONLY);
|
|
|
|
}
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
RasterizerGLES3::RasterizerGLES3() {
|
2020-11-18 18:11:30 +00:00
|
|
|
canvas.storage = &storage;
|
|
|
|
canvas.scene_render = &scene;
|
2022-03-21 11:25:25 +00:00
|
|
|
//storage.canvas = &canvas;
|
2020-11-18 18:11:30 +00:00
|
|
|
//scene.storage = &storage;
|
2022-03-21 11:25:25 +00:00
|
|
|
//storage.scene = &scene;
|
2020-11-18 18:11:30 +00:00
|
|
|
}
|
|
|
|
|
2021-10-26 15:18:39 +00:00
|
|
|
void RasterizerGLES3::prepare_for_blitting_render_targets() {
|
2020-11-18 18:11:30 +00:00
|
|
|
}
|
|
|
|
|
2021-11-16 15:25:42 +00:00
|
|
|
void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, DisplayServer::WindowID p_screen, const Rect2 &p_screen_rect) {
|
2020-11-18 18:11:30 +00:00
|
|
|
ERR_FAIL_COND(storage.frame.current_rt);
|
|
|
|
|
2022-03-12 11:19:59 +00:00
|
|
|
GLES3::RenderTarget *rt = storage.render_target_owner.get_or_null(p_render_target);
|
2020-11-18 18:11:30 +00:00
|
|
|
ERR_FAIL_COND(!rt);
|
|
|
|
|
2021-11-16 15:25:42 +00:00
|
|
|
// TODO: do we need a keep 3d linear option?
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
if (rt->external.fbo != 0) {
|
2021-11-16 15:25:42 +00:00
|
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, rt->external.fbo);
|
2020-11-18 18:11:30 +00:00
|
|
|
} else {
|
2021-11-16 15:25:42 +00:00
|
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, rt->fbo);
|
2020-11-18 18:11:30 +00:00
|
|
|
}
|
2021-11-16 15:25:42 +00:00
|
|
|
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
|
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
|
|
|
|
glBlitFramebuffer(0, 0, rt->width, rt->height, 0, p_screen_rect.size.y, p_screen_rect.size.x, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
2020-11-18 18:11:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// is this p_screen useless in a multi window environment?
|
2021-10-26 15:18:39 +00:00
|
|
|
void RasterizerGLES3::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) {
|
2020-11-18 18:11:30 +00:00
|
|
|
// do this once off for all blits
|
|
|
|
storage.bind_framebuffer_system();
|
|
|
|
|
|
|
|
storage.frame.current_rt = nullptr;
|
|
|
|
|
|
|
|
for (int i = 0; i < p_amount; i++) {
|
|
|
|
const BlitToScreen &blit = p_render_targets[i];
|
|
|
|
|
|
|
|
RID rid_rt = blit.render_target;
|
|
|
|
|
|
|
|
Rect2 dst_rect = blit.dst_rect;
|
2021-11-16 15:25:42 +00:00
|
|
|
_blit_render_target_to_screen(rid_rt, p_screen, dst_rect);
|
2020-11-18 18:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-19 15:09:52 +00:00
|
|
|
void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
|
2022-01-27 16:34:33 +00:00
|
|
|
if (p_image.is_null() || p_image->is_empty()) {
|
2020-11-18 18:11:30 +00:00
|
|
|
return;
|
2022-01-27 16:34:33 +00:00
|
|
|
}
|
2020-11-18 18:11:30 +00:00
|
|
|
|
2022-01-19 15:09:52 +00:00
|
|
|
Size2i win_size = DisplayServer::get_singleton()->screen_get_size();
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
2022-01-19 15:09:52 +00:00
|
|
|
glViewport(0, 0, win_size.width, win_size.height);
|
2020-11-18 18:11:30 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glDepthMask(GL_FALSE);
|
2022-01-19 15:09:52 +00:00
|
|
|
if (false) {
|
|
|
|
// 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);
|
|
|
|
}
|
2020-11-18 18:11:30 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
|
|
canvas.canvas_begin();
|
|
|
|
|
2022-03-12 11:19:59 +00:00
|
|
|
RID texture = texture_storage.texture_create();
|
|
|
|
//texture_storage.texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_use_filter ? VS::TEXTURE_FLAG_FILTER : 0);
|
|
|
|
texture_storage._texture_allocate_internal(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), RenderingDevice::TEXTURE_TYPE_2D);
|
|
|
|
texture_storage.texture_set_data(texture, p_image);
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height());
|
|
|
|
Rect2 screenrect;
|
2022-01-19 15:09:52 +00:00
|
|
|
if (p_scale) {
|
|
|
|
if (win_size.width > win_size.height) {
|
|
|
|
//scale horizontally
|
|
|
|
screenrect.size.y = win_size.height;
|
|
|
|
screenrect.size.x = imgrect.size.x * win_size.height / imgrect.size.y;
|
|
|
|
screenrect.position.x = (win_size.width - screenrect.size.x) / 2;
|
2020-11-18 18:11:30 +00:00
|
|
|
|
2022-01-19 15:09:52 +00:00
|
|
|
} else {
|
|
|
|
//scale vertically
|
|
|
|
screenrect.size.x = win_size.width;
|
|
|
|
screenrect.size.y = imgrect.size.y * win_size.width / imgrect.size.x;
|
|
|
|
screenrect.position.y = (win_size.height - screenrect.size.y) / 2;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
screenrect = imgrect;
|
|
|
|
screenrect.position += ((Size2(win_size.width, win_size.height) - screenrect.size) / 2.0).floor();
|
|
|
|
}
|
2021-10-25 17:27:12 +00:00
|
|
|
|
2022-03-12 11:19:59 +00:00
|
|
|
GLES3::Texture *t = texture_storage.get_texture(texture);
|
|
|
|
glActiveTexture(GL_TEXTURE0 + config.max_texture_image_units - 1);
|
2020-11-18 18:11:30 +00:00
|
|
|
glBindTexture(GL_TEXTURE_2D, t->tex_id);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
canvas.canvas_end();
|
|
|
|
|
2022-03-12 11:19:59 +00:00
|
|
|
texture_storage.texture_free(texture);
|
2020-11-18 18:11:30 +00:00
|
|
|
|
|
|
|
end_frame(true);
|
|
|
|
}
|
|
|
|
|
2021-11-16 15:25:42 +00:00
|
|
|
#endif // GLES3_ENABLED
|