diff --git a/SConstruct b/SConstruct index cd4657b20c5..78e3d283377 100644 --- a/SConstruct +++ b/SConstruct @@ -15,7 +15,7 @@ from collections import OrderedDict # Local import methods import glsl_builders -import opengl_builders +import gles3_builders from platform_methods import run_in_subprocess # Scan possible build platforms @@ -711,8 +711,8 @@ if selected_platform in platform_list: if not env["platform"] == "server": env.Append( BUILDERS={ - "OpenGL_GLSL": env.Builder( - action=run_in_subprocess(opengl_builders.build_opengl_headers), + "GLES3_GLSL": env.Builder( + action=run_in_subprocess(gles3_builders.build_gles3_headers), suffix="glsl.gen.h", src_suffix=".glsl", ) diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 31e9237d569..afd82939ca7 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -604,7 +604,7 @@ void OS::_bind_methods() { ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900); BIND_ENUM_CONSTANT(VIDEO_DRIVER_VULKAN); - BIND_ENUM_CONSTANT(VIDEO_DRIVER_OPENGL); + BIND_ENUM_CONSTANT(VIDEO_DRIVER_OPENGL_3); BIND_ENUM_CONSTANT(DAY_SUNDAY); BIND_ENUM_CONSTANT(DAY_MONDAY); diff --git a/core/core_bind.h b/core/core_bind.h index afbee4efaa3..010d1e24196 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -120,7 +120,7 @@ protected: public: enum VideoDriver { VIDEO_DRIVER_VULKAN, - VIDEO_DRIVER_OPENGL, + VIDEO_DRIVER_OPENGL_3, }; enum Weekday { diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index cc845cc139d..03a3ac053d0 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -456,10 +456,10 @@ - The Vulkan rendering backend. + The Vulkan rendering backend. It requires Vulkan 1.0 support and automatically uses features from Vulkan 1.1 and 1.2 if available. - - The OpenGL rendering backend. It uses OpenGL ES 3.0 on mobile devices, OpenGL 3.3 on desktop platforms and WebGL 2.0 on the web. + + The OpenGL 3 rendering backend. It uses OpenGL 3.3 Core Profile on desktop platforms, OpenGL ES 3.0 on mobile devices, and WebGL 2.0 on HTML5. Sunday. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index e67ccf9efd4..55636958117 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1475,6 +1475,18 @@ The number of fixed iterations per second. This controls how often physics simulation and [method Node._physics_process] methods are run. [b]Note:[/b] This property is only read when the project starts. To change the physics FPS at runtime, set [member Engine.physics_ticks_per_second] instead. + + + + + + + + + + + + @@ -1504,6 +1516,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + Sets the quality of the depth of field effect. Higher quality takes more samples, which is slower but looks smoother. @@ -1585,6 +1623,10 @@ Base size used to determine size of froxel buffer in the camera X-axis and Y-axis. The final size is scaled by the aspect ratio of the screen, so actual values may differ from what is set. Set a larger size for more detailed fog, set a smaller size for better performance. + + + + diff --git a/drivers/SCsub b/drivers/SCsub index ea6d4c9a477..714d4110de3 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -25,7 +25,7 @@ SConscript("winmidi/SCsub") # Graphics drivers if env["vulkan"]: SConscript("vulkan/SCsub") - SConscript("opengl/SCsub") + SConscript("gles3/SCsub") SConscript("gl_context/SCsub") else: SConscript("dummy/SCsub") diff --git a/drivers/opengl/SCsub b/drivers/gles3/SCsub similarity index 100% rename from drivers/opengl/SCsub rename to drivers/gles3/SCsub diff --git a/drivers/opengl/rasterizer_array.h b/drivers/gles3/rasterizer_array.h similarity index 98% rename from drivers/opengl/rasterizer_array.h rename to drivers/gles3/rasterizer_array.h index aeadee56bf3..a321c9ed107 100644 --- a/drivers/opengl/rasterizer_array.h +++ b/drivers/gles3/rasterizer_array.h @@ -35,7 +35,7 @@ * Fast single-threaded growable array for POD types. * For use in render drivers, not for general use. * TO BE REPLACED by local_vector. -*/ + */ #include "core/os/memory.h" #include @@ -47,13 +47,13 @@ // which can be cast to whatever vertex format FVF required, and is initially // created with enough memory to hold the biggest FVF. // This allows multiple FVFs to use the same array. -class RasterizerUnitArrayOpenGL { +class RasterizerUnitArrayGLES3 { public: - RasterizerUnitArrayOpenGL() { + RasterizerUnitArrayGLES3() { _list = nullptr; free(); } - ~RasterizerUnitArrayOpenGL() { free(); } + ~RasterizerUnitArrayGLES3() { free(); } uint8_t *get_unit(unsigned int ui) { return &_list[ui * _unit_size_bytes]; } const uint8_t *get_unit(unsigned int ui) const { return &_list[ui * _unit_size_bytes]; } diff --git a/drivers/opengl/rasterizer_asserts.h b/drivers/gles3/rasterizer_asserts.h similarity index 100% rename from drivers/opengl/rasterizer_asserts.h rename to drivers/gles3/rasterizer_asserts.h diff --git a/drivers/opengl/rasterizer_canvas_base_opengl.cpp b/drivers/gles3/rasterizer_canvas_base_gles3.cpp similarity index 68% rename from drivers/opengl/rasterizer_canvas_base_opengl.cpp rename to drivers/gles3/rasterizer_canvas_base_gles3.cpp index 9b586f296d2..ffa0bc30f5c 100644 --- a/drivers/opengl/rasterizer_canvas_base_opengl.cpp +++ b/drivers/gles3/rasterizer_canvas_base_gles3.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rasterizer_canvas_base_opengl.cpp */ +/* rasterizer_canvas_base_gles3.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,12 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "rasterizer_canvas_base_opengl.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "rasterizer_canvas_base_gles3.h" +#ifdef GLES3_BACKEND_ENABLED #include "core/os/os.h" -#include "drivers/opengl/rasterizer_asserts.h" -#include "rasterizer_scene_opengl.h" +#include "drivers/gles3/rasterizer_asserts.h" +#include "rasterizer_scene_gles3.h" #include "core/config/project_settings.h" #include "servers/rendering/rendering_server_default.h" @@ -42,56 +42,75 @@ #define glClearDepth glClearDepthf #endif -RID RasterizerCanvasBaseOpenGL::light_internal_create() { +static _FORCE_INLINE_ void store_transform3d(const Transform3D &p_mtx, float *p_array) { + p_array[0] = p_mtx.basis.elements[0][0]; + p_array[1] = p_mtx.basis.elements[1][0]; + p_array[2] = p_mtx.basis.elements[2][0]; + p_array[3] = 0; + p_array[4] = p_mtx.basis.elements[0][1]; + p_array[5] = p_mtx.basis.elements[1][1]; + p_array[6] = p_mtx.basis.elements[2][1]; + p_array[7] = 0; + p_array[8] = p_mtx.basis.elements[0][2]; + p_array[9] = p_mtx.basis.elements[1][2]; + p_array[10] = p_mtx.basis.elements[2][2]; + p_array[11] = 0; + p_array[12] = p_mtx.origin.x; + p_array[13] = p_mtx.origin.y; + p_array[14] = p_mtx.origin.z; + p_array[15] = 1; +} + +RID RasterizerCanvasBaseGLES3::light_internal_create() { return RID(); } -void RasterizerCanvasBaseOpenGL::light_internal_update(RID p_rid, Light *p_light) { +void RasterizerCanvasBaseGLES3::light_internal_update(RID p_rid, Light *p_light) { } -void RasterizerCanvasBaseOpenGL::light_internal_free(RID p_rid) { +void RasterizerCanvasBaseGLES3::light_internal_free(RID p_rid) { } -RID RasterizerCanvasBaseOpenGL::light_create() { +RID RasterizerCanvasBaseGLES3::light_create() { return RID(); } -void RasterizerCanvasBaseOpenGL::light_set_texture(RID p_rid, RID p_texture) { +void RasterizerCanvasBaseGLES3::light_set_texture(RID p_rid, RID p_texture) { } -void RasterizerCanvasBaseOpenGL::light_set_use_shadow(RID p_rid, bool p_enable) { +void RasterizerCanvasBaseGLES3::light_set_use_shadow(RID p_rid, bool p_enable) { } -void RasterizerCanvasBaseOpenGL::light_update_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) { +void RasterizerCanvasBaseGLES3::light_update_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) { } -void RasterizerCanvasBaseOpenGL::light_update_directional_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_cull_distance, const Rect2 &p_clip_rect, LightOccluderInstance *p_occluders) { +void RasterizerCanvasBaseGLES3::light_update_directional_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_cull_distance, const Rect2 &p_clip_rect, LightOccluderInstance *p_occluders) { } -void RasterizerCanvasBaseOpenGL::render_sdf(RID p_render_target, LightOccluderInstance *p_occluders) { +void RasterizerCanvasBaseGLES3::render_sdf(RID p_render_target, LightOccluderInstance *p_occluders) { } -RID RasterizerCanvasBaseOpenGL::occluder_polygon_create() { +RID RasterizerCanvasBaseGLES3::occluder_polygon_create() { return RID(); } -void RasterizerCanvasBaseOpenGL::occluder_polygon_set_shape(RID p_occluder, const Vector &p_points, bool p_closed) { +void RasterizerCanvasBaseGLES3::occluder_polygon_set_shape(RID p_occluder, const Vector &p_points, bool p_closed) { } -void RasterizerCanvasBaseOpenGL::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) { +void RasterizerCanvasBaseGLES3::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) { } -void RasterizerCanvasBaseOpenGL::set_shadow_texture_size(int p_size) { +void RasterizerCanvasBaseGLES3::set_shadow_texture_size(int p_size) { } -bool RasterizerCanvasBaseOpenGL::free(RID p_rid) { +bool RasterizerCanvasBaseGLES3::free(RID p_rid) { return true; } -void RasterizerCanvasBaseOpenGL::update() { +void RasterizerCanvasBaseGLES3::update() { } -void RasterizerCanvasBaseOpenGL::canvas_begin() { +void RasterizerCanvasBaseGLES3::canvas_begin() { state.using_transparent_rt = false; // always start with light_angle unset @@ -99,9 +118,9 @@ void RasterizerCanvasBaseOpenGL::canvas_begin() { state.using_large_vertex = false; state.using_modulate = false; - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LIGHT_ANGLE, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_MODULATE, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LARGE_VERTEX, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_LIGHT_ANGLE, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_MODULATE, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_LARGE_VERTEX, false); state.canvas_shader.bind(); int viewport_x, viewport_y, viewport_width, viewport_height; @@ -204,15 +223,14 @@ void RasterizerCanvasBaseOpenGL::canvas_begin() { _set_uniforms(); _bind_quad_buffer(); + + glBindBufferBase(GL_UNIFORM_BUFFER, 0, state.canvas_item_ubo); + glBindVertexArray(data.canvas_quad_array); } -void RasterizerCanvasBaseOpenGL::canvas_end() { +void RasterizerCanvasBaseGLES3::canvas_end() { glBindBuffer(GL_ARRAY_BUFFER, 0); - for (int i = 0; i < RS::ARRAY_MAX; i++) { - glDisableVertexAttribArray(i); - } - if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) { //reset viewport to full window size // int viewport_width = OS::get_singleton()->get_window_size().width; @@ -229,38 +247,38 @@ void RasterizerCanvasBaseOpenGL::canvas_end() { state.using_transparent_rt = false; } -void RasterizerCanvasBaseOpenGL::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) { - state.canvas_shader.set_uniform(CanvasShaderOpenGL::DST_RECT, Color(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y)); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SRC_RECT, Color(p_src.position.x, p_src.position.y, p_src.size.x, p_src.size.y)); - +void RasterizerCanvasBaseGLES3::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) { + state.canvas_shader.set_uniform(CanvasShaderGLES3::DST_RECT, Color(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y)); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SRC_RECT, Color(p_src.position.x, p_src.position.y, p_src.size.x, p_src.size.y)); + _bind_quad_buffer(); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } -void RasterizerCanvasBaseOpenGL::_set_texture_rect_mode(bool p_texture_rect, bool p_light_angle, bool p_modulate, bool p_large_vertex) { +void RasterizerCanvasBaseGLES3::_set_texture_rect_mode(bool p_texture_rect, bool p_light_angle, bool p_modulate, bool p_large_vertex) { // always set this directly (this could be state checked) - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_TEXTURE_RECT, p_texture_rect); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_TEXTURE_RECT, p_texture_rect); if (state.using_light_angle != p_light_angle) { state.using_light_angle = p_light_angle; - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LIGHT_ANGLE, p_light_angle); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_LIGHT_ANGLE, p_light_angle); } if (state.using_modulate != p_modulate) { state.using_modulate = p_modulate; - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_MODULATE, p_modulate); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_MODULATE, p_modulate); } if (state.using_large_vertex != p_large_vertex) { state.using_large_vertex = p_large_vertex; - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LARGE_VERTEX, p_large_vertex); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_ATTRIB_LARGE_VERTEX, p_large_vertex); } } -RasterizerStorageOpenGL::Texture *RasterizerCanvasBaseOpenGL::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) { - RasterizerStorageOpenGL::Texture *tex_return = NULL; +RasterizerStorageGLES3::Texture *RasterizerCanvasBaseGLES3::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) { + RasterizerStorageGLES3::Texture *tex_return = NULL; if (p_texture.is_valid()) { - RasterizerStorageOpenGL::Texture *texture = storage->texture_owner.get_or_null(p_texture); + RasterizerStorageGLES3::Texture *texture = storage->texture_owner.get_or_null(p_texture); if (!texture) { state.current_tex = RID(); @@ -302,16 +320,16 @@ RasterizerStorageOpenGL::Texture *RasterizerCanvasBaseOpenGL::_bind_canvas_textu if (p_normal_map == state.current_normal) { //do none - state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, state.current_normal.is_valid()); + state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, state.current_normal.is_valid()); } else if (p_normal_map.is_valid()) { - RasterizerStorageOpenGL::Texture *normal_map = storage->texture_owner.get_or_null(p_normal_map); + RasterizerStorageGLES3::Texture *normal_map = storage->texture_owner.get_or_null(p_normal_map); if (!normal_map) { state.current_normal = RID(); glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2); glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, false); + state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, false); } else { if (normal_map->redraw_if_visible) { //check before proxy, because this is usually used with proxies @@ -323,21 +341,21 @@ RasterizerStorageOpenGL::Texture *RasterizerCanvasBaseOpenGL::_bind_canvas_textu glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2); glBindTexture(GL_TEXTURE_2D, normal_map->tex_id); state.current_normal = p_normal_map; - state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, true); + state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, true); } } else { state.current_normal = RID(); glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2); glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, false); + state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, false); } return tex_return; } /* -void RasterizerCanvasBaseOpenGL::draw_window_margins(int *black_margin, RID *black_image) { +void RasterizerCanvasBaseGLES3::draw_window_margins(int *black_margin, RID *black_image) { return; // FTODO @@ -409,74 +427,72 @@ void RasterizerCanvasBaseOpenGL::draw_window_margins(int *black_margin, RID *bla } */ -void RasterizerCanvasBaseOpenGL::_bind_quad_buffer() { - glBindBuffer(GL_ARRAY_BUFFER, data.canvas_quad_vertices); - glEnableVertexAttribArray(RS::ARRAY_VERTEX); - glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, NULL); +void RasterizerCanvasBaseGLES3::_bind_quad_buffer() { + glBindVertexArray(data.canvas_quad_array); } -void RasterizerCanvasBaseOpenGL::_set_uniforms() { - state.canvas_shader.set_uniform(CanvasShaderOpenGL::PROJECTION_MATRIX, state.uniforms.projection_matrix); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::EXTRA_MATRIX, state.uniforms.extra_matrix); +void RasterizerCanvasBaseGLES3::_set_uniforms() { + state.canvas_shader.set_uniform(CanvasShaderGLES3::PROJECTION_MATRIX, state.uniforms.projection_matrix); + state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); + state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, state.uniforms.extra_matrix); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::FINAL_MODULATE, state.uniforms.final_modulate); + state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, state.uniforms.final_modulate); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::TIME, storage->frame.time[0]); + state.canvas_shader.set_uniform(CanvasShaderGLES3::TIME, storage->frame.time[0]); if (storage->frame.current_rt) { Vector2 screen_pixel_size; screen_pixel_size.x = 1.0 / storage->frame.current_rt->width; screen_pixel_size.y = 1.0 / storage->frame.current_rt->height; - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SCREEN_PIXEL_SIZE, screen_pixel_size); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SCREEN_PIXEL_SIZE, screen_pixel_size); } if (state.using_skeleton) { - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SKELETON_TRANSFORM, state.skeleton_transform); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SKELETON_TRANSFORM_INVERSE, state.skeleton_transform_inverse); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SKELETON_TEXTURE_SIZE, state.skeleton_texture_size); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM, state.skeleton_transform); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TRANSFORM_INVERSE, state.skeleton_transform_inverse); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SKELETON_TEXTURE_SIZE, state.skeleton_texture_size); } if (state.using_light) { Light *light = state.using_light; - state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_MATRIX, light->light_shader_xform); + state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_MATRIX, light->light_shader_xform); Transform2D basis_inverse = light->light_shader_xform.affine_inverse().orthonormalized(); basis_inverse.elements[2] = Vector2(); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_MATRIX_INVERSE, basis_inverse); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_LOCAL_MATRIX, light->xform_cache.affine_inverse()); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_COLOR, light->color * light->energy); - // state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_POS, light->light_shader_pos); + state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_MATRIX_INVERSE, basis_inverse); + state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_LOCAL_MATRIX, light->xform_cache.affine_inverse()); + state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_COLOR, light->color * light->energy); + // state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_POS, light->light_shader_pos); // FTODO - state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_POS, light->light_shader_xform.elements[2]); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_HEIGHT, light->height); + state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_POS, light->light_shader_xform.elements[2]); + state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_HEIGHT, light->height); // FTODO - //state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_OUTSIDE_ALPHA, light->mode == RS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_OUTSIDE_ALPHA, 0.0f); + //state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_OUTSIDE_ALPHA, light->mode == RS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0); + state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_OUTSIDE_ALPHA, 0.0f); if (state.using_shadow) { // FTODO #if 0 - RasterizerStorageOpenGL::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(light->shadow_buffer); + RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(light->shadow_buffer); glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 5); glBindTexture(GL_TEXTURE_2D, cls->distance); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_MATRIX, light->shadow_matrix_cache); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_SHADOW_COLOR, light->shadow_color); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SHADOW_MATRIX, light->shadow_matrix_cache); + state.canvas_shader.set_uniform(CanvasShaderGLES3::LIGHT_SHADOW_COLOR, light->shadow_color); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOWPIXEL_SIZE, (1.0 / light->shadow_buffer_size) * (1.0 + light->shadow_smooth)); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SHADOWPIXEL_SIZE, (1.0 / light->shadow_buffer_size) * (1.0 + light->shadow_smooth)); if (light->radius_cache == 0) { - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_GRADIENT, 0.0); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SHADOW_GRADIENT, 0.0); } else { - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_GRADIENT, light->shadow_gradient_length / (light->radius_cache * 1.1)); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SHADOW_GRADIENT, light->shadow_gradient_length / (light->radius_cache * 1.1)); } - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_DISTANCE_MULT, light->radius_cache * 1.1); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SHADOW_DISTANCE_MULT, light->radius_cache * 1.1); #endif } } } -void RasterizerCanvasBaseOpenGL::reset_canvas() { +void RasterizerCanvasBaseGLES3::reset_canvas() { glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -502,10 +518,10 @@ void RasterizerCanvasBaseOpenGL::reset_canvas() { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } -void RasterizerCanvasBaseOpenGL::canvas_debug_viewport_shadows(Light *p_lights_with_shadow) { +void RasterizerCanvasBaseGLES3::canvas_debug_viewport_shadows(Light *p_lights_with_shadow) { } -void RasterizerCanvasBaseOpenGL::_copy_texscreen(const Rect2 &p_rect) { +void RasterizerCanvasBaseGLES3::_copy_texscreen(const Rect2 &p_rect) { state.canvas_texscreen_used = true; _copy_screen(p_rect); @@ -517,7 +533,8 @@ void RasterizerCanvasBaseOpenGL::_copy_texscreen(const Rect2 &p_rect) { _set_uniforms(); } -void RasterizerCanvasBaseOpenGL::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) { +void RasterizerCanvasBaseGLES3::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) { + glBindVertexArray(data.polygon_buffer_pointer_array); glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); uint32_t buffer_ofs = 0; @@ -593,12 +610,13 @@ void RasterizerCanvasBaseOpenGL::_draw_polygon(const int *p_indices, int p_index glDrawElements(GL_TRIANGLES, p_index_count, GL_UNSIGNED_SHORT, 0); storage->info.render._2d_draw_call_count++; } - + glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } -void RasterizerCanvasBaseOpenGL::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) { +void RasterizerCanvasBaseGLES3::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) { + glBindVertexArray(data.polygon_buffer_pointer_array); glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); uint32_t buffer_ofs = 0; @@ -638,10 +656,12 @@ void RasterizerCanvasBaseOpenGL::_draw_generic(GLuint p_primitive, int p_vertex_ glDrawArrays(p_primitive, 0, p_vertex_count); storage->info.render._2d_draw_call_count++; + glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); } -void RasterizerCanvasBaseOpenGL::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) { +void RasterizerCanvasBaseGLES3::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) { + glBindVertexArray(data.polygon_buffer_pointer_array); glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); uint32_t buffer_ofs = 0; @@ -706,12 +726,12 @@ void RasterizerCanvasBaseOpenGL::_draw_generic_indices(GLuint p_primitive, const glDrawElements(p_primitive, p_index_count, GL_UNSIGNED_SHORT, 0); storage->info.render._2d_draw_call_count++; } - + glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } -void RasterizerCanvasBaseOpenGL::_legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageOpenGL::Material *p_material) { +void RasterizerCanvasBaseGLES3::_legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageGLES3::Material *p_material) { // return; const PolyData &pd = _polydata[p_poly->polygon.polygon_id]; @@ -724,12 +744,12 @@ void RasterizerCanvasBaseOpenGL::_legacy_draw_poly_triangles(Item::CommandPolygo } // FTODO - //RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(polygon->texture, polygon->normal_map); - RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(p_poly->texture, RID()); + //RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(polygon->texture, polygon->normal_map); + RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(p_poly->texture, RID()); if (texture) { Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size); + state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size); } _draw_polygon(pd.indices.ptr(), pd.indices.size(), pd.points.size(), pd.points.ptr(), pd.uvs.ptr(), pd.colors.ptr(), pd.colors.size() == 1, nullptr, nullptr); @@ -750,7 +770,7 @@ void RasterizerCanvasBaseOpenGL::_legacy_draw_poly_triangles(Item::CommandPolygo #endif } -void RasterizerCanvasBaseOpenGL::_legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material) { +void RasterizerCanvasBaseGLES3::_legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageGLES3::Material *p_material) { // return; if (p_pr->point_count != 4) @@ -768,12 +788,12 @@ void RasterizerCanvasBaseOpenGL::_legacy_draw_primitive(Item::CommandPrimitive * glDisableVertexAttribArray(RS::ARRAY_COLOR); glVertexAttrib4fv(RS::ARRAY_COLOR, p_pr->colors[0].components); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); + state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); _draw_gui_primitive(p_pr->point_count, p_pr->points, NULL, NULL); } -void RasterizerCanvasBaseOpenGL::_legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material) { +void RasterizerCanvasBaseGLES3::_legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageGLES3::Material *p_material) { _set_texture_rect_mode(false); if (state.canvas_shader.bind()) { @@ -786,7 +806,7 @@ void RasterizerCanvasBaseOpenGL::_legacy_draw_line(Item::CommandPrimitive *p_pr, glDisableVertexAttribArray(RS::ARRAY_COLOR); glVertexAttrib4fv(RS::ARRAY_COLOR, p_pr->colors[0].components); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); + state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); #ifdef GLES_OVER_GL // if (line->antialiased) @@ -800,25 +820,29 @@ void RasterizerCanvasBaseOpenGL::_legacy_draw_line(Item::CommandPrimitive *p_pr, #endif } -void RasterizerCanvasBaseOpenGL::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const float *p_light_angles) { +void RasterizerCanvasBaseGLES3::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const float *p_light_angles) { static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN }; + int version = 0; int color_offset = 0; int uv_offset = 0; int light_angle_offset = 0; int stride = 2; if (p_colors) { + version |= 1; color_offset = stride; stride += 4; } if (p_uvs) { + version |= 2; uv_offset = stride; stride += 2; } if (p_light_angles) { //light_angles + version |= 4; light_angle_offset = stride; stride += 1; } @@ -856,35 +880,15 @@ void RasterizerCanvasBaseOpenGL::_draw_gui_primitive(int p_points, const Vector2 glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, p_points * stride * 4 * sizeof(float), buffer_data, GL_ARRAY_BUFFER, _buffer_upload_usage_flag, true); - glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), NULL); - - if (p_colors) { - glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(color_offset * sizeof(float))); - glEnableVertexAttribArray(RS::ARRAY_COLOR); - } - - if (p_uvs) { - glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(uv_offset * sizeof(float))); - glEnableVertexAttribArray(RS::ARRAY_TEX_UV); - } - - if (p_light_angles) { - glVertexAttribPointer(RS::ARRAY_TANGENT, 1, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(light_angle_offset * sizeof(float))); - glEnableVertexAttribArray(RS::ARRAY_TANGENT); - } + glBindVertexArray(data.polygon_buffer_quad_arrays[version]); glDrawArrays(prim[p_points], 0, p_points); storage->info.render._2d_draw_call_count++; - - if (p_light_angles) { - // may not be needed - glDisableVertexAttribArray(RS::ARRAY_TANGENT); - } - + glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); } -void RasterizerCanvasBaseOpenGL::_copy_screen(const Rect2 &p_rect) { +void RasterizerCanvasBaseGLES3::_copy_screen(const Rect2 &p_rect) { if (storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) { ERR_PRINT_ONCE("Cannot use screen texture copying in render target set to render direct to screen."); return; @@ -899,17 +903,17 @@ void RasterizerCanvasBaseOpenGL::_copy_screen(const Rect2 &p_rect) { Color copy_section(p_rect.position.x / wh.x, p_rect.position.y / wh.y, p_rect.size.x / wh.x, p_rect.size.y / wh.y); if (p_rect != Rect2()) { - storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_COPY_SECTION, true); + storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_COPY_SECTION, true); } - storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_NO_ALPHA, !state.using_transparent_rt); + storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_NO_ALPHA, !state.using_transparent_rt); storage->bind_framebuffer(storage->frame.current_rt->copy_screen_effect.fbo); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color); storage->shaders.copy.bind(); - storage->shaders.copy.set_uniform(CopyShaderOpenGL::COPY_SECTION, copy_section); + storage->shaders.copy.set_uniform(CopyShaderGLES3::COPY_SECTION, copy_section); const Vector2 vertpos[4] = { Vector2(-1, -1), @@ -932,16 +936,16 @@ void RasterizerCanvasBaseOpenGL::_copy_screen(const Rect2 &p_rect) { _draw_polygon(indexpos, 6, 4, vertpos, uvpos, NULL, false); - storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_COPY_SECTION, false); - storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_NO_ALPHA, false); + storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_COPY_SECTION, false); + storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_NO_ALPHA, false); storage->bind_framebuffer(storage->frame.current_rt->fbo); glEnable(GL_BLEND); } -void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) { +void RasterizerCanvasBaseGLES3::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) { #if 0 - RasterizerStorageOpenGL::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(p_buffer); + RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(p_buffer); ERR_FAIL_COND(!cls); glDisable(GL_BLEND); @@ -954,7 +958,7 @@ void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer, glBindFramebuffer(GL_FRAMEBUFFER, cls->fbo); - state.canvas_shadow_shader.set_conditional(CanvasShadowShaderOpenGL::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows); + state.canvas_shadow_shader.set_conditional(CanvasShadowShaderGLES3::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows); state.canvas_shadow_shader.bind(); glViewport(0, 0, cls->size, cls->height); @@ -996,9 +1000,9 @@ void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer, Vector3 cam_target = Basis(Vector3(0, 0, Math_PI * 2 * (i / 4.0))).xform(Vector3(0, 1, 0)); projection = projection * CameraMatrix(Transform3D().looking_at(cam_target, Vector3(0, 0, -1)).affine_inverse()); - state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::PROJECTION_MATRIX, projection); - state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::LIGHT_MATRIX, light); - state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::DISTANCE_NORM, 1.0 / p_far); + state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::PROJECTION_MATRIX, projection); + state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::LIGHT_MATRIX, light); + state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::DISTANCE_NORM, 1.0 / p_far); if (i == 0) *p_xform_cache = projection; @@ -1008,13 +1012,13 @@ void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer, LightOccluderInstance *instance = p_occluders; while (instance) { - RasterizerStorageOpenGL::CanvasOccluder *cc = storage->canvas_occluder_owner.get_or_null(instance->polygon_buffer); + RasterizerStorageGLES3::CanvasOccluder *cc = storage->canvas_occluder_owner.get_or_null(instance->polygon_buffer); if (!cc || cc->len == 0 || !(p_light_mask & instance->light_mask)) { instance = instance->next; continue; } - state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::WORLD_MATRIX, instance->xform_cache); + state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::WORLD_MATRIX, instance->xform_cache); RS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache; @@ -1061,7 +1065,7 @@ void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer, #endif } -void RasterizerCanvasBaseOpenGL::draw_lens_distortion_rect(const Rect2 &p_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) { +void RasterizerCanvasBaseGLES3::draw_lens_distortion_rect(const Rect2 &p_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) { Vector2 half_size; if (storage->frame.current_rt) { half_size = Vector2(storage->frame.current_rt->width, storage->frame.current_rt->height); @@ -1077,13 +1081,13 @@ void RasterizerCanvasBaseOpenGL::draw_lens_distortion_rect(const Rect2 &p_rect, // setup our lens shader state.lens_shader.bind(); - state.lens_shader.set_uniform(LensDistortedShaderOpenGL::OFFSET, offset); - state.lens_shader.set_uniform(LensDistortedShaderOpenGL::SCALE, scale); - state.lens_shader.set_uniform(LensDistortedShaderOpenGL::K1, p_k1); - state.lens_shader.set_uniform(LensDistortedShaderOpenGL::K2, p_k2); - state.lens_shader.set_uniform(LensDistortedShaderOpenGL::EYE_CENTER, p_eye_center); - state.lens_shader.set_uniform(LensDistortedShaderOpenGL::UPSCALE, p_oversample); - state.lens_shader.set_uniform(LensDistortedShaderOpenGL::ASPECT_RATIO, aspect_ratio); + state.lens_shader.set_uniform(LensDistortedShaderGLES3::OFFSET, offset); + state.lens_shader.set_uniform(LensDistortedShaderGLES3::SCALE, scale); + state.lens_shader.set_uniform(LensDistortedShaderGLES3::K1, p_k1); + state.lens_shader.set_uniform(LensDistortedShaderGLES3::K2, p_k2); + state.lens_shader.set_uniform(LensDistortedShaderGLES3::EYE_CENTER, p_eye_center); + state.lens_shader.set_uniform(LensDistortedShaderGLES3::UPSCALE, p_oversample); + state.lens_shader.set_uniform(LensDistortedShaderGLES3::ASPECT_RATIO, aspect_ratio); // bind our quad buffer _bind_quad_buffer(); @@ -1093,13 +1097,9 @@ void RasterizerCanvasBaseOpenGL::draw_lens_distortion_rect(const Rect2 &p_rect, // and cleanup glBindBuffer(GL_ARRAY_BUFFER, 0); - - for (int i = 0; i < RS::ARRAY_MAX; i++) { - glDisableVertexAttribArray(i); - } } -void RasterizerCanvasBaseOpenGL::initialize() { +void RasterizerCanvasBaseGLES3::initialize() { bool flag_stream = false; //flag_stream = GLOBAL_GET("rendering/options/api_usage_legacy/flag_stream"); if (flag_stream) @@ -1122,29 +1122,119 @@ void RasterizerCanvasBaseOpenGL::initialize() { glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 8, qv, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); + + glGenVertexArrays(1, &data.canvas_quad_array); + glBindVertexArray(data.canvas_quad_array); + glBindBuffer(GL_ARRAY_BUFFER, data.canvas_quad_vertices); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, nullptr); + glEnableVertexAttribArray(0); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind + } + + { + //particle quad buffers + + glGenBuffers(1, &data.particle_quad_vertices); + glBindBuffer(GL_ARRAY_BUFFER, data.particle_quad_vertices); + { + //quad of size 1, with pivot on the center for particles, then regular UVS. Color is general plus fetched from particle + const float qv[16] = { + -0.5, -0.5, + 0.0, 0.0, + -0.5, 0.5, + 0.0, 1.0, + 0.5, 0.5, + 1.0, 1.0, + 0.5, -0.5, + 1.0, 0.0 + }; + + glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 16, qv, GL_STATIC_DRAW); + } + + glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind + + glGenVertexArrays(1, &data.particle_quad_array); + glBindVertexArray(data.particle_quad_array); + glBindBuffer(GL_ARRAY_BUFFER, data.particle_quad_vertices); + glEnableVertexAttribArray(RS::ARRAY_VERTEX); + glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, nullptr); + glEnableVertexAttribArray(RS::ARRAY_TEX_UV); + glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(8)); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind } // polygon buffer { - uint32_t poly_size = GLOBAL_DEF("rendering/limits/buffers/canvas_polygon_buffer_size_kb", 128); + uint32_t poly_size = 128; //GLOBAL_DEF_RST("rendering/limits/buffers/canvas_polygon_buffer_size_kb", 128); ProjectSettings::get_singleton()->set_custom_property_info("rendering/limits/buffers/canvas_polygon_buffer_size_kb", PropertyInfo(Variant::INT, "rendering/limits/buffers/canvas_polygon_buffer_size_kb", PROPERTY_HINT_RANGE, "0,256,1,or_greater")); - poly_size = MAX(poly_size, 128); // minimum 2k, may still see anomalies in editor - poly_size *= 1024; + poly_size = MAX(poly_size, 2); // minimum 2k, may still see anomalies in editor + poly_size *= 1024; //kb glGenBuffers(1, &data.polygon_buffer); glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); - glBufferData(GL_ARRAY_BUFFER, poly_size, NULL, GL_DYNAMIC_DRAW); - + glBufferData(GL_ARRAY_BUFFER, poly_size, nullptr, GL_DYNAMIC_DRAW); //allocate max size + glBindBuffer(GL_ARRAY_BUFFER, 0); data.polygon_buffer_size = poly_size; - glBindBuffer(GL_ARRAY_BUFFER, 0); + //quad arrays + for (int i = 0; i < Data::NUM_QUAD_ARRAY_VARIATIONS; i++) { + glGenVertexArrays(1, &data.polygon_buffer_quad_arrays[i]); + glBindVertexArray(data.polygon_buffer_quad_arrays[i]); + glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); - uint32_t index_size = GLOBAL_DEF("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", 128); + int uv_ofs = 0; + int color_ofs = 0; + int light_angle_ofs = 0; + int stride = 2 * 4; + + if (i & 1) { //color + color_ofs = stride; + stride += 4 * 4; + } + + if (i & 2) { //uv + uv_ofs = stride; + stride += 2 * 4; + } + + if (i & 4) { //light_angle + light_angle_ofs = stride; + stride += 1 * 4; + } + + glEnableVertexAttribArray(RS::ARRAY_VERTEX); + glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride, nullptr); + + if (i & 1) { + glEnableVertexAttribArray(RS::ARRAY_COLOR); + glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(color_ofs)); + } + + if (i & 2) { + glEnableVertexAttribArray(RS::ARRAY_TEX_UV); + glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(uv_ofs)); + } + + if (i & 4) { + // reusing tangent for light_angle + glEnableVertexAttribArray(RS::ARRAY_TANGENT); + glVertexAttribPointer(RS::ARRAY_TANGENT, 1, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(light_angle_ofs)); + } + + glBindVertexArray(0); + } + + glGenVertexArrays(1, &data.polygon_buffer_pointer_array); + + uint32_t index_size = 128; //GLOBAL_DEF_RST("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", 128); ProjectSettings::get_singleton()->set_custom_property_info("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", PropertyInfo(Variant::INT, "rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", PROPERTY_HINT_RANGE, "0,256,1,or_greater")); - index_size = MAX(index_size, 128); - index_size *= 1024; // kb + index_size = MAX(index_size, 2); + index_size *= 1024; //kb glGenBuffers(1, &data.polygon_index_buffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_size, nullptr, GL_DYNAMIC_DRAW); //allocate max size glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); data.polygon_index_buffer_size = index_size; @@ -1212,25 +1302,30 @@ void RasterizerCanvasBaseOpenGL::initialize() { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } + store_transform3d(Transform3D(), state.canvas_item_ubo_data.projection_matrix); + + glGenBuffers(1, &state.canvas_item_ubo); + glBindBuffer(GL_UNIFORM_BUFFER, state.canvas_item_ubo); + glBufferData(GL_UNIFORM_BUFFER, sizeof(CanvasItemUBO), &state.canvas_item_ubo_data, GL_DYNAMIC_DRAW); + glBindBuffer(GL_UNIFORM_BUFFER, 0); + state.canvas_shadow_shader.init(); - state.canvas_shader.init(); - _set_texture_rect_mode(true); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows); state.canvas_shader.bind(); state.lens_shader.init(); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false)); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false)); state.using_light = NULL; state.using_transparent_rt = false; state.using_skeleton = false; } -RendererCanvasRender::PolygonID RasterizerCanvasBaseOpenGL::request_polygon(const Vector &p_indices, const Vector &p_points, const Vector &p_colors, const Vector &p_uvs, const Vector &p_bones, const Vector &p_weights) { +RendererCanvasRender::PolygonID RasterizerCanvasBaseGLES3::request_polygon(const Vector &p_indices, const Vector &p_points, const Vector &p_colors, const Vector &p_uvs, const Vector &p_bones, const Vector &p_weights) { uint32_t id = _polydata.alloc(); PolyData &pd = _polydata[id]; pd.indices = p_indices; @@ -1239,14 +1334,21 @@ RendererCanvasRender::PolygonID RasterizerCanvasBaseOpenGL::request_polygon(cons pd.uvs = p_uvs; return id; } -void RasterizerCanvasBaseOpenGL::free_polygon(PolygonID p_polygon) { +void RasterizerCanvasBaseGLES3::free_polygon(PolygonID p_polygon) { _polydata.free(p_polygon); } -void RasterizerCanvasBaseOpenGL::finalize() { +void RasterizerCanvasBaseGLES3::finalize() { + glDeleteBuffers(1, &data.canvas_quad_vertices); + glDeleteVertexArrays(1, &data.canvas_quad_array); + + glDeleteBuffers(1, &data.canvas_quad_vertices); + glDeleteVertexArrays(1, &data.canvas_quad_array); + + glDeleteVertexArrays(1, &data.polygon_buffer_pointer_array); } -RasterizerCanvasBaseOpenGL::RasterizerCanvasBaseOpenGL() { +RasterizerCanvasBaseGLES3::RasterizerCanvasBaseGLES3() { } -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED diff --git a/drivers/opengl/rasterizer_canvas_base_opengl.h b/drivers/gles3/rasterizer_canvas_base_gles3.h similarity index 85% rename from drivers/opengl/rasterizer_canvas_base_opengl.h rename to drivers/gles3/rasterizer_canvas_base_gles3.h index ac2020e5d78..3fa180539e3 100644 --- a/drivers/opengl/rasterizer_canvas_base_opengl.h +++ b/drivers/gles3/rasterizer_canvas_base_gles3.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rasterizer_canvas_base_opengl.h */ +/* rasterizer_canvas_base_gles3.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,13 +31,13 @@ #ifndef RASTERIZER_CANVAS_BASE_OPENGL_H #define RASTERIZER_CANVAS_BASE_OPENGL_H -#include "drivers/opengl/rasterizer_platforms.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "drivers/gles3/rasterizer_platforms.h" +#ifdef GLES3_BACKEND_ENABLED -#include "drivers/opengl/rasterizer_array.h" -#include "drivers/opengl/rasterizer_storage_common.h" -#include "rasterizer_scene_opengl.h" -#include "rasterizer_storage_opengl.h" +#include "drivers/gles3/rasterizer_array.h" +#include "drivers/gles3/rasterizer_storage_common.h" +#include "rasterizer_scene_gles3.h" +#include "rasterizer_storage_gles3.h" #include "servers/rendering/renderer_canvas_render.h" #include "servers/rendering/renderer_compositor.h" @@ -45,7 +45,7 @@ #include "shaders/canvas_shadow.glsl.gen.h" #include "shaders/lens_distorted.glsl.gen.h" -class RasterizerCanvasBaseOpenGL : public RendererCanvasRender { +class RasterizerCanvasBaseGLES3 : public RendererCanvasRender { public: enum { INSTANCE_ATTRIB_BASE = 8, @@ -62,11 +62,26 @@ public: float time; }; + struct CanvasItemUBO { + float projection_matrix[16]; + float time; + uint8_t padding[12]; + }; + struct Data { + enum { NUM_QUAD_ARRAY_VARIATIONS = 8 }; + GLuint canvas_quad_vertices; + GLuint canvas_quad_array; + GLuint polygon_buffer; + GLuint polygon_buffer_quad_arrays[NUM_QUAD_ARRAY_VARIATIONS]; + GLuint polygon_buffer_pointer_array; GLuint polygon_index_buffer; + GLuint particle_quad_vertices; + GLuint particle_quad_array; + uint32_t polygon_buffer_size; uint32_t polygon_index_buffer_size; @@ -76,10 +91,12 @@ public: struct State { Uniforms uniforms; + CanvasItemUBO canvas_item_ubo_data; + GLuint canvas_item_ubo; bool canvas_texscreen_used; - CanvasShaderOpenGL canvas_shader; - CanvasShadowShaderOpenGL canvas_shadow_shader; - LensDistortedShaderOpenGL lens_shader; + CanvasShaderGLES3 canvas_shader; + CanvasShadowShaderGLES3 canvas_shadow_shader; + LensDistortedShaderGLES3 lens_shader; bool using_texture_rect; @@ -96,7 +113,7 @@ public: RID current_tex; RID current_normal; - RasterizerStorageOpenGL::Texture *current_tex_ptr; + RasterizerStorageGLES3::Texture *current_tex_ptr; Transform3D vp; Light *using_light; @@ -111,9 +128,9 @@ public: typedef void Texture; - RasterizerSceneOpenGL *scene_render; + RasterizerSceneGLES3 *scene_render; - RasterizerStorageOpenGL *storage; + RasterizerStorageGLES3 *storage; // allow user to choose api usage GLenum _buffer_upload_usage_flag; @@ -128,9 +145,9 @@ public: virtual void canvas_end(); protected: - void _legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material); - void _legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material); - void _legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageOpenGL::Material *p_material); + void _legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageGLES3::Material *p_material); + void _legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageGLES3::Material *p_material); + void _legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageGLES3::Material *p_material); public: void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const float *p_light_angles = nullptr); @@ -168,7 +185,7 @@ public: void update() override; // End copied from RasterizerCanvasDummy. - RasterizerStorageOpenGL::Texture *_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map); + RasterizerStorageGLES3::Texture *_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map); void _set_texture_rect_mode(bool p_texture_rect, bool p_light_angle = false, bool p_modulate = false, bool p_large_vertex = false); // NEW API @@ -188,9 +205,9 @@ public: void initialize(); void finalize(); - RasterizerCanvasBaseOpenGL(); + RasterizerCanvasBaseGLES3(); }; -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED #endif // RASTERIZER_CANVAS_BASE_OPENGL_H diff --git a/drivers/opengl/rasterizer_canvas_batcher.h b/drivers/gles3/rasterizer_canvas_batcher.h similarity index 100% rename from drivers/opengl/rasterizer_canvas_batcher.h rename to drivers/gles3/rasterizer_canvas_batcher.h diff --git a/drivers/opengl/rasterizer_canvas_opengl.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp similarity index 83% rename from drivers/opengl/rasterizer_canvas_opengl.cpp rename to drivers/gles3/rasterizer_canvas_gles3.cpp index 41d68e5bc96..7cd90ea1dea 100644 --- a/drivers/opengl/rasterizer_canvas_opengl.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rasterizer_canvas_opengl.cpp */ +/* rasterizer_canvas_gles3.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,14 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "rasterizer_canvas_opengl.h" -#include "drivers/opengl/rasterizer_platforms.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "rasterizer_canvas_gles3.h" +#include "drivers/gles3/rasterizer_platforms.h" +#ifdef GLES3_BACKEND_ENABLED #include "core/os/os.h" -#include "drivers/opengl/rasterizer_asserts.h" -#include "rasterizer_scene_opengl.h" -#include "rasterizer_storage_opengl.h" +#include "drivers/gles3/rasterizer_asserts.h" +#include "rasterizer_scene_gles3.h" +#include "rasterizer_storage_gles3.h" #include "core/config/project_settings.h" #include "servers/rendering/rendering_server_default.h" @@ -51,7 +51,7 @@ //}; #if 0 -void RasterizerCanvasOpenGL::_batch_upload_buffers() { +void RasterizerCanvasGLES3::_batch_upload_buffers() { // noop? if (!bdata.vertices.size()) return; @@ -93,7 +93,7 @@ void RasterizerCanvasOpenGL::_batch_upload_buffers() { glBindBuffer(GL_ARRAY_BUFFER, 0); } -void RasterizerCanvasOpenGL::_batch_render_lines(const Batch &p_batch, RasterizerStorageOpenGL::Material *p_material, bool p_anti_alias) { +void RasterizerCanvasGLES3::_batch_render_lines(const Batch &p_batch, RasterizerStorageGLES3::Material *p_material, bool p_anti_alias) { _set_texture_rect_mode(false); if (state.canvas_shader.bind()) { @@ -139,7 +139,7 @@ void RasterizerCanvasOpenGL::_batch_render_lines(const Batch &p_batch, Rasterize #endif } -void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, RasterizerStorageOpenGL::Material *p_material) { +void RasterizerCanvasGLES3::_batch_render_generic(const Batch &p_batch, RasterizerStorageGLES3::Material *p_material) { ERR_FAIL_COND(p_batch.num_commands <= 0); const bool &use_light_angles = bdata.use_light_angles; @@ -183,7 +183,7 @@ void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, Rasteri // force repeat is set if non power of 2 texture, and repeat is needed if hardware doesn't support npot if (tex.tile_mode == BatchTex::TILE_FORCE_REPEAT) { - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_FORCE_REPEAT, true); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_FORCE_REPEAT, true); } if (state.canvas_shader.bind()) { @@ -234,7 +234,7 @@ void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, Rasteri // This is an optimization left over from the legacy renderer. // If we DID set tiling in the API, and reverted to clamped, then the next draw using this texture // may use clamped mode incorrectly. - bool tex_is_already_tiled = tex.flags & RasterizerStorageOpenGL::TEXTURE_FLAG_REPEAT; + bool tex_is_already_tiled = tex.flags & RasterizerStorageGLES3::TEXTURE_FLAG_REPEAT; if (tex.tile_mode == BatchTex::TILE_NORMAL) { // if the texture is imported as tiled, no need to set GL state, as it will already be bound with repeat @@ -248,7 +248,7 @@ void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, Rasteri // could use a cast but this might be unsafe in future Vector2 tps; tex.tex_pixel_size.to(tps); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, tps); + state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, tps); switch (p_batch.type) { default: { @@ -272,7 +272,7 @@ void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, Rasteri switch (tex.tile_mode) { case BatchTex::TILE_FORCE_REPEAT: { - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_FORCE_REPEAT, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_FORCE_REPEAT, false); } break; case BatchTex::TILE_NORMAL: { // if the texture is imported as tiled, no need to revert GL state @@ -298,7 +298,7 @@ void RasterizerCanvasOpenGL::_batch_render_generic(const Batch &p_batch, Rasteri glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } #endif -void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, Item *p_current_clip, bool &r_reclip, RasterizerStorageOpenGL::Material *p_material) { +void RasterizerCanvasGLES3::render_batches(Item::Command *const *p_commands, Item *p_current_clip, bool &r_reclip, RasterizerStorageGLES3::Material *p_material) { int num_batches = bdata.batches.size(); for (int batch_num = 0; batch_num < num_batches; batch_num++) { @@ -340,7 +340,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It glDisableVertexAttribArray(RS::ARRAY_COLOR); glVertexAttrib4fv(RS::ARRAY_COLOR, line->color.components); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); + state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); if (line->width <= 1) { Vector2 verts[2] = { @@ -401,7 +401,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It case Item::Command::TYPE_RECT: { Item::CommandRect *r = static_cast(command); - + _bind_quad_buffer(); glDisableVertexAttribArray(RS::ARRAY_COLOR); glVertexAttrib4fv(RS::ARRAY_COLOR, r->modulate.components); @@ -413,7 +413,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It // very inefficient, improve this if (r->texture.is_valid()) { - RasterizerStorageOpenGL::Texture *texture = storage->texture_owner.get_or_null(r->texture); + RasterizerStorageGLES3::Texture *texture = storage->texture_owner.get_or_null(r->texture); if (texture) { if (texture->is_upside_down()) @@ -424,13 +424,13 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It if (r->texture.is_valid() && r->flags & CANVAS_RECT_TILE && !storage->config.support_npot_repeat_mipmap) { // workaround for when setting tiling does not work due to hardware limitation - RasterizerStorageOpenGL::Texture *texture = storage->texture_owner.get_or_null(r->texture); + RasterizerStorageGLES3::Texture *texture = storage->texture_owner.get_or_null(r->texture); if (texture) { texture = texture->get_ptr(); if (next_power_of_2(texture->alloc_width) != (unsigned int)texture->alloc_width && next_power_of_2(texture->alloc_height) != (unsigned int)texture->alloc_height) { - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_FORCE_REPEAT, true); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_FORCE_REPEAT, true); can_tile = false; } } @@ -475,8 +475,8 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It } // FTODO - //RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(r->texture, r->normal_map); - RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(r->texture, RID()); + //RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(r->texture, r->normal_map); + RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(r->texture, RID()); if (texture) { Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height); @@ -510,11 +510,11 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It flip_v = !flip_v; } - state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size); + state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size); bool untile = false; - if (can_tile && r->flags & CANVAS_RECT_TILE && !(texture->flags & RasterizerStorageOpenGL::TEXTURE_FLAG_REPEAT)) { + if (can_tile && r->flags & CANVAS_RECT_TILE && !(texture->flags & RasterizerStorageGLES3::TEXTURE_FLAG_REPEAT)) { texture->GLSetRepeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); untile = true; } @@ -558,13 +558,12 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It Vector2(1.0, 0.0), }; - state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, Vector2()); + state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, Vector2()); _draw_gui_primitive(4, points, NULL, uvs); } } else { // This branch is better for performance, but can produce flicker on Nvidia, see above comment. - _bind_quad_buffer(); _set_texture_rect_mode(true); @@ -572,10 +571,11 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It _set_uniforms(); state.canvas_shader.use_material((void *)p_material); } + _bind_quad_buffer(); // FTODO - //RasterizerStorageOpenGL::Texture *tex = _bind_canvas_texture(r->texture, r->normal_map); - RasterizerStorageOpenGL::Texture *tex = _bind_canvas_texture(r->texture, RID()); + //RasterizerStorageGLES3::Texture *tex = _bind_canvas_texture(r->texture, r->normal_map); + RasterizerStorageGLES3::Texture *tex = _bind_canvas_texture(r->texture, RID()); if (!tex) { Rect2 dst_rect = Rect2(r->rect.position, r->rect.size); @@ -589,15 +589,15 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It dst_rect.size.height *= -1; } - state.canvas_shader.set_uniform(CanvasShaderOpenGL::DST_RECT, Color(dst_rect.position.x, dst_rect.position.y, dst_rect.size.x, dst_rect.size.y)); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SRC_RECT, Color(0, 0, 1, 1)); + state.canvas_shader.set_uniform(CanvasShaderGLES3::DST_RECT, Color(dst_rect.position.x, dst_rect.position.y, dst_rect.size.x, dst_rect.size.y)); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SRC_RECT, Color(0, 0, 1, 1)); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); storage->info.render._2d_draw_call_count++; } else { bool untile = false; - if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & RasterizerStorageOpenGL::TEXTURE_FLAG_REPEAT)) { + if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & RasterizerStorageGLES3::TEXTURE_FLAG_REPEAT)) { tex->GLSetRepeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); untile = true; } @@ -628,10 +628,10 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It dst_rect.size.x *= -1; // Encoding in the dst_rect.z uniform } - state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size); + state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::DST_RECT, Color(dst_rect.position.x, dst_rect.position.y, dst_rect.size.x, dst_rect.size.y)); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::SRC_RECT, Color(src_rect.position.x, src_rect.position.y, src_rect.size.x, src_rect.size.y)); + state.canvas_shader.set_uniform(CanvasShaderGLES3::DST_RECT, Color(dst_rect.position.x, dst_rect.position.y, dst_rect.size.x, dst_rect.size.y)); + state.canvas_shader.set_uniform(CanvasShaderGLES3::SRC_RECT, Color(src_rect.position.x, src_rect.position.y, src_rect.size.x, src_rect.size.y)); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); storage->info.render._2d_draw_call_count++; @@ -645,7 +645,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_FORCE_REPEAT, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_FORCE_REPEAT, false); } break; case Item::Command::TYPE_NINEPATCH: { @@ -656,13 +656,14 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It _set_uniforms(); state.canvas_shader.use_material((void *)p_material); } + _bind_quad_buffer(); glDisableVertexAttribArray(RS::ARRAY_COLOR); glVertexAttrib4fv(RS::ARRAY_COLOR, np->color.components); // FTODO - //RasterizerStorageOpenGL::Texture *tex = _bind_canvas_texture(np->texture, np->normal_map); - RasterizerStorageOpenGL::Texture *tex = _bind_canvas_texture(np->texture, RID()); + //RasterizerStorageGLES3::Texture *tex = _bind_canvas_texture(np->texture, np->normal_map); + RasterizerStorageGLES3::Texture *tex = _bind_canvas_texture(np->texture, RID()); if (!tex) { // FIXME: Handle textureless ninepatch gracefully @@ -676,8 +677,8 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It Size2 texpixel_size(1.0 / tex->width, 1.0 / tex->height); - // state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size); + // state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); + state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size); Rect2 source = np->source; if (source.size.x == 0 && source.size.y == 0) { @@ -809,13 +810,13 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.ninepatch_elements); - glEnableVertexAttribArray(RS::ARRAY_VERTEX); + //glEnableVertexAttribArray(RS::ARRAY_VERTEX); glEnableVertexAttribArray(RS::ARRAY_TEX_UV); - glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), NULL); + //glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), NULL); glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), CAST_INT_TO_UCHAR_PTR((sizeof(float) * 2))); - glDrawElements(GL_TRIANGLES, 18 * 3 - (np->draw_center ? 0 : 6), GL_UNSIGNED_BYTE, NULL); + //glDrawElements(GL_TRIANGLES, 18 * 3 - (np->draw_center ? 0 : 6), GL_UNSIGNED_SHORT, NULL); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); @@ -876,17 +877,17 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It state.canvas_shader.use_material((void *)p_material); } - RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(mesh->texture, mesh->normal_map); + RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(mesh->texture, mesh->normal_map); if (texture) { Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size); + state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size); } - RasterizerStorageOpenGL::Mesh *mesh_data = storage->mesh_owner.get_or_null(mesh->mesh); + RasterizerStorageGLES3::Mesh *mesh_data = storage->mesh_owner.get_or_null(mesh->mesh); if (mesh_data) { for (int j = 0; j < mesh_data->surfaces.size(); j++) { - RasterizerStorageOpenGL::Surface *s = mesh_data->surfaces[j]; + RasterizerStorageGLES3::Surface *s = mesh_data->surfaces[j]; // materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing glBindBuffer(GL_ARRAY_BUFFER, s->vertex_id); @@ -932,18 +933,18 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It case Item::Command::TYPE_MULTIMESH: { Item::CommandMultiMesh *mmesh = static_cast(command); - RasterizerStorageOpenGL::MultiMesh *multi_mesh = storage->multimesh_owner.get_or_null(mmesh->multimesh); + RasterizerStorageGLES3::MultiMesh *multi_mesh = storage->multimesh_owner.get_or_null(mmesh->multimesh); if (!multi_mesh) break; - RasterizerStorageOpenGL::Mesh *mesh_data = storage->mesh_owner.get_or_null(multi_mesh->mesh); + RasterizerStorageGLES3::Mesh *mesh_data = storage->mesh_owner.get_or_null(multi_mesh->mesh); if (!mesh_data) break; - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != RS::MULTIMESH_CUSTOM_DATA_NONE); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_INSTANCING, true); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != RS::MULTIMESH_CUSTOM_DATA_NONE); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCING, true); _set_texture_rect_mode(false); if (state.canvas_shader.bind()) { @@ -951,11 +952,11 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It state.canvas_shader.use_material((void *)p_material); } - RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(mmesh->texture, mmesh->normal_map); + RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(mmesh->texture, mmesh->normal_map); if (texture) { Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size); + state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size); } //reset shader and force rebind @@ -976,7 +977,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It const float *base_buffer = multi_mesh->data.ptr(); for (int j = 0; j < mesh_data->surfaces.size(); j++) { - RasterizerStorageOpenGL::Surface *s = mesh_data->surfaces[j]; + RasterizerStorageGLES3::Surface *s = mesh_data->surfaces[j]; // materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing //bind buffers for mesh surface @@ -1050,8 +1051,8 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It // LIGHT ANGLE PR replaced USE_INSTANCE_CUSTOM line with below .. think it was a typo, // but just in case, made this note. //_set_texture_rect_mode(false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_INSTANCE_CUSTOM, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_INSTANCING, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCE_CUSTOM, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCING, false); storage->info.render._2d_draw_call_count++; } break; @@ -1117,11 +1118,11 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It ERR_CONTINUE(primitive->points.size() < 1); - RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(primitive->texture, primitive->normal_map); + RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(primitive->texture, primitive->normal_map); if (texture) { Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size); + state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size); } // we need a temporary because this must be nulled out @@ -1150,7 +1151,7 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It case Item::Command::TYPE_TRANSFORM: { Item::CommandTransform *transform = static_cast(command); state.uniforms.extra_matrix = transform->xform; - state.canvas_shader.set_uniform(CanvasShaderOpenGL::EXTRA_MATRIX, state.uniforms.extra_matrix); + state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, state.uniforms.extra_matrix); } break; case Item::Command::TYPE_PARTICLES: { @@ -1195,25 +1196,25 @@ void RasterizerCanvasOpenGL::render_batches(Item::Command *const *p_commands, It } } -void RasterizerCanvasOpenGL::canvas_end() { +void RasterizerCanvasGLES3::canvas_end() { batch_canvas_end(); - RasterizerCanvasBaseOpenGL::canvas_end(); + RasterizerCanvasBaseGLES3::canvas_end(); } -void RasterizerCanvasOpenGL::canvas_begin() { +void RasterizerCanvasGLES3::canvas_begin() { batch_canvas_begin(); - RasterizerCanvasBaseOpenGL::canvas_begin(); + RasterizerCanvasBaseGLES3::canvas_begin(); } -void RasterizerCanvasOpenGL::canvas_render_items_begin(const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) { +void RasterizerCanvasGLES3::canvas_render_items_begin(const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) { batch_canvas_render_items_begin(p_modulate, p_light, p_base_transform); } -void RasterizerCanvasOpenGL::canvas_render_items_end() { +void RasterizerCanvasGLES3::canvas_render_items_end() { batch_canvas_render_items_end(); } -void RasterizerCanvasOpenGL::canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used) { +void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used) { storage->frame.current_rt = nullptr; // first set the current render target @@ -1235,13 +1236,13 @@ void RasterizerCanvasOpenGL::canvas_render_items(RID p_to_render_target, Item *p // canvas_end(); } -void RasterizerCanvasOpenGL::canvas_render_items_internal(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) { +void RasterizerCanvasGLES3::canvas_render_items_internal(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) { batch_canvas_render_items(p_item_list, p_z, p_modulate, p_light, p_base_transform); //glClearColor(Math::randf(), 0, 1, 1); } -void RasterizerCanvasOpenGL::canvas_render_items_implementation(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) { +void RasterizerCanvasGLES3::canvas_render_items_implementation(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) { // parameters are easier to pass around in a structure RenderItemState ris; ris.item_group_z = p_z; @@ -1249,7 +1250,7 @@ void RasterizerCanvasOpenGL::canvas_render_items_implementation(Item *p_item_lis ris.item_group_light = p_light; ris.item_group_base_transform = p_base_transform; - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_SKELETON, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_SKELETON, false); state.current_tex = RID(); state.current_tex_ptr = NULL; @@ -1269,12 +1270,12 @@ void RasterizerCanvasOpenGL::canvas_render_items_implementation(Item *p_item_lis glDisable(GL_SCISSOR_TEST); } - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_SKELETON, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_SKELETON, false); } // Legacy non-batched implementation for regression testing. // Should be removed after testing phase to avoid duplicate codepaths. -void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemState &r_ris) { +void RasterizerCanvasGLES3::_legacy_canvas_render_item(Item *p_ci, RenderItemState &r_ris) { storage->info.render._2d_item_count++; // defaults @@ -1325,7 +1326,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt } #if 0 - RasterizerStorageOpenGL::Skeleton *skeleton = NULL; + RasterizerStorageGLES3::Skeleton *skeleton = NULL; { //skeleton handling @@ -1343,7 +1344,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt bool use_skeleton = skeleton != NULL; if (r_ris.prev_use_skeleton != use_skeleton) { r_ris.rebind_shader = true; - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_SKELETON, use_skeleton); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_SKELETON, use_skeleton); r_ris.prev_use_skeleton = use_skeleton; } @@ -1360,10 +1361,10 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt Item *material_owner = p_ci->material_owner ? p_ci->material_owner : p_ci; RID material = material_owner->material; - RasterizerStorageOpenGL::Material *material_ptr = storage->material_owner.get_or_null(material); + RasterizerStorageGLES3::Material *material_ptr = storage->material_owner.get_or_null(material); if (material != r_ris.canvas_last_material || r_ris.rebind_shader) { - RasterizerStorageOpenGL::Shader *shader_ptr = NULL; + RasterizerStorageGLES3::Shader *shader_ptr = NULL; if (material_ptr) { shader_ptr = material_ptr->shader; @@ -1380,7 +1381,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt _copy_texscreen(Rect2()); // blend mode will have been enabled so make sure we disable it again later on - //last_blend_mode = last_blend_mode != RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_DISABLED ? last_blend_mode : -1; + //last_blend_mode = last_blend_mode != RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_DISABLED ? last_blend_mode : -1; } if (storage->frame.current_rt->copy_screen_effect.color) { @@ -1406,7 +1407,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt for (int i = 0; i < tc; i++) { glActiveTexture(GL_TEXTURE0 + i); - RasterizerStorageOpenGL::Texture *t = storage->texture_owner.get_or_null(textures[i].second); + RasterizerStorageGLES3::Texture *t = storage->texture_owner.get_or_null(textures[i].second); if (!t) { switch (texture_hints[i]) { @@ -1458,13 +1459,13 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt r_ris.rebind_shader = false; } - int blend_mode = r_ris.shader_cache ? r_ris.shader_cache->canvas_item.blend_mode : RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_MIX; - bool unshaded = r_ris.shader_cache && (r_ris.shader_cache->canvas_item.light_mode == RasterizerStorageOpenGL::Shader::CanvasItem::LIGHT_MODE_UNSHADED || (blend_mode != RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_MIX && blend_mode != RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_PMALPHA)); + int blend_mode = r_ris.shader_cache ? r_ris.shader_cache->canvas_item.blend_mode : RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX; + bool unshaded = r_ris.shader_cache && (r_ris.shader_cache->canvas_item.light_mode == RasterizerStorageGLES3::Shader::CanvasItem::LIGHT_MODE_UNSHADED || (blend_mode != RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX && blend_mode != RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_PMALPHA)); bool reclip = false; if (r_ris.last_blend_mode != blend_mode) { switch (blend_mode) { - case RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_MIX: { + case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX: { glBlendEquation(GL_FUNC_ADD); if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_TRANSPARENT]) { glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); @@ -1473,7 +1474,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt } } break; - case RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_ADD: { + case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_ADD: { glBlendEquation(GL_FUNC_ADD); if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_TRANSPARENT]) { glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE); @@ -1482,7 +1483,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt } } break; - case RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_SUB: { + case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_SUB: { glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_TRANSPARENT]) { glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_SRC_ALPHA, GL_ONE); @@ -1490,7 +1491,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE); } } break; - case RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_MUL: { + case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MUL: { glBlendEquation(GL_FUNC_ADD); if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_TRANSPARENT]) { glBlendFuncSeparate(GL_DST_COLOR, GL_ZERO, GL_DST_ALPHA, GL_ZERO); @@ -1498,7 +1499,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt glBlendFuncSeparate(GL_DST_COLOR, GL_ZERO, GL_ZERO, GL_ONE); } } break; - case RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_PMALPHA: { + case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_PMALPHA: { glBlendEquation(GL_FUNC_ADD); if (storage->frame.current_rt && storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_TRANSPARENT]) { glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); @@ -1516,12 +1517,12 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt _set_uniforms(); - if (unshaded || (state.uniforms.final_modulate.a > 0.001 && (!r_ris.shader_cache || r_ris.shader_cache->canvas_item.light_mode != RasterizerStorageOpenGL::Shader::CanvasItem::LIGHT_MODE_LIGHT_ONLY) && !p_ci->light_masked)) + if (unshaded || (state.uniforms.final_modulate.a > 0.001 && (!r_ris.shader_cache || r_ris.shader_cache->canvas_item.light_mode != RasterizerStorageGLES3::Shader::CanvasItem::LIGHT_MODE_LIGHT_ONLY) && !p_ci->light_masked)) _legacy_canvas_item_render_commands(p_ci, NULL, reclip, material_ptr); r_ris.rebind_shader = true; // hacked in for now. - if ((blend_mode == RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_MIX || blend_mode == RasterizerStorageOpenGL::Shader::CanvasItem::BLEND_MODE_PMALPHA) && r_ris.item_group_light && !unshaded) { + if ((blend_mode == RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX || blend_mode == RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_PMALPHA) && r_ris.item_group_light && !unshaded) { Light *light = r_ris.item_group_light; bool light_used = false; RS::CanvasLightBlendMode bmode = RS::CANVAS_LIGHT_BLEND_MODE_ADD; @@ -1554,7 +1555,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt } if (!light_used) { - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_LIGHTING, true); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_LIGHTING, true); light_used = true; } @@ -1562,20 +1563,20 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt //bool has_shadow = light->shadow_buffer.is_valid() && p_ci->light_mask & light->item_shadow_mask; bool has_shadow = light->use_shadow && p_ci->light_mask & light->item_shadow_mask; - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_SHADOWS, has_shadow); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_SHADOWS, has_shadow); if (has_shadow) { // FTODO - //state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_USE_GRADIENT, light->shadow_gradient_length > 0); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_USE_GRADIENT, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_NEAREST, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_NONE); - //state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF3, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF3); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF3, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF5, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF5); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF7, false); - //state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF7, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF7); - //state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF9, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF9); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF9, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF13, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF13); + //state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_USE_GRADIENT, light->shadow_gradient_length > 0); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_USE_GRADIENT, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_NEAREST, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_NONE); + //state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF3, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF3); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF3, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF5, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF5); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF7, false); + //state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF7, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF7); + //state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF9, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF9); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF9, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF13, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF13); } state.canvas_shader.bind(); @@ -1587,7 +1588,7 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt state.canvas_shader.use_material((void *)material_ptr); glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 6); - RasterizerStorageOpenGL::Texture *t = storage->texture_owner.get_or_null(light->texture); + RasterizerStorageGLES3::Texture *t = storage->texture_owner.get_or_null(light->texture); if (!t) { glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex); } else { @@ -1606,14 +1607,14 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt } if (light_used) { - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_LIGHTING, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_SHADOWS, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_NEAREST, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF3, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF5, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF7, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF9, false); - state.canvas_shader.set_conditional(CanvasShaderOpenGL::SHADOW_FILTER_PCF13, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_LIGHTING, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_SHADOWS, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_NEAREST, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF3, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF5, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF7, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF9, false); + state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF13, false); state.canvas_shader.bind(); @@ -1623,9 +1624,9 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt //this is set again, so it should not be needed anyway? state.canvas_item_modulate = unshaded ? ci->final_modulate : Color(ci->final_modulate.r * p_modulate.r, ci->final_modulate.g * p_modulate.g, ci->final_modulate.b * p_modulate.b, ci->final_modulate.a * p_modulate.a); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.final_transform); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::EXTRA_MATRIX, Transform2D()); - state.canvas_shader.set_uniform(CanvasShaderOpenGL::FINAL_MODULATE, state.canvas_item_modulate); + state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX, state.final_transform); + state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX, Transform2D()); + state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE, state.canvas_item_modulate); glBlendEquation(GL_FUNC_ADD); @@ -1650,17 +1651,17 @@ void RasterizerCanvasOpenGL::_legacy_canvas_render_item(Item *p_ci, RenderItemSt } } -void RasterizerCanvasOpenGL::gl_enable_scissor(int p_x, int p_y, int p_width, int p_height) const { +void RasterizerCanvasGLES3::gl_enable_scissor(int p_x, int p_y, int p_width, int p_height) const { glEnable(GL_SCISSOR_TEST); glScissor(p_x, p_y, p_width, p_height); } -void RasterizerCanvasOpenGL::gl_disable_scissor() const { +void RasterizerCanvasGLES3::gl_disable_scissor() const { glDisable(GL_SCISSOR_TEST); } -void RasterizerCanvasOpenGL::initialize() { - RasterizerCanvasBaseOpenGL::initialize(); +void RasterizerCanvasGLES3::initialize() { + RasterizerCanvasBaseGLES3::initialize(); batch_initialize(); @@ -1701,8 +1702,8 @@ void RasterizerCanvasOpenGL::initialize() { } // only if there is a vertex buffer (batching is on) } -RasterizerCanvasOpenGL::RasterizerCanvasOpenGL() { +RasterizerCanvasGLES3::RasterizerCanvasGLES3() { batch_constructor(); } -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED diff --git a/drivers/opengl/rasterizer_canvas_opengl.h b/drivers/gles3/rasterizer_canvas_gles3.h similarity index 84% rename from drivers/opengl/rasterizer_canvas_opengl.h rename to drivers/gles3/rasterizer_canvas_gles3.h index ff5295e7395..3d5cd705b76 100644 --- a/drivers/opengl/rasterizer_canvas_opengl.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rasterizer_canvas_opengl.h */ +/* rasterizer_canvas_gles3.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,16 +31,16 @@ #ifndef RASTERIZER_CANVAS_OPENGL_H #define RASTERIZER_CANVAS_OPENGL_H -#include "drivers/opengl/rasterizer_platforms.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "drivers/gles3/rasterizer_platforms.h" +#ifdef GLES3_BACKEND_ENABLED -#include "drivers/opengl/rasterizer_canvas_batcher.h" -#include "rasterizer_canvas_base_opengl.h" +#include "drivers/gles3/rasterizer_canvas_batcher.h" +#include "rasterizer_canvas_base_gles3.h" -class RasterizerSceneOpenGL; +class RasterizerSceneGLES3; -class RasterizerCanvasOpenGL : public RasterizerCanvasBaseOpenGL, public RasterizerCanvasBatcher { - friend class RasterizerCanvasBatcher; +class RasterizerCanvasGLES3 : public RasterizerCanvasBaseGLES3, public RasterizerCanvasBatcher { + friend class RasterizerCanvasBatcher; private: // legacy codepath .. to remove after testing @@ -48,7 +48,7 @@ private: // high level batch funcs void canvas_render_items_implementation(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform); - void render_batches(Item::Command *const *p_commands, Item *p_current_clip, bool &r_reclip, RasterizerStorageOpenGL::Material *p_material); + void render_batches(Item::Command *const *p_commands, Item *p_current_clip, bool &r_reclip, RasterizerStorageGLES3::Material *p_material); // funcs used from rasterizer_canvas_batcher template void gl_enable_scissor(int p_x, int p_y, int p_width, int p_height) const; @@ -64,8 +64,8 @@ public: void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used) override; void initialize(); - RasterizerCanvasOpenGL(); + RasterizerCanvasGLES3(); }; -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED #endif // RASTERIZER_CANVAS_OPENGL_H diff --git a/drivers/opengl/rasterizer_opengl.cpp b/drivers/gles3/rasterizer_gles3.cpp similarity index 92% rename from drivers/opengl/rasterizer_opengl.cpp rename to drivers/gles3/rasterizer_gles3.cpp index b7eef805c04..10093d42a3d 100644 --- a/drivers/opengl/rasterizer_opengl.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rasterizer_opengl.cpp */ +/* rasterizer_gles3.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,10 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "rasterizer_opengl.h" +#include "rasterizer_gles3.h" -#ifdef OPENGL_BACKEND_ENABLED -#include "shader_opengl.h" +#ifdef GLES3_BACKEND_ENABLED +#include "shader_gles3.h" #include "core/config/project_settings.h" #include "core/os/os.h" @@ -75,9 +75,9 @@ #endif #if !defined(GLES_OVER_GL) && defined(CAN_DEBUG) -#include -#include -#include +#include +#include +#include #include #include @@ -87,7 +87,7 @@ #define strcpy strcpy_s #endif -void RasterizerOpenGL::begin_frame(double frame_step) { +void RasterizerGLES3::begin_frame(double frame_step) { frame++; delta = frame_step; @@ -117,7 +117,7 @@ void RasterizerOpenGL::begin_frame(double frame_step) { //scene->iteration(); } -void RasterizerOpenGL::end_frame(bool p_swap_buffers) { +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()) { //clear alpha @@ -184,7 +184,7 @@ static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GL ERR_PRINT(output); } -#endif // CAN_DEBUG +#endif typedef void (*DEBUGPROCARB)(GLenum source, GLenum type, @@ -196,7 +196,7 @@ typedef void (*DEBUGPROCARB)(GLenum source, typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam); -void RasterizerOpenGL::initialize() { +void RasterizerGLES3::initialize() { print_verbose("Using OpenGL video driver"); storage._main_thread_id = Thread::get_caller_id(); @@ -261,7 +261,7 @@ void RasterizerOpenGL::initialize() { OS::get_singleton()->set_render_main_thread_mode(OS::RENDER_MAIN_THREAD_ONLY); } -RasterizerOpenGL::RasterizerOpenGL() { +RasterizerGLES3::RasterizerGLES3() { canvas.storage = &storage; canvas.scene_render = &scene; storage.canvas = &canvas; @@ -269,15 +269,15 @@ RasterizerOpenGL::RasterizerOpenGL() { storage.scene = &scene; } -void RasterizerOpenGL::prepare_for_blitting_render_targets() { +void RasterizerGLES3::prepare_for_blitting_render_targets() { } -void RasterizerOpenGL::_blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect) { +void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect) { ERR_FAIL_COND(storage.frame.current_rt); // print_line("_blit_render_target_to_screen " + itos (p_screen) + ", rect " + String(Variant(p_screen_rect))); - RasterizerStorageOpenGL::RenderTarget *rt = storage.render_target_owner.get_or_null(p_render_target); + RasterizerStorageGLES3::RenderTarget *rt = storage.render_target_owner.get_or_null(p_render_target); ERR_FAIL_COND(!rt); canvas._set_texture_rect_mode(true); @@ -287,6 +287,7 @@ void RasterizerOpenGL::_blit_render_target_to_screen(RID p_render_target, const canvas.canvas_begin(); glDisable(GL_BLEND); + storage.bind_framebuffer_system(); glActiveTexture(GL_TEXTURE0 + storage.config.max_texture_image_units - 1); if (rt->external.fbo != 0) { glBindTexture(GL_TEXTURE_2D, rt->external.color); @@ -300,7 +301,7 @@ void RasterizerOpenGL::_blit_render_target_to_screen(RID p_render_target, const } // is this p_screen useless in a multi window environment? -void RasterizerOpenGL::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) { +void RasterizerGLES3::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) { // do this once off for all blits storage.bind_framebuffer_system(); @@ -316,7 +317,7 @@ void RasterizerOpenGL::blit_render_targets_to_screen(DisplayServer::WindowID p_s } } -void RasterizerOpenGL::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { +void RasterizerGLES3::set_boot_image(const Ref &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { if (p_image.is_null() || p_image->is_empty()) return; @@ -362,7 +363,7 @@ void RasterizerOpenGL::set_boot_image(const Ref &p_image, const Color &p_ screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor(); } - RasterizerStorageOpenGL::Texture *t = storage.texture_owner.get_or_null(texture); + RasterizerStorageGLES3::Texture *t = storage.texture_owner.get_or_null(texture); glActiveTexture(GL_TEXTURE0 + storage.config.max_texture_image_units - 1); glBindTexture(GL_TEXTURE_2D, t->tex_id); canvas.draw_generic_textured_rect(screenrect, Rect2(0, 0, 1, 1)); @@ -374,4 +375,4 @@ void RasterizerOpenGL::set_boot_image(const Ref &p_image, const Color &p_ end_frame(true); } -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED diff --git a/drivers/opengl/rasterizer_opengl.h b/drivers/gles3/rasterizer_gles3.h similarity index 86% rename from drivers/opengl/rasterizer_opengl.h rename to drivers/gles3/rasterizer_gles3.h index e72c23faf9d..8976b885226 100644 --- a/drivers/opengl/rasterizer_opengl.h +++ b/drivers/gles3/rasterizer_gles3.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rasterizer_opengl.h */ +/* rasterizer_gles3.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,15 +31,15 @@ #ifndef RASTERIZER_OPENGL_H #define RASTERIZER_OPENGL_H -#include "drivers/opengl/rasterizer_platforms.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "drivers/gles3/rasterizer_platforms.h" +#ifdef GLES3_BACKEND_ENABLED -#include "rasterizer_canvas_opengl.h" -#include "rasterizer_scene_opengl.h" -#include "rasterizer_storage_opengl.h" +#include "rasterizer_canvas_gles3.h" +#include "rasterizer_scene_gles3.h" +#include "rasterizer_storage_gles3.h" #include "servers/rendering/renderer_compositor.h" -class RasterizerOpenGL : public RendererCompositor { +class RasterizerGLES3 : public RendererCompositor { private: uint64_t frame = 1; float delta = 0; @@ -48,9 +48,9 @@ private: double time_scale = 1.0; protected: - RasterizerCanvasOpenGL canvas; - RasterizerStorageOpenGL storage; - RasterizerSceneOpenGL scene; + RasterizerCanvasGLES3 canvas; + RasterizerStorageGLES3 storage; + RasterizerSceneGLES3 scene; void _blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect); @@ -72,7 +72,7 @@ public: void finalize() {} static RendererCompositor *_create_current() { - return memnew(RasterizerOpenGL); + return memnew(RasterizerGLES3); } static void make_current() { @@ -83,10 +83,10 @@ public: uint64_t get_frame_number() const { return frame; } double get_frame_delta_time() const { return delta; } - RasterizerOpenGL(); - ~RasterizerOpenGL() {} + RasterizerGLES3(); + ~RasterizerGLES3() {} }; -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED #endif diff --git a/drivers/opengl/rasterizer_platforms.h b/drivers/gles3/rasterizer_platforms.h similarity index 93% rename from drivers/opengl/rasterizer_platforms.h rename to drivers/gles3/rasterizer_platforms.h index effae518192..5d520c4d981 100644 --- a/drivers/opengl/rasterizer_platforms.h +++ b/drivers/gles3/rasterizer_platforms.h @@ -36,13 +36,13 @@ //#ifndef X11_ENABLED //#define X11_ENABLED //#endif -//#define OPENGL_BACKEND_ENABLED +//#define GLES3_BACKEND_ENABLED ///////////////////////////////////////////////////// -#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) +#if defined(GLES3_ENABLED) || defined(GLES_ENABLED) -#define OPENGL_BACKEND_ENABLED +#define GLES3_BACKEND_ENABLED -#endif // defined(OPENGL_ENABLED) || defined(GLES_ENABLED) +#endif // defined(GLES3_ENABLED) || defined(GLES_ENABLED) #endif // RASTERIZER_PLATFORMS_H diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp new file mode 100644 index 00000000000..e66bde90fed --- /dev/null +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -0,0 +1,466 @@ +/*************************************************************************/ +/* rasterizer_scene_gles3.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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. */ +/*************************************************************************/ + +#include "rasterizer_scene_gles3.h" +#ifdef GLES3_BACKEND_ENABLED + +// TODO: 3D support not implemented yet. + +RasterizerSceneGLES3::GeometryInstance *RasterizerSceneGLES3::geometry_instance_create(RID p_base) { + return nullptr; +} + +void RasterizerSceneGLES3::geometry_instance_set_skeleton(GeometryInstance *p_geometry_instance, RID p_skeleton) { +} + +void RasterizerSceneGLES3::geometry_instance_set_material_override(GeometryInstance *p_geometry_instance, RID p_override) { +} + +void RasterizerSceneGLES3::geometry_instance_set_surface_materials(GeometryInstance *p_geometry_instance, const Vector &p_material) { +} + +void RasterizerSceneGLES3::geometry_instance_set_mesh_instance(GeometryInstance *p_geometry_instance, RID p_mesh_instance) { +} + +void RasterizerSceneGLES3::geometry_instance_set_transform(GeometryInstance *p_geometry_instance, const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabbb) { +} + +void RasterizerSceneGLES3::geometry_instance_set_layer_mask(GeometryInstance *p_geometry_instance, uint32_t p_layer_mask) { +} + +void RasterizerSceneGLES3::geometry_instance_set_lod_bias(GeometryInstance *p_geometry_instance, float p_lod_bias) { +} + +void RasterizerSceneGLES3::geometry_instance_set_transparency(GeometryInstance *p_geometry_instance, float p_transparency) { +} + +void RasterizerSceneGLES3::geometry_instance_set_fade_range(GeometryInstance *p_geometry_instance, bool p_enable_near, float p_near_begin, float p_near_end, bool p_enable_far, float p_far_begin, float p_far_end) { +} + +void RasterizerSceneGLES3::geometry_instance_set_parent_fade_alpha(GeometryInstance *p_geometry_instance, float p_alpha) { +} + +void RasterizerSceneGLES3::geometry_instance_set_use_baked_light(GeometryInstance *p_geometry_instance, bool p_enable) { +} + +void RasterizerSceneGLES3::geometry_instance_set_use_dynamic_gi(GeometryInstance *p_geometry_instance, bool p_enable) { +} + +void RasterizerSceneGLES3::geometry_instance_set_use_lightmap(GeometryInstance *p_geometry_instance, RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) { +} + +void RasterizerSceneGLES3::geometry_instance_set_lightmap_capture(GeometryInstance *p_geometry_instance, const Color *p_sh9) { +} + +void RasterizerSceneGLES3::geometry_instance_set_instance_shader_parameters_offset(GeometryInstance *p_geometry_instance, int32_t p_offset) { +} + +void RasterizerSceneGLES3::geometry_instance_set_cast_double_sided_shadows(GeometryInstance *p_geometry_instance, bool p_enable) { +} + +uint32_t RasterizerSceneGLES3::geometry_instance_get_pair_mask() { + return 0; +} + +void RasterizerSceneGLES3::geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) { +} + +void RasterizerSceneGLES3::geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) { +} + +void RasterizerSceneGLES3::geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) { +} + +void RasterizerSceneGLES3::geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) { +} + +void RasterizerSceneGLES3::geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) { +} + +void RasterizerSceneGLES3::geometry_instance_free(GeometryInstance *p_geometry_instance) { +} + +/* SHADOW ATLAS API */ + +RID RasterizerSceneGLES3::shadow_atlas_create() { + return RID(); +} + +void RasterizerSceneGLES3::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits) { +} + +void RasterizerSceneGLES3::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) { +} + +bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) { + return false; +} + +void RasterizerSceneGLES3::directional_shadow_atlas_set_size(int p_size, bool p_16_bits) { +} + +int RasterizerSceneGLES3::get_directional_light_shadow_size(RID p_light_intance) { + return 0; +} + +void RasterizerSceneGLES3::set_directional_shadow_count(int p_count) { +} + +/* SDFGI UPDATE */ + +void RasterizerSceneGLES3::sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position) { +} + +int RasterizerSceneGLES3::sdfgi_get_pending_region_count(RID p_render_buffers) const { + return 0; +} + +AABB RasterizerSceneGLES3::sdfgi_get_pending_region_bounds(RID p_render_buffers, int p_region) const { + return AABB(); +} + +uint32_t RasterizerSceneGLES3::sdfgi_get_pending_region_cascade(RID p_render_buffers, int p_region) const { + return 0; +} + +/* SKY API */ + +RID RasterizerSceneGLES3::sky_allocate() { + return RID(); +} + +void RasterizerSceneGLES3::sky_initialize(RID p_rid) { +} + +void RasterizerSceneGLES3::sky_set_radiance_size(RID p_sky, int p_radiance_size) { +} + +void RasterizerSceneGLES3::sky_set_mode(RID p_sky, RS::SkyMode p_samples) { +} + +void RasterizerSceneGLES3::sky_set_material(RID p_sky, RID p_material) { +} + +Ref RasterizerSceneGLES3::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) { + return Ref(); +} + +/* ENVIRONMENT API */ + +RID RasterizerSceneGLES3::environment_allocate() { + return RID(); +} + +void RasterizerSceneGLES3::environment_initialize(RID p_rid) { +} + +void RasterizerSceneGLES3::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) { +} + +void RasterizerSceneGLES3::environment_set_sky(RID p_env, RID p_sky) { +} + +void RasterizerSceneGLES3::environment_set_sky_custom_fov(RID p_env, float p_scale) { +} + +void RasterizerSceneGLES3::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) { +} + +void RasterizerSceneGLES3::environment_set_bg_color(RID p_env, const Color &p_color) { +} + +void RasterizerSceneGLES3::environment_set_bg_energy(RID p_env, float p_energy) { +} + +void RasterizerSceneGLES3::environment_set_canvas_max_layer(RID p_env, int p_max_layer) { +} + +void RasterizerSceneGLES3::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source) { +} + +void RasterizerSceneGLES3::environment_set_glow(RID p_env, bool p_enable, Vector p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) { +} + +void RasterizerSceneGLES3::environment_glow_set_use_bicubic_upscale(bool p_enable) { +} + +void RasterizerSceneGLES3::environment_glow_set_use_high_quality(bool p_enable) { +} + +void RasterizerSceneGLES3::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) { +} + +void RasterizerSceneGLES3::environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) { +} + +void RasterizerSceneGLES3::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) { +} + +void RasterizerSceneGLES3::environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) { +} + +void RasterizerSceneGLES3::environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) { +} + +void RasterizerSceneGLES3::environment_set_sdfgi_ray_count(RS::EnvironmentSDFGIRayCount p_ray_count) { +} + +void RasterizerSceneGLES3::environment_set_sdfgi_frames_to_converge(RS::EnvironmentSDFGIFramesToConverge p_frames) { +} + +void RasterizerSceneGLES3::environment_set_sdfgi_frames_to_update_light(RS::EnvironmentSDFGIFramesToUpdateLight p_update) { +} + +void RasterizerSceneGLES3::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) { +} + +void RasterizerSceneGLES3::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) { +} + +void RasterizerSceneGLES3::environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_aerial_perspective) { +} + +void RasterizerSceneGLES3::environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_albedo, const Color &p_emission, float p_emission_energy, float p_anisotropy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount, float p_ambient_inject) { +} + +void RasterizerSceneGLES3::environment_set_volumetric_fog_volume_size(int p_size, int p_depth) { +} + +void RasterizerSceneGLES3::environment_set_volumetric_fog_filter_active(bool p_enable) { +} + +Ref RasterizerSceneGLES3::environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) { + return Ref(); +} + +bool RasterizerSceneGLES3::is_environment(RID p_env) const { + return false; +} + +RS::EnvironmentBG RasterizerSceneGLES3::environment_get_background(RID p_env) const { + return RS::ENV_BG_KEEP; +} + +int RasterizerSceneGLES3::environment_get_canvas_max_layer(RID p_env) const { + return 0; +} + +RID RasterizerSceneGLES3::camera_effects_allocate() { + return RID(); +} + +void RasterizerSceneGLES3::camera_effects_initialize(RID p_rid) { +} + +void RasterizerSceneGLES3::camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) { +} + +void RasterizerSceneGLES3::camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) { +} + +void RasterizerSceneGLES3::camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) { +} + +void RasterizerSceneGLES3::camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) { +} + +void RasterizerSceneGLES3::shadows_quality_set(RS::ShadowQuality p_quality) { +} + +void RasterizerSceneGLES3::directional_shadow_quality_set(RS::ShadowQuality p_quality) { +} + +RID RasterizerSceneGLES3::light_instance_create(RID p_light) { + return RID(); +} + +void RasterizerSceneGLES3::light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) { +} + +void RasterizerSceneGLES3::light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) { +} + +void RasterizerSceneGLES3::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale, float p_range_begin, const Vector2 &p_uv_scale) { +} + +void RasterizerSceneGLES3::light_instance_mark_visible(RID p_light_instance) { +} + +RID RasterizerSceneGLES3::fog_volume_instance_create(RID p_fog_volume) { + return RID(); +} + +void RasterizerSceneGLES3::fog_volume_instance_set_transform(RID p_fog_volume_instance, const Transform3D &p_transform) { +} + +void RasterizerSceneGLES3::fog_volume_instance_set_active(RID p_fog_volume_instance, bool p_active) { +} + +RID RasterizerSceneGLES3::fog_volume_instance_get_volume(RID p_fog_volume_instance) const { + return RID(); +} + +Vector3 RasterizerSceneGLES3::fog_volume_instance_get_position(RID p_fog_volume_instance) const { + return Vector3(); +} + +RID RasterizerSceneGLES3::reflection_atlas_create() { + return RID(); +} + +int RasterizerSceneGLES3::reflection_atlas_get_size(RID p_ref_atlas) const { + return 0; +} + +void RasterizerSceneGLES3::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) { +} + +RID RasterizerSceneGLES3::reflection_probe_instance_create(RID p_probe) { + return RID(); +} + +void RasterizerSceneGLES3::reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) { +} + +void RasterizerSceneGLES3::reflection_probe_release_atlas_index(RID p_instance) { +} + +bool RasterizerSceneGLES3::reflection_probe_instance_needs_redraw(RID p_instance) { + return false; +} + +bool RasterizerSceneGLES3::reflection_probe_instance_has_reflection(RID p_instance) { + return false; +} + +bool RasterizerSceneGLES3::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) { + return false; +} + +bool RasterizerSceneGLES3::reflection_probe_instance_postprocess_step(RID p_instance) { + return true; +} + +RID RasterizerSceneGLES3::decal_instance_create(RID p_decal) { + return RID(); +} + +void RasterizerSceneGLES3::decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) { +} + +RID RasterizerSceneGLES3::lightmap_instance_create(RID p_lightmap) { + return RID(); +} + +void RasterizerSceneGLES3::lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) { +} + +RID RasterizerSceneGLES3::voxel_gi_instance_create(RID p_voxel_gi) { + return RID(); +} + +void RasterizerSceneGLES3::voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) { +} + +bool RasterizerSceneGLES3::voxel_gi_needs_update(RID p_probe) const { + return false; +} + +void RasterizerSceneGLES3::voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector &p_light_instances, const PagedArray &p_dynamic_objects) { +} + +void RasterizerSceneGLES3::voxel_gi_set_quality(RS::VoxelGIQuality) { +} + +void RasterizerSceneGLES3::render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray &p_instances, const PagedArray &p_lights, const PagedArray &p_reflection_probes, const PagedArray &p_voxel_gi_instances, const PagedArray &p_decals, const PagedArray &p_lightmaps, const PagedArray &p_fog_volumes, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data, RendererScene::RenderInfo *r_render_info) { +} + +void RasterizerSceneGLES3::render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray &p_instances, RID p_framebuffer, const Rect2i &p_region) { +} + +void RasterizerSceneGLES3::render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray &p_instances) { +} + +void RasterizerSceneGLES3::set_scene_pass(uint64_t p_pass) { +} + +void RasterizerSceneGLES3::set_time(double p_time, double p_step) { +} + +void RasterizerSceneGLES3::set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) { +} + +RID RasterizerSceneGLES3::render_buffers_create() { + return RID(); +} + +void RasterizerSceneGLES3::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) { +} + +void RasterizerSceneGLES3::gi_set_use_half_resolution(bool p_enable) { +} + +void RasterizerSceneGLES3::screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_curve) { +} + +bool RasterizerSceneGLES3::screen_space_roughness_limiter_is_active() const { + return false; +} + +void RasterizerSceneGLES3::sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) { +} + +void RasterizerSceneGLES3::sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) { +} + +TypedArray RasterizerSceneGLES3::bake_render_uv2(RID p_base, const Vector &p_material_overrides, const Size2i &p_image_size) { + return TypedArray(); +} + +bool RasterizerSceneGLES3::free(RID p_rid) { + return false; +} + +void RasterizerSceneGLES3::update() { +} + +void RasterizerSceneGLES3::sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) { +} + +void RasterizerSceneGLES3::decals_set_filter(RS::DecalFilter p_filter) { +} + +void RasterizerSceneGLES3::light_projectors_set_filter(RS::LightProjectorFilter p_filter) { +} + +RasterizerSceneGLES3::RasterizerSceneGLES3() { +} + +#endif // GLES3_BACKEND_ENABLED diff --git a/drivers/opengl/rasterizer_scene_opengl.h b/drivers/gles3/rasterizer_scene_gles3.h similarity index 88% rename from drivers/opengl/rasterizer_scene_opengl.h rename to drivers/gles3/rasterizer_scene_gles3.h index 2ae7633ba3a..e8d257087f6 100644 --- a/drivers/opengl/rasterizer_scene_opengl.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rasterizer_scene_opengl.h */ +/* rasterizer_scene_gles3.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,8 +31,8 @@ #ifndef RASTERIZER_SCENE_OPENGL_H #define RASTERIZER_SCENE_OPENGL_H -#include "drivers/opengl/rasterizer_platforms.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "drivers/gles3/rasterizer_platforms.h" +#ifdef GLES3_BACKEND_ENABLED #include "core/math/camera_matrix.h" #include "core/templates/rid_owner.h" @@ -43,10 +43,10 @@ #include "servers/rendering_server.h" #include "shaders/scene.glsl.gen.h" -class RasterizerSceneOpenGL : public RendererSceneRender { +class RasterizerSceneGLES3 : public RendererSceneRender { public: struct State { - SceneShaderOpenGL scene_shader; + SceneShaderGLES3 scene_shader; } state; GeometryInstance *geometry_instance_create(RID p_base) override; @@ -57,6 +57,9 @@ public: void geometry_instance_set_transform(GeometryInstance *p_geometry_instance, const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabbb) override; void geometry_instance_set_layer_mask(GeometryInstance *p_geometry_instance, uint32_t p_layer_mask) override; void geometry_instance_set_lod_bias(GeometryInstance *p_geometry_instance, float p_lod_bias) override; + void geometry_instance_set_transparency(GeometryInstance *p_geometry_instance, float p_transparency) override; + void geometry_instance_set_fade_range(GeometryInstance *p_geometry_instance, bool p_enable_near, float p_near_begin, float p_near_end, bool p_enable_far, float p_far_begin, float p_far_end) override; + void geometry_instance_set_parent_fade_alpha(GeometryInstance *p_geometry_instance, float p_alpha) override; void geometry_instance_set_use_baked_light(GeometryInstance *p_geometry_instance, bool p_enable) override; void geometry_instance_set_use_dynamic_gi(GeometryInstance *p_geometry_instance, bool p_enable) override; void geometry_instance_set_use_lightmap(GeometryInstance *p_geometry_instance, RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) override; @@ -133,7 +136,7 @@ public: void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) override; void environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_aerial_perspective) override; - void environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount) override; + void environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_albedo, const Color &p_emission, float p_emission_energy, float p_anisotropy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount, float p_ambient_inject) override; void environment_set_volumetric_fog_volume_size(int p_size, int p_depth) override; void environment_set_volumetric_fog_filter_active(bool p_enable) override; @@ -160,6 +163,12 @@ public: void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale = 1.0, float p_range_begin = 0, const Vector2 &p_uv_scale = Vector2()) override; void light_instance_mark_visible(RID p_light_instance) override; + RID fog_volume_instance_create(RID p_fog_volume) override; + void fog_volume_instance_set_transform(RID p_fog_volume_instance, const Transform3D &p_transform) override; + void fog_volume_instance_set_active(RID p_fog_volume_instance, bool p_active) override; + RID fog_volume_instance_get_volume(RID p_fog_volume_instance) const override; + Vector3 fog_volume_instance_get_position(RID p_fog_volume_instance) const override; + RID reflection_atlas_create() override; int reflection_atlas_get_size(RID p_ref_atlas) const override; void reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) override; @@ -185,7 +194,7 @@ public: void voxel_gi_set_quality(RS::VoxelGIQuality) override; - void render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray &p_instances, const PagedArray &p_lights, const PagedArray &p_reflection_probes, const PagedArray &p_voxel_gi_instances, const PagedArray &p_decals, const PagedArray &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RendererScene::RenderInfo *r_info = nullptr) override; + void render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray &p_instances, const PagedArray &p_lights, const PagedArray &p_reflection_probes, const PagedArray &p_voxel_gi_instances, const PagedArray &p_decals, const PagedArray &p_lightmaps, const PagedArray &p_fog_volumes, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RendererScene::RenderInfo *r_render_info = nullptr) override; void render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray &p_instances, RID p_framebuffer, const Rect2i &p_region) override; void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray &p_instances) override; @@ -212,9 +221,9 @@ public: void decals_set_filter(RS::DecalFilter p_filter) override; void light_projectors_set_filter(RS::LightProjectorFilter p_filter) override; - RasterizerSceneOpenGL(); + RasterizerSceneGLES3(); }; -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED #endif // RASTERIZER_SCENE_OPENGL_H diff --git a/drivers/opengl/rasterizer_storage_common.h b/drivers/gles3/rasterizer_storage_common.h similarity index 100% rename from drivers/opengl/rasterizer_storage_common.h rename to drivers/gles3/rasterizer_storage_common.h diff --git a/drivers/opengl/rasterizer_storage_opengl.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp similarity index 71% rename from drivers/opengl/rasterizer_storage_opengl.cpp rename to drivers/gles3/rasterizer_storage_gles3.cpp index 99665dcbb85..1feb2c224e2 100644 --- a/drivers/opengl/rasterizer_storage_opengl.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rasterizer_storage_opengl.cpp */ +/* rasterizer_storage_gles3.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -30,17 +30,17 @@ //#define OPENGL_DISABLE_RENDER_TARGETS -#include "rasterizer_storage_opengl.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "rasterizer_storage_gles3.h" +#ifdef GLES3_BACKEND_ENABLED #include "core/config/project_settings.h" #include "core/math/transform_3d.h" -#include "drivers/opengl/rasterizer_storage_common.h" -#include "rasterizer_canvas_opengl.h" -#include "rasterizer_scene_opengl.h" +#include "drivers/gles3/rasterizer_storage_common.h" +#include "rasterizer_canvas_gles3.h" +#include "rasterizer_scene_gles3.h" #include "servers/rendering/shader_language.h" -GLuint RasterizerStorageOpenGL::system_fbo = 0; +GLuint RasterizerStorageGLES3::system_fbo = 0; /* TEXTURE API */ @@ -89,50 +89,22 @@ GLuint RasterizerStorageOpenGL::system_fbo = 0; #ifndef GLES_OVER_GL #define glClearDepth glClearDepthf - -// enable extensions manually for android and ios -#ifndef UWP_ENABLED -#include // needed to load extensions -#endif - -#ifdef IPHONE_ENABLED - -#include -//void *glRenderbufferStorageMultisampleAPPLE; -//void *glResolveMultisampleFramebufferAPPLE; -#define glRenderbufferStorageMultisample glRenderbufferStorageMultisampleAPPLE -#elif defined(ANDROID_ENABLED) - -#include -PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT; -PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC glFramebufferTexture2DMultisampleEXT; -#define glRenderbufferStorageMultisample glRenderbufferStorageMultisampleEXT -#define glFramebufferTexture2DMultisample glFramebufferTexture2DMultisampleEXT - -#elif defined(UWP_ENABLED) -#include -#define glRenderbufferStorageMultisample glRenderbufferStorageMultisampleANGLE -#define glFramebufferTexture2DMultisample glFramebufferTexture2DMultisampleANGLE -#endif - -#define GL_TEXTURE_3D 0x806F -#define GL_MAX_SAMPLES 0x8D57 #endif //!GLES_OVER_GL -void RasterizerStorageOpenGL::bind_quad_array() const { - glBindBuffer(GL_ARRAY_BUFFER, resources.quadie); - glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, 0); - glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(8)); +void RasterizerStorageGLES3::bind_quad_array() const { + //glBindBuffer(GL_ARRAY_BUFFER, resources.quadie); + //glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, 0); + //glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(8)); - glEnableVertexAttribArray(RS::ARRAY_VERTEX); - glEnableVertexAttribArray(RS::ARRAY_TEX_UV); + //glEnableVertexAttribArray(RS::ARRAY_VERTEX); + //glEnableVertexAttribArray(RS::ARRAY_TEX_UV); } -bool RasterizerStorageOpenGL::can_create_resources_async() const { +bool RasterizerStorageGLES3::can_create_resources_async() const { return false; } -Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const { +Ref RasterizerStorageGLES3::_get_gl_image_and_format(const Ref &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const { r_gl_format = 0; Ref image = p_image; r_compressed = false; @@ -142,131 +114,116 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p switch (p_format) { case Image::FORMAT_L8: { +#ifdef GLES_OVER_GL + r_gl_internal_format = GL_R8; + r_gl_format = GL_RED; + r_gl_type = GL_UNSIGNED_BYTE; +#else r_gl_internal_format = GL_LUMINANCE; r_gl_format = GL_LUMINANCE; r_gl_type = GL_UNSIGNED_BYTE; +#endif } break; case Image::FORMAT_LA8: { +#ifdef GLES_OVER_GL + r_gl_internal_format = GL_RG8; + r_gl_format = GL_RG; + r_gl_type = GL_UNSIGNED_BYTE; +#else r_gl_internal_format = GL_LUMINANCE_ALPHA; r_gl_format = GL_LUMINANCE_ALPHA; r_gl_type = GL_UNSIGNED_BYTE; +#endif } break; case Image::FORMAT_R8: { - r_gl_internal_format = GL_ALPHA; - r_gl_format = GL_ALPHA; + r_gl_internal_format = GL_R8; + r_gl_format = GL_RED; r_gl_type = GL_UNSIGNED_BYTE; } break; case Image::FORMAT_RG8: { - ERR_PRINT("RG texture not supported, converting to RGB8."); - if (image.is_valid()) - image->convert(Image::FORMAT_RGB8); - r_real_format = Image::FORMAT_RGB8; - r_gl_internal_format = GL_RGB; - r_gl_format = GL_RGB; + r_gl_internal_format = GL_RG8; + r_gl_format = GL_RG; r_gl_type = GL_UNSIGNED_BYTE; } break; case Image::FORMAT_RGB8: { - r_gl_internal_format = GL_RGB; + r_gl_internal_format = GL_RGB8; r_gl_format = GL_RGB; r_gl_type = GL_UNSIGNED_BYTE; + //r_srgb = true; } break; case Image::FORMAT_RGBA8: { r_gl_format = GL_RGBA; - r_gl_internal_format = GL_RGBA; + r_gl_internal_format = GL_RGBA8; r_gl_type = GL_UNSIGNED_BYTE; + //r_srgb = true; } break; case Image::FORMAT_RGBA4444: { - r_gl_internal_format = GL_RGBA; + r_gl_internal_format = GL_RGBA4; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_SHORT_4_4_4_4; } break; - // case Image::FORMAT_RGBA5551: { - // r_gl_internal_format = GL_RGB5_A1; - // r_gl_format = GL_RGBA; - // r_gl_type = GL_UNSIGNED_SHORT_5_5_5_1; - - // } break; + //case Image::FORMAT_RGBA5551: { + // r_gl_internal_format = GL_RGB5_A1; + // r_gl_format = GL_RGBA; + // r_gl_type = GL_UNSIGNED_SHORT_5_5_5_1; + // + //} break; case Image::FORMAT_RF: { - if (!config.float_texture_supported) { - ERR_PRINT("R float texture not supported, converting to RGB8."); - if (image.is_valid()) - image->convert(Image::FORMAT_RGB8); - r_real_format = Image::FORMAT_RGB8; - r_gl_internal_format = GL_RGB; - r_gl_format = GL_RGB; - r_gl_type = GL_UNSIGNED_BYTE; - } else { - r_gl_internal_format = GL_ALPHA; - r_gl_format = GL_ALPHA; - r_gl_type = GL_FLOAT; - } + r_gl_internal_format = GL_R32F; + r_gl_format = GL_RED; + r_gl_type = GL_FLOAT; + } break; case Image::FORMAT_RGF: { - ERR_PRINT("RG float texture not supported, converting to RGB8."); - if (image.is_valid()) - image->convert(Image::FORMAT_RGB8); - r_real_format = Image::FORMAT_RGB8; - r_gl_internal_format = GL_RGB; - r_gl_format = GL_RGB; - r_gl_type = GL_UNSIGNED_BYTE; + r_gl_internal_format = GL_RG32F; + r_gl_format = GL_RG; + r_gl_type = GL_FLOAT; + } break; case Image::FORMAT_RGBF: { - if (!config.float_texture_supported) { - ERR_PRINT("RGB float texture not supported, converting to RGB8."); - if (image.is_valid()) - image->convert(Image::FORMAT_RGB8); - r_real_format = Image::FORMAT_RGB8; - r_gl_internal_format = GL_RGB; - r_gl_format = GL_RGB; - r_gl_type = GL_UNSIGNED_BYTE; - } else { - r_gl_internal_format = GL_RGB; - r_gl_format = GL_RGB; - r_gl_type = GL_FLOAT; - } + r_gl_internal_format = GL_RGB32F; + r_gl_format = GL_RGB; + r_gl_type = GL_FLOAT; + } break; case Image::FORMAT_RGBAF: { - if (!config.float_texture_supported) { - ERR_PRINT("RGBA float texture not supported, converting to RGBA8."); - if (image.is_valid()) - image->convert(Image::FORMAT_RGBA8); - r_real_format = Image::FORMAT_RGBA8; - r_gl_internal_format = GL_RGBA; - r_gl_format = GL_RGBA; - r_gl_type = GL_UNSIGNED_BYTE; - } else { - r_gl_internal_format = GL_RGBA; - r_gl_format = GL_RGBA; - r_gl_type = GL_FLOAT; - } + r_gl_internal_format = GL_RGBA32F; + r_gl_format = GL_RGBA; + r_gl_type = GL_FLOAT; + } break; case Image::FORMAT_RH: { - need_decompress = true; + r_gl_internal_format = GL_R16F; + r_gl_format = GL_RED; + r_gl_type = GL_HALF_FLOAT; } break; case Image::FORMAT_RGH: { - need_decompress = true; + r_gl_internal_format = GL_RG16F; + r_gl_format = GL_RG; + r_gl_type = GL_HALF_FLOAT; + } break; case Image::FORMAT_RGBH: { - need_decompress = true; + r_gl_internal_format = GL_RGB16F; + r_gl_format = GL_RGB; + r_gl_type = GL_HALF_FLOAT; + } break; case Image::FORMAT_RGBAH: { - need_decompress = true; + r_gl_internal_format = GL_RGBA16F; + r_gl_format = GL_RGBA; + r_gl_type = GL_HALF_FLOAT; + } break; case Image::FORMAT_RGBE9995: { - r_gl_internal_format = GL_RGB; + r_gl_internal_format = GL_RGB9_E5; r_gl_format = GL_RGB; - r_gl_type = GL_UNSIGNED_BYTE; - - if (image.is_valid()) - - image = image->rgbe_to_srgb(); - - return image; + r_gl_type = GL_UNSIGNED_INT_5_9_9_9_REV; } break; case Image::FORMAT_DXT1: { @@ -275,10 +232,11 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; + //r_srgb = true; + } else { need_decompress = true; } - } break; case Image::FORMAT_DXT3: { if (config.s3tc_supported) { @@ -286,10 +244,11 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; + //r_srgb = true; + } else { need_decompress = true; } - } break; case Image::FORMAT_DXT5: { if (config.s3tc_supported) { @@ -297,10 +256,11 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; + //r_srgb = true; + } else { need_decompress = true; } - } break; case Image::FORMAT_RGTC_R: { if (config.rgtc_supported) { @@ -312,7 +272,6 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p } else { need_decompress = true; } - } break; case Image::FORMAT_RGTC_RG: { if (config.rgtc_supported) { @@ -323,7 +282,6 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p } else { need_decompress = true; } - } break; case Image::FORMAT_BPTC_RGBA: { if (config.bptc_supported) { @@ -331,6 +289,7 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; + //r_srgb = true; } else { need_decompress = true; @@ -362,6 +321,7 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; + //r_srgb = true; } else { need_decompress = true; @@ -373,6 +333,7 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; + //r_srgb = true; } else { need_decompress = true; @@ -385,6 +346,7 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; + //r_srgb = true; } else { need_decompress = true; @@ -397,6 +359,7 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; + //r_srgb = true; } else { need_decompress = true; @@ -404,38 +367,101 @@ Ref RasterizerStorageOpenGL::_get_gl_image_and_format(const Ref &p } break; case Image::FORMAT_ETC: { - if (config.etc1_supported) { + if (config.etc_supported) { r_gl_internal_format = _EXT_ETC1_RGB8_OES; r_gl_format = GL_RGBA; r_gl_type = GL_UNSIGNED_BYTE; r_compressed = true; + + } else { + need_decompress = true; + } + + } break; + /* + case Image::FORMAT_ETC2_R11: { + if (config.etc2_supported) { + r_gl_internal_format = _EXT_COMPRESSED_R11_EAC; + r_gl_format = GL_RED; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + } else { need_decompress = true; } } break; - case Image::FORMAT_ETC2_R11: { - need_decompress = true; - } break; case Image::FORMAT_ETC2_R11S: { - need_decompress = true; + if (config.etc2_supported) { + r_gl_internal_format = _EXT_COMPRESSED_SIGNED_R11_EAC; + r_gl_format = GL_RED; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + + } else { + need_decompress = true; + } } break; case Image::FORMAT_ETC2_RG11: { - need_decompress = true; + if (config.etc2_supported) { + r_gl_internal_format = _EXT_COMPRESSED_RG11_EAC; + r_gl_format = GL_RG; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + + } else { + need_decompress = true; + } } break; case Image::FORMAT_ETC2_RG11S: { - need_decompress = true; + if (config.etc2_supported) { + r_gl_internal_format = _EXT_COMPRESSED_SIGNED_RG11_EAC; + r_gl_format = GL_RG; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + + } else { + need_decompress = true; + } } break; case Image::FORMAT_ETC2_RGB8: { - need_decompress = true; + if (config.etc2_supported) { + r_gl_internal_format = _EXT_COMPRESSED_RGB8_ETC2; + r_gl_format = GL_RGB; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + //r_srgb = true; + + } else { + need_decompress = true; + } } break; case Image::FORMAT_ETC2_RGBA8: { - need_decompress = true; + if (config.etc2_supported) { + r_gl_internal_format = _EXT_COMPRESSED_RGBA8_ETC2_EAC; + r_gl_format = GL_RGBA; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + //r_srgb = true; + + } else { + need_decompress = true; + } } break; case Image::FORMAT_ETC2_RGB8A1: { - need_decompress = true; + if (config.etc2_supported) { + r_gl_internal_format = _EXT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + r_gl_format = GL_RGBA; + r_gl_type = GL_UNSIGNED_BYTE; + r_compressed = true; + //r_srgb = true; + + } else { + need_decompress = true; + } } break; + */ default: { - ERR_FAIL_V(p_image); + ERR_FAIL_V(Ref()); } } @@ -486,13 +512,13 @@ static const GLenum _cube_side_enum[6] = { GL_TEXTURE_CUBE_MAP_POSITIVE_Z, }; -RID RasterizerStorageOpenGL::texture_allocate() { +RID RasterizerStorageGLES3::texture_allocate() { RID id = texture_create(); ERR_FAIL_COND_V(id == RID(), id); return id; } -void RasterizerStorageOpenGL::texture_2d_initialize(RID p_texture, const Ref &p_image) { +void RasterizerStorageGLES3::texture_2d_initialize(RID p_texture, const Ref &p_image) { Texture *tex = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!tex); @@ -503,16 +529,17 @@ void RasterizerStorageOpenGL::texture_2d_initialize(RID p_texture, const Ref> &p_layers, RS::TextureLayeredType p_layered_type) { +void RasterizerStorageGLES3::texture_2d_layered_initialize(RID p_texture, const Vector> &p_layers, RS::TextureLayeredType p_layered_type) { } -void RasterizerStorageOpenGL::texture_3d_initialize(RID p_texture, Image::Format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector> &p_data) { +void RasterizerStorageGLES3::texture_3d_initialize(RID p_texture, Image::Format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector> &p_data) { } -void RasterizerStorageOpenGL::texture_proxy_initialize(RID p_texture, RID p_base) { +void RasterizerStorageGLES3::texture_proxy_initialize(RID p_texture, RID p_base) { + texture_set_proxy(p_texture, p_base); } -//RID RasterizerStorageOpenGL::texture_2d_create(const Ref &p_image) { +//RID RasterizerStorageGLES3::texture_2d_create(const Ref &p_image) { // RID id = texture_create(); // ERR_FAIL_COND_V(id == RID(), id); @@ -526,35 +553,29 @@ void RasterizerStorageOpenGL::texture_proxy_initialize(RID p_texture, RID p_base // return id; //} -//RID RasterizerStorageOpenGL::texture_2d_layered_create(const Vector> &p_layers, RS::TextureLayeredType p_layered_type) { +//RID RasterizerStorageGLES3::texture_2d_layered_create(const Vector> &p_layers, RS::TextureLayeredType p_layered_type) { // return RID(); //} -//RID RasterizerStorageOpenGL::texture_proxy_create(RID p_base) { -// RID link = texture_create(); -// texture_set_proxy(link, p_base); -// return link; -//} - -//void RasterizerStorageOpenGL::texture_2d_update_immediate(RID p_texture, const Ref &p_image, int p_layer) { +//void RasterizerStorageGLES3::texture_2d_update_immediate(RID p_texture, const Ref &p_image, int p_layer) { // // only 1 layer so far // texture_set_data(p_texture, p_image); //} -void RasterizerStorageOpenGL::texture_2d_update(RID p_texture, const Ref &p_image, int p_layer) { +void RasterizerStorageGLES3::texture_2d_update(RID p_texture, const Ref &p_image, int p_layer) { // only 1 layer so far texture_set_data(p_texture, p_image); } -void RasterizerStorageOpenGL::texture_2d_placeholder_initialize(RID p_texture) { +void RasterizerStorageGLES3::texture_2d_placeholder_initialize(RID p_texture) { } -void RasterizerStorageOpenGL::texture_2d_layered_placeholder_initialize(RID p_texture, RenderingServer::TextureLayeredType p_layered_type) { +void RasterizerStorageGLES3::texture_2d_layered_placeholder_initialize(RID p_texture, RenderingServer::TextureLayeredType p_layered_type) { } -void RasterizerStorageOpenGL::texture_3d_placeholder_initialize(RID p_texture) { +void RasterizerStorageGLES3::texture_3d_placeholder_initialize(RID p_texture) { } -Ref RasterizerStorageOpenGL::texture_2d_get(RID p_texture) const { +Ref RasterizerStorageGLES3::texture_2d_get(RID p_texture) const { Texture *tex = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!tex, Ref()); @@ -589,7 +610,7 @@ Ref RasterizerStorageOpenGL::texture_2d_get(RID p_texture) const { // return Ref(); } -void RasterizerStorageOpenGL::texture_replace(RID p_texture, RID p_by_texture) { +void RasterizerStorageGLES3::texture_replace(RID p_texture, RID p_by_texture) { Texture *tex_to = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!tex_to); Texture *tex_from = texture_owner.get_or_null(p_by_texture); @@ -606,7 +627,7 @@ void RasterizerStorageOpenGL::texture_replace(RID p_texture, RID p_by_texture) { } } -bool RasterizerStorageOpenGL::_is_main_thread() { +bool RasterizerStorageGLES3::_is_main_thread() { //#if defined DEBUG_ENABLED && defined TOOLS_ENABLED // must be called from main thread in OpenGL bool is_main_thread = _main_thread_id == Thread::get_caller_id(); @@ -614,7 +635,7 @@ bool RasterizerStorageOpenGL::_is_main_thread() { return is_main_thread; } -RID RasterizerStorageOpenGL::texture_create() { +RID RasterizerStorageGLES3::texture_create() { ERR_FAIL_COND_V(!_is_main_thread(), RID()); Texture *texture = memnew(Texture); @@ -626,7 +647,7 @@ RID RasterizerStorageOpenGL::texture_create() { return texture_owner.make_rid(texture); } -void RasterizerStorageOpenGL::_texture_allocate_internal(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, RenderingDevice::TextureType p_type, uint32_t p_flags) { +void RasterizerStorageGLES3::_texture_allocate_internal(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, RenderingDevice::TextureType p_type, uint32_t p_flags) { // GLenum format; // GLenum internal_format; // GLenum type; @@ -742,7 +763,7 @@ void RasterizerStorageOpenGL::_texture_allocate_internal(RID p_texture, int p_wi texture->active = true; } -void RasterizerStorageOpenGL::texture_set_data(RID p_texture, const Ref &p_image, int p_layer) { +void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref &p_image, int p_layer) { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!_is_main_thread()); @@ -811,6 +832,32 @@ void RasterizerStorageOpenGL::texture_set_data(RID p_texture, const Ref & // set filtering and repeat state _texture_set_state_from_flags(texture); + //set swizle for older format compatibility +#ifdef GLES_OVER_GL + switch (texture->format) { + case Image::FORMAT_L8: { + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_R, GL_RED); + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_G, GL_RED); + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_B, GL_RED); + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_A, GL_ONE); + + } break; + case Image::FORMAT_LA8: { + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_R, GL_RED); + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_G, GL_RED); + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_B, GL_RED); + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_A, GL_GREEN); + } break; + default: { + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_R, GL_RED); + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_G, GL_GREEN); + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_B, GL_BLUE); + glTexParameteri(texture->target, GL_TEXTURE_SWIZZLE_A, GL_ALPHA); + + } break; + } +#endif + int mipmaps = ((texture->flags & TEXTURE_FLAG_MIPMAPS) && img->has_mipmaps()) ? img->get_mipmap_count() + 1 : 1; int w = img->get_width(); @@ -860,13 +907,13 @@ void RasterizerStorageOpenGL::texture_set_data(RID p_texture, const Ref & texture->mipmaps = mipmaps; } -void RasterizerStorageOpenGL::texture_set_data_partial(RID p_texture, const Ref &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_layer) { +void RasterizerStorageGLES3::texture_set_data_partial(RID p_texture, const Ref &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_layer) { // TODO ERR_PRINT("Not implemented (ask Karroffel to do it :p)"); } /* -Ref RasterizerStorageOpenGL::texture_get_data(RID p_texture, int p_layer) const { +Ref RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer) const { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!texture, Ref()); @@ -990,7 +1037,7 @@ Ref RasterizerStorageOpenGL::texture_get_data(RID p_texture, int p_layer) } */ -void RasterizerStorageOpenGL::_texture_set_state_from_flags(Texture *p_tex) { +void RasterizerStorageGLES3::_texture_set_state_from_flags(Texture *p_tex) { if ((p_tex->flags & TEXTURE_FLAG_MIPMAPS) && !p_tex->ignore_mipmaps) if (p_tex->flags & TEXTURE_FLAG_FILTER) { // these do not exactly correspond ... @@ -1021,7 +1068,7 @@ void RasterizerStorageOpenGL::_texture_set_state_from_flags(Texture *p_tex) { } } -void RasterizerStorageOpenGL::texture_set_flags(RID p_texture, uint32_t p_flags) { +void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags) { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!texture); @@ -1042,7 +1089,7 @@ void RasterizerStorageOpenGL::texture_set_flags(RID p_texture, uint32_t p_flags) } } -uint32_t RasterizerStorageOpenGL::texture_get_flags(RID p_texture) const { +uint32_t RasterizerStorageGLES3::texture_get_flags(RID p_texture) const { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!texture, 0); @@ -1050,7 +1097,7 @@ uint32_t RasterizerStorageOpenGL::texture_get_flags(RID p_texture) const { return texture->flags; } -Image::Format RasterizerStorageOpenGL::texture_get_format(RID p_texture) const { +Image::Format RasterizerStorageGLES3::texture_get_format(RID p_texture) const { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!texture, Image::FORMAT_L8); @@ -1058,7 +1105,7 @@ Image::Format RasterizerStorageOpenGL::texture_get_format(RID p_texture) const { return texture->format; } -RenderingDevice::TextureType RasterizerStorageOpenGL::texture_get_type(RID p_texture) const { +RenderingDevice::TextureType RasterizerStorageGLES3::texture_get_type(RID p_texture) const { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!texture, RenderingDevice::TEXTURE_TYPE_2D); @@ -1066,7 +1113,7 @@ RenderingDevice::TextureType RasterizerStorageOpenGL::texture_get_type(RID p_tex return texture->type; } -uint32_t RasterizerStorageOpenGL::texture_get_texid(RID p_texture) const { +uint32_t RasterizerStorageGLES3::texture_get_texid(RID p_texture) const { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!texture, 0); @@ -1074,7 +1121,7 @@ uint32_t RasterizerStorageOpenGL::texture_get_texid(RID p_texture) const { return texture->tex_id; } -void RasterizerStorageOpenGL::texture_bind(RID p_texture, uint32_t p_texture_no) { +void RasterizerStorageGLES3::texture_bind(RID p_texture, uint32_t p_texture_no) { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!texture); @@ -1083,7 +1130,7 @@ void RasterizerStorageOpenGL::texture_bind(RID p_texture, uint32_t p_texture_no) glBindTexture(texture->target, texture->tex_id); } -uint32_t RasterizerStorageOpenGL::texture_get_width(RID p_texture) const { +uint32_t RasterizerStorageGLES3::texture_get_width(RID p_texture) const { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!texture, 0); @@ -1091,7 +1138,7 @@ uint32_t RasterizerStorageOpenGL::texture_get_width(RID p_texture) const { return texture->width; } -uint32_t RasterizerStorageOpenGL::texture_get_height(RID p_texture) const { +uint32_t RasterizerStorageGLES3::texture_get_height(RID p_texture) const { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!texture, 0); @@ -1099,7 +1146,7 @@ uint32_t RasterizerStorageOpenGL::texture_get_height(RID p_texture) const { return texture->height; } -uint32_t RasterizerStorageOpenGL::texture_get_depth(RID p_texture) const { +uint32_t RasterizerStorageGLES3::texture_get_depth(RID p_texture) const { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!texture, 0); @@ -1107,7 +1154,7 @@ uint32_t RasterizerStorageOpenGL::texture_get_depth(RID p_texture) const { return texture->depth; } -void RasterizerStorageOpenGL::texture_set_size_override(RID p_texture, int p_width, int p_height) { +void RasterizerStorageGLES3::texture_set_size_override(RID p_texture, int p_width, int p_height) { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!texture); @@ -1120,21 +1167,21 @@ void RasterizerStorageOpenGL::texture_set_size_override(RID p_texture, int p_wid texture->height = p_height; } -void RasterizerStorageOpenGL::texture_set_path(RID p_texture, const String &p_path) { +void RasterizerStorageGLES3::texture_set_path(RID p_texture, const String &p_path) { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!texture); texture->path = p_path; } -String RasterizerStorageOpenGL::texture_get_path(RID p_texture) const { +String RasterizerStorageGLES3::texture_get_path(RID p_texture) const { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!texture, ""); return texture->path; } -void RasterizerStorageOpenGL::texture_debug_usage(List *r_info) { +void RasterizerStorageGLES3::texture_debug_usage(List *r_info) { List textures; texture_owner.get_owned_list(&textures); @@ -1153,15 +1200,15 @@ void RasterizerStorageOpenGL::texture_debug_usage(List *r_info) } } -void RasterizerStorageOpenGL::texture_set_shrink_all_x2_on_set_data(bool p_enable) { +void RasterizerStorageGLES3::texture_set_shrink_all_x2_on_set_data(bool p_enable) { config.shrink_textures_x2 = p_enable; } -void RasterizerStorageOpenGL::textures_keep_original(bool p_enable) { +void RasterizerStorageGLES3::textures_keep_original(bool p_enable) { config.keep_original_textures = p_enable; } -Size2 RasterizerStorageOpenGL::texture_size_with_proxy(RID p_texture) { +Size2 RasterizerStorageGLES3::texture_size_with_proxy(RID p_texture) { const Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND_V(!texture, Size2()); if (texture->proxy) { @@ -1182,7 +1229,7 @@ Size2 RasterizerStorageOpenGL::texture_size_with_proxy(RID p_texture) { // The p_proxy is the source texture // and p_texture is actually the proxy???? -void RasterizerStorageOpenGL::texture_set_proxy(RID p_texture, RID p_proxy) { +void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!texture); @@ -1200,14 +1247,14 @@ void RasterizerStorageOpenGL::texture_set_proxy(RID p_texture, RID p_proxy) { } } -void RasterizerStorageOpenGL::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) { +void RasterizerStorageGLES3::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!texture); texture->redraw_if_visible = p_enable; } -void RasterizerStorageOpenGL::texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) { +void RasterizerStorageGLES3::texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!texture); @@ -1215,7 +1262,7 @@ void RasterizerStorageOpenGL::texture_set_detect_3d_callback(RID p_texture, RS:: texture->detect_3d_ud = p_userdata; } -void RasterizerStorageOpenGL::texture_set_detect_srgb_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) { +void RasterizerStorageGLES3::texture_set_detect_srgb_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!texture); @@ -1223,7 +1270,7 @@ void RasterizerStorageOpenGL::texture_set_detect_srgb_callback(RID p_texture, RS texture->detect_srgb_ud = p_userdata; } -void RasterizerStorageOpenGL::texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) { +void RasterizerStorageGLES3::texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) { Texture *texture = texture_owner.get_or_null(p_texture); ERR_FAIL_COND(!texture); @@ -1231,35 +1278,35 @@ void RasterizerStorageOpenGL::texture_set_detect_normal_callback(RID p_texture, texture->detect_normal_ud = p_userdata; } -RID RasterizerStorageOpenGL::texture_create_radiance_cubemap(RID p_source, int p_resolution) const { +RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source, int p_resolution) const { return RID(); } -RID RasterizerStorageOpenGL::canvas_texture_allocate() { +RID RasterizerStorageGLES3::canvas_texture_allocate() { return RID(); } -void RasterizerStorageOpenGL::canvas_texture_initialize(RID p_rid) { +void RasterizerStorageGLES3::canvas_texture_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) { +void RasterizerStorageGLES3::canvas_texture_set_channel(RID p_canvas_texture, RS::CanvasTextureChannel p_channel, RID p_texture) { } -void RasterizerStorageOpenGL::canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_base_color, float p_shininess) { +void RasterizerStorageGLES3::canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_base_color, float p_shininess) { } -void RasterizerStorageOpenGL::canvas_texture_set_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) { +void RasterizerStorageGLES3::canvas_texture_set_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) { } -void RasterizerStorageOpenGL::canvas_texture_set_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) { +void RasterizerStorageGLES3::canvas_texture_set_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) { } -RID RasterizerStorageOpenGL::sky_create() { +RID RasterizerStorageGLES3::sky_create() { Sky *sky = memnew(Sky); sky->radiance = 0; return sky_owner.make_rid(sky); } -void RasterizerStorageOpenGL::sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size) { +void RasterizerStorageGLES3::sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size) { Sky *sky = sky_owner.get_or_null(p_sky); ERR_FAIL_COND(!sky); @@ -1290,7 +1337,7 @@ void RasterizerStorageOpenGL::sky_set_texture(RID p_sky, RID p_panorama, int p_r glDisable(GL_BLEND); for (int i = 0; i < RS::ARRAY_MAX - 1; i++) { - glDisableVertexAttribArray(i); + //glDisableVertexAttribArray(i); } } @@ -1344,8 +1391,8 @@ void RasterizerStorageOpenGL::sky_set_texture(RID p_sky, RID p_panorama, int p_r int lod = 0; int mm_level = mipmaps; size = p_radiance_size / 2; - shaders.cubemap_filter.set_conditional(CubemapFilterShaderOpenGL::USE_SOURCE_PANORAMA, true); - shaders.cubemap_filter.set_conditional(CubemapFilterShaderOpenGL::USE_DIRECT_WRITE, true); + shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, true); + shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DIRECT_WRITE, true); shaders.cubemap_filter.bind(); // third, render to the framebuffer using separate textures, then copy to mipmaps @@ -1361,8 +1408,8 @@ void RasterizerStorageOpenGL::sky_set_texture(RID p_sky, RID p_panorama, int p_r glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_CUBE_MAP, sky->radiance); - shaders.cubemap_filter.set_conditional(CubemapFilterShaderOpenGL::USE_SOURCE_PANORAMA, false); - shaders.cubemap_filter.set_conditional(CubemapFilterShaderOpenGL::USE_DIRECT_WRITE, false); + shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, false); + shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DIRECT_WRITE, false); shaders.cubemap_filter.bind(); } glViewport(0, 0, size, size); @@ -1371,14 +1418,14 @@ void RasterizerStorageOpenGL::sky_set_texture(RID p_sky, RID p_panorama, int p_r glActiveTexture(GL_TEXTURE2); //back to panorama for (int i = 0; i < 6; i++) { - shaders.cubemap_filter.set_uniform(CubemapFilterShaderOpenGL::FACE_ID, i); + shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::FACE_ID, i); float roughness = mm_level >= 0 ? lod / (float)(mipmaps - 1) : 1; roughness = MIN(1.0, roughness); //keep max at 1 - shaders.cubemap_filter.set_uniform(CubemapFilterShaderOpenGL::ROUGHNESS, roughness); - shaders.cubemap_filter.set_uniform(CubemapFilterShaderOpenGL::Z_FLIP, false); + shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::ROUGHNESS, roughness); + shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES3::Z_FLIP, false); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + //glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glCopyTexSubImage2D(_cube_side_enum[i], lod, 0, 0, 0, 0, size, size); } @@ -1390,8 +1437,8 @@ void RasterizerStorageOpenGL::sky_set_texture(RID p_sky, RID p_panorama, int p_r lod++; } - shaders.cubemap_filter.set_conditional(CubemapFilterShaderOpenGL::USE_SOURCE_PANORAMA, false); - shaders.cubemap_filter.set_conditional(CubemapFilterShaderOpenGL::USE_DIRECT_WRITE, false); + shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_SOURCE_PANORAMA, false); + shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::USE_DIRECT_WRITE, false); // restore ranges glActiveTexture(GL_TEXTURE2); //back to panorama @@ -1419,7 +1466,7 @@ void RasterizerStorageOpenGL::sky_set_texture(RID p_sky, RID p_panorama, int p_r /* SHADER API */ -RID RasterizerStorageOpenGL::shader_allocate() { +RID RasterizerStorageGLES3::shader_allocate() { Shader *shader = memnew(Shader); shader->mode = RS::SHADER_SPATIAL; shader->shader = &scene->state.scene_shader; @@ -1430,11 +1477,11 @@ RID RasterizerStorageOpenGL::shader_allocate() { return rid; } -void RasterizerStorageOpenGL::shader_initialize(RID p_rid) { +void RasterizerStorageGLES3::shader_initialize(RID p_rid) { // noop } -//RID RasterizerStorageOpenGL::shader_create() { +//RID RasterizerStorageGLES3::shader_create() { // Shader *shader = memnew(Shader); // shader->mode = RS::SHADER_SPATIAL; // shader->shader = &scene->state.scene_shader; @@ -1445,14 +1492,14 @@ void RasterizerStorageOpenGL::shader_initialize(RID p_rid) { // return rid; //} -void RasterizerStorageOpenGL::_shader_make_dirty(Shader *p_shader) { +void RasterizerStorageGLES3::_shader_make_dirty(Shader *p_shader) { if (p_shader->dirty_list.in_list()) return; _shader_dirty_list.add(&p_shader->dirty_list); } -void RasterizerStorageOpenGL::shader_set_code(RID p_shader, const String &p_code) { +void RasterizerStorageGLES3::shader_set_code(RID p_shader, const String &p_code) { Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND(!shader); @@ -1492,14 +1539,14 @@ void RasterizerStorageOpenGL::shader_set_code(RID p_shader, const String &p_code _shader_make_dirty(shader); } -String RasterizerStorageOpenGL::shader_get_code(RID p_shader) const { +String RasterizerStorageGLES3::shader_get_code(RID p_shader) const { const Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND_V(!shader, ""); return shader->code; } -void RasterizerStorageOpenGL::_update_shader(Shader *p_shader) const { +void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const { _shader_dirty_list.remove(&p_shader->dirty_list); p_shader->valid = false; @@ -1510,8 +1557,8 @@ void RasterizerStorageOpenGL::_update_shader(Shader *p_shader) const { return; //just invalid, but no error } - ShaderCompilerOpenGL::GeneratedCode gen_code; - ShaderCompilerOpenGL::IdentifierActions *actions = NULL; + ShaderCompilerGLES3::GeneratedCode gen_code; + ShaderCompilerGLES3::IdentifierActions *actions = NULL; switch (p_shader->mode) { case RS::SHADER_CANVAS_ITEM: { @@ -1675,13 +1722,13 @@ void RasterizerStorageOpenGL::_update_shader(Shader *p_shader) const { p_shader->version++; } -void RasterizerStorageOpenGL::update_dirty_shaders() { +void RasterizerStorageGLES3::update_dirty_shaders() { while (_shader_dirty_list.first()) { _update_shader(_shader_dirty_list.first()->self()); } } -void RasterizerStorageOpenGL::shader_get_param_list(RID p_shader, List *p_param_list) const { +void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List *p_param_list) const { Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND(!shader); @@ -1822,7 +1869,7 @@ void RasterizerStorageOpenGL::shader_get_param_list(RID p_shader, Listget(); } -void RasterizerStorageOpenGL::shader_add_custom_define(RID p_shader, const String &p_define) { +void RasterizerStorageGLES3::shader_add_custom_define(RID p_shader, const String &p_define) { Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND(!shader); @@ -1858,14 +1905,14 @@ void RasterizerStorageOpenGL::shader_add_custom_define(RID p_shader, const Strin _shader_make_dirty(shader); } -void RasterizerStorageOpenGL::shader_get_custom_defines(RID p_shader, Vector *p_defines) const { +void RasterizerStorageGLES3::shader_get_custom_defines(RID p_shader, Vector *p_defines) const { Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND(!shader); shader->shader->get_custom_defines(p_defines); } -void RasterizerStorageOpenGL::shader_remove_custom_define(RID p_shader, const String &p_define) { +void RasterizerStorageGLES3::shader_remove_custom_define(RID p_shader, const String &p_define) { Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_COND(!shader); @@ -1876,28 +1923,28 @@ void RasterizerStorageOpenGL::shader_remove_custom_define(RID p_shader, const St /* COMMON MATERIAL API */ -void RasterizerStorageOpenGL::_material_make_dirty(Material *p_material) const { +void RasterizerStorageGLES3::_material_make_dirty(Material *p_material) const { if (p_material->dirty_list.in_list()) return; _material_dirty_list.add(&p_material->dirty_list); } -RID RasterizerStorageOpenGL::material_allocate() { +RID RasterizerStorageGLES3::material_allocate() { Material *material = memnew(Material); return material_owner.make_rid(material); } -void RasterizerStorageOpenGL::material_initialize(RID p_rid) { +void RasterizerStorageGLES3::material_initialize(RID p_rid) { } -//RID RasterizerStorageOpenGL::material_create() { +//RID RasterizerStorageGLES3::material_create() { // Material *material = memnew(Material); // return material_owner.make_rid(material); //} -void RasterizerStorageOpenGL::material_set_shader(RID p_material, RID p_shader) { +void RasterizerStorageGLES3::material_set_shader(RID p_material, RID p_shader) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND(!material); @@ -1917,7 +1964,7 @@ void RasterizerStorageOpenGL::material_set_shader(RID p_material, RID p_shader) _material_make_dirty(material); } -RID RasterizerStorageOpenGL::material_get_shader(RID p_material) const { +RID RasterizerStorageGLES3::material_get_shader(RID p_material) const { const Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND_V(!material, RID()); @@ -1928,7 +1975,7 @@ RID RasterizerStorageOpenGL::material_get_shader(RID p_material) const { return RID(); } -void RasterizerStorageOpenGL::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) { +void RasterizerStorageGLES3::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND(!material); @@ -1941,7 +1988,7 @@ void RasterizerStorageOpenGL::material_set_param(RID p_material, const StringNam _material_make_dirty(material); } -Variant RasterizerStorageOpenGL::material_get_param(RID p_material, const StringName &p_param) const { +Variant RasterizerStorageGLES3::material_get_param(RID p_material, const StringName &p_param) const { const Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND_V(!material, RID()); @@ -1952,7 +1999,7 @@ Variant RasterizerStorageOpenGL::material_get_param(RID p_material, const String return material_get_param_default(p_material, p_param); } -Variant RasterizerStorageOpenGL::material_get_param_default(RID p_material, const StringName &p_param) const { +Variant RasterizerStorageGLES3::material_get_param_default(RID p_material, const StringName &p_param) const { const Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND_V(!material, Variant()); @@ -1966,21 +2013,21 @@ Variant RasterizerStorageOpenGL::material_get_param_default(RID p_material, cons return Variant(); } -void RasterizerStorageOpenGL::material_set_line_width(RID p_material, float p_width) { +void RasterizerStorageGLES3::material_set_line_width(RID p_material, float p_width) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND(!material); material->line_width = p_width; } -void RasterizerStorageOpenGL::material_set_next_pass(RID p_material, RID p_next_material) { +void RasterizerStorageGLES3::material_set_next_pass(RID p_material, RID p_next_material) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND(!material); material->next_pass = p_next_material; } -bool RasterizerStorageOpenGL::material_is_animated(RID p_material) { +bool RasterizerStorageGLES3::material_is_animated(RID p_material) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND_V(!material, false); if (material->dirty_list.in_list()) { @@ -1994,7 +2041,7 @@ bool RasterizerStorageOpenGL::material_is_animated(RID p_material) { return animated; } -bool RasterizerStorageOpenGL::material_casts_shadows(RID p_material) { +bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND_V(!material, false); if (material->dirty_list.in_list()) { @@ -2010,7 +2057,7 @@ bool RasterizerStorageOpenGL::material_casts_shadows(RID p_material) { return casts_shadows; } -bool RasterizerStorageOpenGL::material_uses_tangents(RID p_material) { +bool RasterizerStorageGLES3::material_uses_tangents(RID p_material) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND_V(!material, false); @@ -2025,7 +2072,7 @@ bool RasterizerStorageOpenGL::material_uses_tangents(RID p_material) { return material->shader->spatial.uses_tangent; } -bool RasterizerStorageOpenGL::material_uses_ensure_correct_normals(RID p_material) { +bool RasterizerStorageGLES3::material_uses_ensure_correct_normals(RID p_material) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND_V(!material, false); @@ -2040,7 +2087,7 @@ bool RasterizerStorageOpenGL::material_uses_ensure_correct_normals(RID p_materia return material->shader->spatial.uses_ensure_correct_normals; } -void RasterizerStorageOpenGL::material_add_instance_owner(RID p_material, DependencyTracker *p_instance) { +void RasterizerStorageGLES3::material_add_instance_owner(RID p_material, DependencyTracker *p_instance) { /* Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND(!material); @@ -2054,7 +2101,7 @@ void RasterizerStorageOpenGL::material_add_instance_owner(RID p_material, Depend */ } -void RasterizerStorageOpenGL::material_remove_instance_owner(RID p_material, DependencyTracker *p_instance) { +void RasterizerStorageGLES3::material_remove_instance_owner(RID p_material, DependencyTracker *p_instance) { /* Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND(!material); @@ -2070,7 +2117,7 @@ void RasterizerStorageOpenGL::material_remove_instance_owner(RID p_material, Dep */ } -void RasterizerStorageOpenGL::material_set_render_priority(RID p_material, int priority) { +void RasterizerStorageGLES3::material_set_render_priority(RID p_material, int priority) { ERR_FAIL_COND(priority < RS::MATERIAL_RENDER_PRIORITY_MIN); ERR_FAIL_COND(priority > RS::MATERIAL_RENDER_PRIORITY_MAX); @@ -2080,7 +2127,7 @@ void RasterizerStorageOpenGL::material_set_render_priority(RID p_material, int p material->render_priority = priority; } -void RasterizerStorageOpenGL::_update_material(Material *p_material) { +void RasterizerStorageGLES3::_update_material(Material *p_material) { if (p_material->dirty_list.in_list()) { _material_dirty_list.remove(&p_material->dirty_list); } @@ -2128,7 +2175,7 @@ void RasterizerStorageOpenGL::_update_material(Material *p_material) { } } - // uniforms and other things will be set in the use_material method in ShaderOpenGL + // uniforms and other things will be set in the use_material method in ShaderGLES3 if (p_material->shader && p_material->shader->texture_count > 0) { p_material->textures.resize(p_material->shader->texture_count); @@ -2160,7 +2207,7 @@ void RasterizerStorageOpenGL::_update_material(Material *p_material) { } } /* -void RasterizerStorageOpenGL::_material_add_geometry(RID p_material, Geometry *p_geometry) { +void RasterizerStorageGLES3::_material_add_geometry(RID p_material, Geometry *p_geometry) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND(!material); @@ -2173,7 +2220,7 @@ void RasterizerStorageOpenGL::_material_add_geometry(RID p_material, Geometry *p } } -void RasterizerStorageOpenGL::_material_remove_geometry(RID p_material, Geometry *p_geometry) { +void RasterizerStorageGLES3::_material_remove_geometry(RID p_material, Geometry *p_geometry) { Material *material = material_owner.get_or_null(p_material); ERR_FAIL_COND(!material); @@ -2187,7 +2234,7 @@ void RasterizerStorageOpenGL::_material_remove_geometry(RID p_material, Geometry } } */ -void RasterizerStorageOpenGL::update_dirty_materials() { +void RasterizerStorageGLES3::update_dirty_materials() { while (_material_dirty_list.first()) { Material *material = _material_dirty_list.first()->self(); _update_material(material); @@ -2196,854 +2243,878 @@ void RasterizerStorageOpenGL::update_dirty_materials() { /* MESH API */ -RID RasterizerStorageOpenGL::mesh_allocate() { +RID RasterizerStorageGLES3::mesh_allocate() { return RID(); } -void RasterizerStorageOpenGL::mesh_initialize(RID p_rid) { +void RasterizerStorageGLES3::mesh_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) { +void RasterizerStorageGLES3::mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) { } -bool RasterizerStorageOpenGL::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) { +bool RasterizerStorageGLES3::mesh_needs_instance(RID p_mesh, bool p_has_skeleton) { return false; } -RID RasterizerStorageOpenGL::mesh_instance_create(RID p_base) { +RID RasterizerStorageGLES3::mesh_instance_create(RID p_base) { return RID(); } -void RasterizerStorageOpenGL::mesh_instance_set_skeleton(RID p_mesh_instance, RID p_skeleton) { +void RasterizerStorageGLES3::mesh_instance_set_skeleton(RID p_mesh_instance, RID p_skeleton) { } -void RasterizerStorageOpenGL::mesh_instance_set_blend_shape_weight(RID p_mesh_instance, int p_shape, float p_weight) { +void RasterizerStorageGLES3::mesh_instance_set_blend_shape_weight(RID p_mesh_instance, int p_shape, float p_weight) { } -void RasterizerStorageOpenGL::mesh_instance_check_for_update(RID p_mesh_instance) { +void RasterizerStorageGLES3::mesh_instance_check_for_update(RID p_mesh_instance) { } -void RasterizerStorageOpenGL::update_mesh_instances() { +void RasterizerStorageGLES3::update_mesh_instances() { } -void RasterizerStorageOpenGL::reflection_probe_set_lod_threshold(RID p_probe, float p_ratio) { +void RasterizerStorageGLES3::reflection_probe_set_lod_threshold(RID p_probe, float p_ratio) { } -float RasterizerStorageOpenGL::reflection_probe_get_lod_threshold(RID p_probe) const { +float RasterizerStorageGLES3::reflection_probe_get_lod_threshold(RID p_probe) const { return 0.0; } -void RasterizerStorageOpenGL::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) { +void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) { } -int RasterizerStorageOpenGL::mesh_get_blend_shape_count(RID p_mesh) const { +int RasterizerStorageGLES3::mesh_get_blend_shape_count(RID p_mesh) const { return 0; } -void RasterizerStorageOpenGL::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) { +void RasterizerStorageGLES3::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) { } -RS::BlendShapeMode RasterizerStorageOpenGL::mesh_get_blend_shape_mode(RID p_mesh) const { +RS::BlendShapeMode RasterizerStorageGLES3::mesh_get_blend_shape_mode(RID p_mesh) const { return RS::BLEND_SHAPE_MODE_NORMALIZED; } -void RasterizerStorageOpenGL::mesh_surface_update_vertex_region(RID p_mesh, int p_surface, int p_offset, const Vector &p_data) { +void RasterizerStorageGLES3::mesh_surface_update_vertex_region(RID p_mesh, int p_surface, int p_offset, const Vector &p_data) { } -void RasterizerStorageOpenGL::mesh_surface_update_attribute_region(RID p_mesh, int p_surface, int p_offset, const Vector &p_data) { +void RasterizerStorageGLES3::mesh_surface_update_attribute_region(RID p_mesh, int p_surface, int p_offset, const Vector &p_data) { } -void RasterizerStorageOpenGL::mesh_surface_update_skin_region(RID p_mesh, int p_surface, int p_offset, const Vector &p_data) { +void RasterizerStorageGLES3::mesh_surface_update_skin_region(RID p_mesh, int p_surface, int p_offset, const Vector &p_data) { } -void RasterizerStorageOpenGL::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) { +void RasterizerStorageGLES3::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) { } -RID RasterizerStorageOpenGL::mesh_surface_get_material(RID p_mesh, int p_surface) const { +RID RasterizerStorageGLES3::mesh_surface_get_material(RID p_mesh, int p_surface) const { return RID(); } -RS::SurfaceData RasterizerStorageOpenGL::mesh_get_surface(RID p_mesh, int p_surface) const { +RS::SurfaceData RasterizerStorageGLES3::mesh_get_surface(RID p_mesh, int p_surface) const { return RS::SurfaceData(); } -int RasterizerStorageOpenGL::mesh_get_surface_count(RID p_mesh) const { +int RasterizerStorageGLES3::mesh_get_surface_count(RID p_mesh) const { return 0; } -void RasterizerStorageOpenGL::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) { +void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) { } -AABB RasterizerStorageOpenGL::mesh_get_custom_aabb(RID p_mesh) const { +AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const { return AABB(); } -AABB RasterizerStorageOpenGL::mesh_get_aabb(RID p_mesh, RID p_skeleton) { +AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) { return AABB(); } -void RasterizerStorageOpenGL::mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) { +void RasterizerStorageGLES3::mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) { } -void RasterizerStorageOpenGL::mesh_clear(RID p_mesh) { +void RasterizerStorageGLES3::mesh_clear(RID p_mesh) { } /* MULTIMESH API */ -RID RasterizerStorageOpenGL::multimesh_allocate() { +RID RasterizerStorageGLES3::multimesh_allocate() { return RID(); } -void RasterizerStorageOpenGL::multimesh_initialize(RID p_rid) { +void RasterizerStorageGLES3::multimesh_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) { +void RasterizerStorageGLES3::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) { } -int RasterizerStorageOpenGL::multimesh_get_instance_count(RID p_multimesh) const { +int RasterizerStorageGLES3::multimesh_get_instance_count(RID p_multimesh) const { return 0; } -void RasterizerStorageOpenGL::multimesh_set_mesh(RID p_multimesh, RID p_mesh) { +void RasterizerStorageGLES3::multimesh_set_mesh(RID p_multimesh, RID p_mesh) { } -void RasterizerStorageOpenGL::multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) { +void RasterizerStorageGLES3::multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) { } -void RasterizerStorageOpenGL::multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) { +void RasterizerStorageGLES3::multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) { } -void RasterizerStorageOpenGL::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) { +void RasterizerStorageGLES3::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) { } -void RasterizerStorageOpenGL::multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) { +void RasterizerStorageGLES3::multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) { } -RID RasterizerStorageOpenGL::multimesh_get_mesh(RID p_multimesh) const { +RID RasterizerStorageGLES3::multimesh_get_mesh(RID p_multimesh) const { return RID(); } -AABB RasterizerStorageOpenGL::multimesh_get_aabb(RID p_multimesh) const { +AABB RasterizerStorageGLES3::multimesh_get_aabb(RID p_multimesh) const { return AABB(); } -Transform3D RasterizerStorageOpenGL::multimesh_instance_get_transform(RID p_multimesh, int p_index) const { +Transform3D RasterizerStorageGLES3::multimesh_instance_get_transform(RID p_multimesh, int p_index) const { return Transform3D(); } -Transform2D RasterizerStorageOpenGL::multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const { +Transform2D RasterizerStorageGLES3::multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const { return Transform2D(); } -Color RasterizerStorageOpenGL::multimesh_instance_get_color(RID p_multimesh, int p_index) const { +Color RasterizerStorageGLES3::multimesh_instance_get_color(RID p_multimesh, int p_index) const { return Color(); } -Color RasterizerStorageOpenGL::multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const { +Color RasterizerStorageGLES3::multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const { return Color(); } -void RasterizerStorageOpenGL::multimesh_set_buffer(RID p_multimesh, const Vector &p_buffer) { +void RasterizerStorageGLES3::multimesh_set_buffer(RID p_multimesh, const Vector &p_buffer) { } -Vector RasterizerStorageOpenGL::multimesh_get_buffer(RID p_multimesh) const { +Vector RasterizerStorageGLES3::multimesh_get_buffer(RID p_multimesh) const { return Vector(); } -void RasterizerStorageOpenGL::multimesh_set_visible_instances(RID p_multimesh, int p_visible) { +void RasterizerStorageGLES3::multimesh_set_visible_instances(RID p_multimesh, int p_visible) { } -int RasterizerStorageOpenGL::multimesh_get_visible_instances(RID p_multimesh) const { +int RasterizerStorageGLES3::multimesh_get_visible_instances(RID p_multimesh) const { return 0; } /* SKELETON API */ -RID RasterizerStorageOpenGL::skeleton_allocate() { +RID RasterizerStorageGLES3::skeleton_allocate() { return RID(); } -void RasterizerStorageOpenGL::skeleton_initialize(RID p_rid) { +void RasterizerStorageGLES3::skeleton_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_skeleton) { +void RasterizerStorageGLES3::skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_skeleton) { } -void RasterizerStorageOpenGL::skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) { +void RasterizerStorageGLES3::skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) { } -int RasterizerStorageOpenGL::skeleton_get_bone_count(RID p_skeleton) const { +int RasterizerStorageGLES3::skeleton_get_bone_count(RID p_skeleton) const { return 0; } -void RasterizerStorageOpenGL::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform3D &p_transform) { +void RasterizerStorageGLES3::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform3D &p_transform) { } -Transform3D RasterizerStorageOpenGL::skeleton_bone_get_transform(RID p_skeleton, int p_bone) const { +Transform3D RasterizerStorageGLES3::skeleton_bone_get_transform(RID p_skeleton, int p_bone) const { return Transform3D(); } -void RasterizerStorageOpenGL::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) { +void RasterizerStorageGLES3::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) { } -Transform2D RasterizerStorageOpenGL::skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const { +Transform2D RasterizerStorageGLES3::skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const { return Transform2D(); } /* Light API */ -RID RasterizerStorageOpenGL::directional_light_allocate() { +RID RasterizerStorageGLES3::directional_light_allocate() { return RID(); } -void RasterizerStorageOpenGL::directional_light_initialize(RID p_rid) { +void RasterizerStorageGLES3::directional_light_initialize(RID p_rid) { } -RID RasterizerStorageOpenGL::omni_light_allocate() { +RID RasterizerStorageGLES3::omni_light_allocate() { return RID(); } -void RasterizerStorageOpenGL::omni_light_initialize(RID p_rid) { +void RasterizerStorageGLES3::omni_light_initialize(RID p_rid) { } -RID RasterizerStorageOpenGL::spot_light_allocate() { +RID RasterizerStorageGLES3::spot_light_allocate() { return RID(); } -void RasterizerStorageOpenGL::spot_light_initialize(RID p_rid) { +void RasterizerStorageGLES3::spot_light_initialize(RID p_rid) { } -RID RasterizerStorageOpenGL::reflection_probe_allocate() { +RID RasterizerStorageGLES3::reflection_probe_allocate() { return RID(); } -void RasterizerStorageOpenGL::reflection_probe_initialize(RID p_rid) { +void RasterizerStorageGLES3::reflection_probe_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::light_set_color(RID p_light, const Color &p_color) { +void RasterizerStorageGLES3::light_set_color(RID p_light, const Color &p_color) { } -void RasterizerStorageOpenGL::light_set_param(RID p_light, RS::LightParam p_param, float p_value) { +void RasterizerStorageGLES3::light_set_param(RID p_light, RS::LightParam p_param, float p_value) { } -void RasterizerStorageOpenGL::light_set_shadow(RID p_light, bool p_enabled) { +void RasterizerStorageGLES3::light_set_shadow(RID p_light, bool p_enabled) { } -void RasterizerStorageOpenGL::light_set_shadow_color(RID p_light, const Color &p_color) { +void RasterizerStorageGLES3::light_set_shadow_color(RID p_light, const Color &p_color) { } -void RasterizerStorageOpenGL::light_set_projector(RID p_light, RID p_texture) { +void RasterizerStorageGLES3::light_set_projector(RID p_light, RID p_texture) { } -void RasterizerStorageOpenGL::light_set_negative(RID p_light, bool p_enable) { +void RasterizerStorageGLES3::light_set_negative(RID p_light, bool p_enable) { } -void RasterizerStorageOpenGL::light_set_cull_mask(RID p_light, uint32_t p_mask) { +void RasterizerStorageGLES3::light_set_cull_mask(RID p_light, uint32_t p_mask) { } -void RasterizerStorageOpenGL::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) { +void RasterizerStorageGLES3::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) { } -void RasterizerStorageOpenGL::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) { +void RasterizerStorageGLES3::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) { } -void RasterizerStorageOpenGL::light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) { +void RasterizerStorageGLES3::light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) { } -void RasterizerStorageOpenGL::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) { +void RasterizerStorageGLES3::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) { } -void RasterizerStorageOpenGL::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) { +void RasterizerStorageGLES3::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) { } -void RasterizerStorageOpenGL::light_directional_set_blend_splits(RID p_light, bool p_enable) { +void RasterizerStorageGLES3::light_directional_set_blend_splits(RID p_light, bool p_enable) { } -bool RasterizerStorageOpenGL::light_directional_get_blend_splits(RID p_light) const { +bool RasterizerStorageGLES3::light_directional_get_blend_splits(RID p_light) const { return false; } -void RasterizerStorageOpenGL::light_directional_set_sky_only(RID p_light, bool p_sky_only) { +void RasterizerStorageGLES3::light_directional_set_sky_only(RID p_light, bool p_sky_only) { } -bool RasterizerStorageOpenGL::light_directional_is_sky_only(RID p_light) const { +bool RasterizerStorageGLES3::light_directional_is_sky_only(RID p_light) const { return false; } -RS::LightDirectionalShadowMode RasterizerStorageOpenGL::light_directional_get_shadow_mode(RID p_light) { +RS::LightDirectionalShadowMode RasterizerStorageGLES3::light_directional_get_shadow_mode(RID p_light) { return RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; } -RS::LightOmniShadowMode RasterizerStorageOpenGL::light_omni_get_shadow_mode(RID p_light) { +RS::LightOmniShadowMode RasterizerStorageGLES3::light_omni_get_shadow_mode(RID p_light) { return RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; } -bool RasterizerStorageOpenGL::light_has_shadow(RID p_light) const { +bool RasterizerStorageGLES3::light_has_shadow(RID p_light) const { return false; } -bool RasterizerStorageOpenGL::light_has_projector(RID p_light) const { +bool RasterizerStorageGLES3::light_has_projector(RID p_light) const { return false; } -RS::LightType RasterizerStorageOpenGL::light_get_type(RID p_light) const { +RS::LightType RasterizerStorageGLES3::light_get_type(RID p_light) const { return RS::LIGHT_OMNI; } -AABB RasterizerStorageOpenGL::light_get_aabb(RID p_light) const { +AABB RasterizerStorageGLES3::light_get_aabb(RID p_light) const { return AABB(); } -float RasterizerStorageOpenGL::light_get_param(RID p_light, RS::LightParam p_param) { +float RasterizerStorageGLES3::light_get_param(RID p_light, RS::LightParam p_param) { return 0.0; } -Color RasterizerStorageOpenGL::light_get_color(RID p_light) { +Color RasterizerStorageGLES3::light_get_color(RID p_light) { return Color(); } -RS::LightBakeMode RasterizerStorageOpenGL::light_get_bake_mode(RID p_light) { +RS::LightBakeMode RasterizerStorageGLES3::light_get_bake_mode(RID p_light) { return RS::LIGHT_BAKE_DISABLED; } -uint32_t RasterizerStorageOpenGL::light_get_max_sdfgi_cascade(RID p_light) { +uint32_t RasterizerStorageGLES3::light_get_max_sdfgi_cascade(RID p_light) { return 0; } -uint64_t RasterizerStorageOpenGL::light_get_version(RID p_light) const { +uint64_t RasterizerStorageGLES3::light_get_version(RID p_light) const { return 0; } /* PROBE API */ -void RasterizerStorageOpenGL::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) { +void RasterizerStorageGLES3::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) { } -void RasterizerStorageOpenGL::reflection_probe_set_intensity(RID p_probe, float p_intensity) { +void RasterizerStorageGLES3::reflection_probe_set_intensity(RID p_probe, float p_intensity) { } -void RasterizerStorageOpenGL::reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) { +void RasterizerStorageGLES3::reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) { } -void RasterizerStorageOpenGL::reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) { +void RasterizerStorageGLES3::reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) { } -void RasterizerStorageOpenGL::reflection_probe_set_ambient_energy(RID p_probe, float p_energy) { +void RasterizerStorageGLES3::reflection_probe_set_ambient_energy(RID p_probe, float p_energy) { } -void RasterizerStorageOpenGL::reflection_probe_set_max_distance(RID p_probe, float p_distance) { +void RasterizerStorageGLES3::reflection_probe_set_max_distance(RID p_probe, float p_distance) { } -void RasterizerStorageOpenGL::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) { +void RasterizerStorageGLES3::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) { } -void RasterizerStorageOpenGL::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) { +void RasterizerStorageGLES3::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) { } -void RasterizerStorageOpenGL::reflection_probe_set_as_interior(RID p_probe, bool p_enable) { +void RasterizerStorageGLES3::reflection_probe_set_as_interior(RID p_probe, bool p_enable) { } -void RasterizerStorageOpenGL::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) { +void RasterizerStorageGLES3::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) { } -void RasterizerStorageOpenGL::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) { +void RasterizerStorageGLES3::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) { } -void RasterizerStorageOpenGL::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) { +void RasterizerStorageGLES3::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) { } -void RasterizerStorageOpenGL::reflection_probe_set_resolution(RID p_probe, int p_resolution) { +void RasterizerStorageGLES3::reflection_probe_set_resolution(RID p_probe, int p_resolution) { } -AABB RasterizerStorageOpenGL::reflection_probe_get_aabb(RID p_probe) const { +AABB RasterizerStorageGLES3::reflection_probe_get_aabb(RID p_probe) const { return AABB(); } -RS::ReflectionProbeUpdateMode RasterizerStorageOpenGL::reflection_probe_get_update_mode(RID p_probe) const { +RS::ReflectionProbeUpdateMode RasterizerStorageGLES3::reflection_probe_get_update_mode(RID p_probe) const { return RenderingServer::REFLECTION_PROBE_UPDATE_ONCE; } -uint32_t RasterizerStorageOpenGL::reflection_probe_get_cull_mask(RID p_probe) const { +uint32_t RasterizerStorageGLES3::reflection_probe_get_cull_mask(RID p_probe) const { return 0; } -Vector3 RasterizerStorageOpenGL::reflection_probe_get_extents(RID p_probe) const { +Vector3 RasterizerStorageGLES3::reflection_probe_get_extents(RID p_probe) const { return Vector3(); } -Vector3 RasterizerStorageOpenGL::reflection_probe_get_origin_offset(RID p_probe) const { +Vector3 RasterizerStorageGLES3::reflection_probe_get_origin_offset(RID p_probe) const { return Vector3(); } -float RasterizerStorageOpenGL::reflection_probe_get_origin_max_distance(RID p_probe) const { +float RasterizerStorageGLES3::reflection_probe_get_origin_max_distance(RID p_probe) const { return 0.0; } -bool RasterizerStorageOpenGL::reflection_probe_renders_shadows(RID p_probe) const { +bool RasterizerStorageGLES3::reflection_probe_renders_shadows(RID p_probe) const { return false; } -void RasterizerStorageOpenGL::base_update_dependency(RID p_base, DependencyTracker *p_instance) { +void RasterizerStorageGLES3::base_update_dependency(RID p_base, DependencyTracker *p_instance) { } -void RasterizerStorageOpenGL::skeleton_update_dependency(RID p_base, DependencyTracker *p_instance) { +void RasterizerStorageGLES3::skeleton_update_dependency(RID p_base, DependencyTracker *p_instance) { } /* DECAL API */ -RID RasterizerStorageOpenGL::decal_allocate() { +RID RasterizerStorageGLES3::decal_allocate() { return RID(); } -void RasterizerStorageOpenGL::decal_initialize(RID p_rid) { +void RasterizerStorageGLES3::decal_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::decal_set_extents(RID p_decal, const Vector3 &p_extents) { +void RasterizerStorageGLES3::decal_set_extents(RID p_decal, const Vector3 &p_extents) { } -void RasterizerStorageOpenGL::decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) { +void RasterizerStorageGLES3::decal_set_texture(RID p_decal, RS::DecalTexture p_type, RID p_texture) { } -void RasterizerStorageOpenGL::decal_set_emission_energy(RID p_decal, float p_energy) { +void RasterizerStorageGLES3::decal_set_emission_energy(RID p_decal, float p_energy) { } -void RasterizerStorageOpenGL::decal_set_albedo_mix(RID p_decal, float p_mix) { +void RasterizerStorageGLES3::decal_set_albedo_mix(RID p_decal, float p_mix) { } -void RasterizerStorageOpenGL::decal_set_modulate(RID p_decal, const Color &p_modulate) { +void RasterizerStorageGLES3::decal_set_modulate(RID p_decal, const Color &p_modulate) { } -void RasterizerStorageOpenGL::decal_set_cull_mask(RID p_decal, uint32_t p_layers) { +void RasterizerStorageGLES3::decal_set_cull_mask(RID p_decal, uint32_t p_layers) { } -void RasterizerStorageOpenGL::decal_set_distance_fade(RID p_decal, bool p_enabled, float p_begin, float p_length) { +void RasterizerStorageGLES3::decal_set_distance_fade(RID p_decal, bool p_enabled, float p_begin, float p_length) { } -void RasterizerStorageOpenGL::decal_set_fade(RID p_decal, float p_above, float p_below) { +void RasterizerStorageGLES3::decal_set_fade(RID p_decal, float p_above, float p_below) { } -void RasterizerStorageOpenGL::decal_set_normal_fade(RID p_decal, float p_fade) { +void RasterizerStorageGLES3::decal_set_normal_fade(RID p_decal, float p_fade) { } -AABB RasterizerStorageOpenGL::decal_get_aabb(RID p_decal) const { +AABB RasterizerStorageGLES3::decal_get_aabb(RID p_decal) const { return AABB(); } /* VOXEL GI API */ -RID RasterizerStorageOpenGL::voxel_gi_allocate() { +RID RasterizerStorageGLES3::voxel_gi_allocate() { return RID(); } -void RasterizerStorageOpenGL::voxel_gi_initialize(RID p_rid) { +void RasterizerStorageGLES3::voxel_gi_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector &p_octree_cells, const Vector &p_data_cells, const Vector &p_distance_field, const Vector &p_level_counts) { +void RasterizerStorageGLES3::voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector &p_octree_cells, const Vector &p_data_cells, const Vector &p_distance_field, const Vector &p_level_counts) { } -AABB RasterizerStorageOpenGL::voxel_gi_get_bounds(RID p_voxel_gi) const { +AABB RasterizerStorageGLES3::voxel_gi_get_bounds(RID p_voxel_gi) const { return AABB(); } -Vector3i RasterizerStorageOpenGL::voxel_gi_get_octree_size(RID p_voxel_gi) const { +Vector3i RasterizerStorageGLES3::voxel_gi_get_octree_size(RID p_voxel_gi) const { return Vector3i(); } -Vector RasterizerStorageOpenGL::voxel_gi_get_octree_cells(RID p_voxel_gi) const { +Vector RasterizerStorageGLES3::voxel_gi_get_octree_cells(RID p_voxel_gi) const { return Vector(); } -Vector RasterizerStorageOpenGL::voxel_gi_get_data_cells(RID p_voxel_gi) const { +Vector RasterizerStorageGLES3::voxel_gi_get_data_cells(RID p_voxel_gi) const { return Vector(); } -Vector RasterizerStorageOpenGL::voxel_gi_get_distance_field(RID p_voxel_gi) const { +Vector RasterizerStorageGLES3::voxel_gi_get_distance_field(RID p_voxel_gi) const { return Vector(); } -Vector RasterizerStorageOpenGL::voxel_gi_get_level_counts(RID p_voxel_gi) const { +Vector RasterizerStorageGLES3::voxel_gi_get_level_counts(RID p_voxel_gi) const { return Vector(); } -Transform3D RasterizerStorageOpenGL::voxel_gi_get_to_cell_xform(RID p_voxel_gi) const { +Transform3D RasterizerStorageGLES3::voxel_gi_get_to_cell_xform(RID p_voxel_gi) const { return Transform3D(); } -void RasterizerStorageOpenGL::voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) { +void RasterizerStorageGLES3::voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) { } -float RasterizerStorageOpenGL::voxel_gi_get_dynamic_range(RID p_voxel_gi) const { +float RasterizerStorageGLES3::voxel_gi_get_dynamic_range(RID p_voxel_gi) const { return 0; } -void RasterizerStorageOpenGL::voxel_gi_set_propagation(RID p_voxel_gi, float p_range) { +void RasterizerStorageGLES3::voxel_gi_set_propagation(RID p_voxel_gi, float p_range) { } -float RasterizerStorageOpenGL::voxel_gi_get_propagation(RID p_voxel_gi) const { +float RasterizerStorageGLES3::voxel_gi_get_propagation(RID p_voxel_gi) const { return 0; } -void RasterizerStorageOpenGL::voxel_gi_set_energy(RID p_voxel_gi, float p_range) { +void RasterizerStorageGLES3::voxel_gi_set_energy(RID p_voxel_gi, float p_range) { } -float RasterizerStorageOpenGL::voxel_gi_get_energy(RID p_voxel_gi) const { +float RasterizerStorageGLES3::voxel_gi_get_energy(RID p_voxel_gi) const { return 0.0; } -void RasterizerStorageOpenGL::voxel_gi_set_bias(RID p_voxel_gi, float p_range) { +void RasterizerStorageGLES3::voxel_gi_set_bias(RID p_voxel_gi, float p_range) { } -float RasterizerStorageOpenGL::voxel_gi_get_bias(RID p_voxel_gi) const { +float RasterizerStorageGLES3::voxel_gi_get_bias(RID p_voxel_gi) const { return 0.0; } -void RasterizerStorageOpenGL::voxel_gi_set_normal_bias(RID p_voxel_gi, float p_range) { +void RasterizerStorageGLES3::voxel_gi_set_normal_bias(RID p_voxel_gi, float p_range) { } -float RasterizerStorageOpenGL::voxel_gi_get_normal_bias(RID p_voxel_gi) const { +float RasterizerStorageGLES3::voxel_gi_get_normal_bias(RID p_voxel_gi) const { return 0.0; } -void RasterizerStorageOpenGL::voxel_gi_set_interior(RID p_voxel_gi, bool p_enable) { +void RasterizerStorageGLES3::voxel_gi_set_interior(RID p_voxel_gi, bool p_enable) { } -bool RasterizerStorageOpenGL::voxel_gi_is_interior(RID p_voxel_gi) const { +bool RasterizerStorageGLES3::voxel_gi_is_interior(RID p_voxel_gi) const { return false; } -void RasterizerStorageOpenGL::voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) { +void RasterizerStorageGLES3::voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) { } -bool RasterizerStorageOpenGL::voxel_gi_is_using_two_bounces(RID p_voxel_gi) const { +bool RasterizerStorageGLES3::voxel_gi_is_using_two_bounces(RID p_voxel_gi) const { return false; } -void RasterizerStorageOpenGL::voxel_gi_set_anisotropy_strength(RID p_voxel_gi, float p_strength) { +void RasterizerStorageGLES3::voxel_gi_set_anisotropy_strength(RID p_voxel_gi, float p_strength) { } -float RasterizerStorageOpenGL::voxel_gi_get_anisotropy_strength(RID p_voxel_gi) const { +float RasterizerStorageGLES3::voxel_gi_get_anisotropy_strength(RID p_voxel_gi) const { return 0; } -uint32_t RasterizerStorageOpenGL::voxel_gi_get_version(RID p_voxel_gi) { +uint32_t RasterizerStorageGLES3::voxel_gi_get_version(RID p_voxel_gi) { return 0; } /* LIGHTMAP CAPTURE */ -RID RasterizerStorageOpenGL::lightmap_allocate() { +RID RasterizerStorageGLES3::lightmap_allocate() { return RID(); } -void RasterizerStorageOpenGL::lightmap_initialize(RID p_rid) { +void RasterizerStorageGLES3::lightmap_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) { +void RasterizerStorageGLES3::lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) { } -void RasterizerStorageOpenGL::lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) { +void RasterizerStorageGLES3::lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) { } -void RasterizerStorageOpenGL::lightmap_set_probe_interior(RID p_lightmap, bool p_interior) { +void RasterizerStorageGLES3::lightmap_set_probe_interior(RID p_lightmap, bool p_interior) { } -void RasterizerStorageOpenGL::lightmap_set_probe_capture_data(RID p_lightmap, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) { +void RasterizerStorageGLES3::lightmap_set_probe_capture_data(RID p_lightmap, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) { } -PackedVector3Array RasterizerStorageOpenGL::lightmap_get_probe_capture_points(RID p_lightmap) const { +PackedVector3Array RasterizerStorageGLES3::lightmap_get_probe_capture_points(RID p_lightmap) const { return PackedVector3Array(); } -PackedColorArray RasterizerStorageOpenGL::lightmap_get_probe_capture_sh(RID p_lightmap) const { +PackedColorArray RasterizerStorageGLES3::lightmap_get_probe_capture_sh(RID p_lightmap) const { return PackedColorArray(); } -PackedInt32Array RasterizerStorageOpenGL::lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const { +PackedInt32Array RasterizerStorageGLES3::lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const { return PackedInt32Array(); } -PackedInt32Array RasterizerStorageOpenGL::lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const { +PackedInt32Array RasterizerStorageGLES3::lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const { return PackedInt32Array(); } -AABB RasterizerStorageOpenGL::lightmap_get_aabb(RID p_lightmap) const { +AABB RasterizerStorageGLES3::lightmap_get_aabb(RID p_lightmap) const { return AABB(); } -void RasterizerStorageOpenGL::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) { +void RasterizerStorageGLES3::lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) { } -bool RasterizerStorageOpenGL::lightmap_is_interior(RID p_lightmap) const { +bool RasterizerStorageGLES3::lightmap_is_interior(RID p_lightmap) const { return false; } -void RasterizerStorageOpenGL::lightmap_set_probe_capture_update_speed(float p_speed) { +void RasterizerStorageGLES3::lightmap_set_probe_capture_update_speed(float p_speed) { } -float RasterizerStorageOpenGL::lightmap_get_probe_capture_update_speed() const { +float RasterizerStorageGLES3::lightmap_get_probe_capture_update_speed() const { return 0; } /* OCCLUDER */ -void RasterizerStorageOpenGL::occluder_set_mesh(RID p_occluder, const PackedVector3Array &p_vertices, const PackedInt32Array &p_indices) { +void RasterizerStorageGLES3::occluder_set_mesh(RID p_occluder, const PackedVector3Array &p_vertices, const PackedInt32Array &p_indices) { } /* PARTICLES */ -RID RasterizerStorageOpenGL::particles_allocate() { +RID RasterizerStorageGLES3::particles_allocate() { return RID(); } -void RasterizerStorageOpenGL::particles_initialize(RID p_rid) { +void RasterizerStorageGLES3::particles_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::particles_set_mode(RID p_particles, RS::ParticlesMode p_mode) { +void RasterizerStorageGLES3::particles_set_mode(RID p_particles, RS::ParticlesMode p_mode) { } -void RasterizerStorageOpenGL::particles_emit(RID p_particles, const Transform3D &p_transform, const Vector3 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags) { +void RasterizerStorageGLES3::particles_emit(RID p_particles, const Transform3D &p_transform, const Vector3 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags) { } -void RasterizerStorageOpenGL::particles_set_emitting(RID p_particles, bool p_emitting) { +void RasterizerStorageGLES3::particles_set_emitting(RID p_particles, bool p_emitting) { } -void RasterizerStorageOpenGL::particles_set_amount(RID p_particles, int p_amount) { +void RasterizerStorageGLES3::particles_set_amount(RID p_particles, int p_amount) { } -void RasterizerStorageOpenGL::particles_set_lifetime(RID p_particles, double p_lifetime) { +void RasterizerStorageGLES3::particles_set_lifetime(RID p_particles, double p_lifetime) { } -void RasterizerStorageOpenGL::particles_set_one_shot(RID p_particles, bool p_one_shot) { +void RasterizerStorageGLES3::particles_set_one_shot(RID p_particles, bool p_one_shot) { } -void RasterizerStorageOpenGL::particles_set_pre_process_time(RID p_particles, double p_time) { +void RasterizerStorageGLES3::particles_set_pre_process_time(RID p_particles, double p_time) { } -void RasterizerStorageOpenGL::particles_set_explosiveness_ratio(RID p_particles, real_t p_ratio) { +void RasterizerStorageGLES3::particles_set_explosiveness_ratio(RID p_particles, real_t p_ratio) { } -void RasterizerStorageOpenGL::particles_set_randomness_ratio(RID p_particles, real_t p_ratio) { +void RasterizerStorageGLES3::particles_set_randomness_ratio(RID p_particles, real_t p_ratio) { } -void RasterizerStorageOpenGL::particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) { +void RasterizerStorageGLES3::particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) { } -void RasterizerStorageOpenGL::particles_set_speed_scale(RID p_particles, double p_scale) { +void RasterizerStorageGLES3::particles_set_speed_scale(RID p_particles, double p_scale) { } -void RasterizerStorageOpenGL::particles_set_use_local_coordinates(RID p_particles, bool p_enable) { +void RasterizerStorageGLES3::particles_set_use_local_coordinates(RID p_particles, bool p_enable) { } -void RasterizerStorageOpenGL::particles_set_process_material(RID p_particles, RID p_material) { +void RasterizerStorageGLES3::particles_set_process_material(RID p_particles, RID p_material) { } -void RasterizerStorageOpenGL::particles_set_fixed_fps(RID p_particles, int p_fps) { +void RasterizerStorageGLES3::particles_set_fixed_fps(RID p_particles, int p_fps) { } -void RasterizerStorageOpenGL::particles_set_interpolate(RID p_particles, bool p_enable) { +void RasterizerStorageGLES3::particles_set_interpolate(RID p_particles, bool p_enable) { } -void RasterizerStorageOpenGL::particles_set_fractional_delta(RID p_particles, bool p_enable) { +void RasterizerStorageGLES3::particles_set_fractional_delta(RID p_particles, bool p_enable) { } -void RasterizerStorageOpenGL::particles_set_subemitter(RID p_particles, RID p_subemitter_particles) { +void RasterizerStorageGLES3::particles_set_subemitter(RID p_particles, RID p_subemitter_particles) { } -void RasterizerStorageOpenGL::particles_set_view_axis(RID p_particles, const Vector3 &p_axis, const Vector3 &p_up_axis) { +void RasterizerStorageGLES3::particles_set_view_axis(RID p_particles, const Vector3 &p_axis, const Vector3 &p_up_axis) { } -void RasterizerStorageOpenGL::particles_set_collision_base_size(RID p_particles, real_t p_size) { +void RasterizerStorageGLES3::particles_set_collision_base_size(RID p_particles, real_t p_size) { } -void RasterizerStorageOpenGL::particles_set_transform_align(RID p_particles, RS::ParticlesTransformAlign p_transform_align) { +void RasterizerStorageGLES3::particles_set_transform_align(RID p_particles, RS::ParticlesTransformAlign p_transform_align) { } -void RasterizerStorageOpenGL::particles_set_trails(RID p_particles, bool p_enable, double p_length) { +void RasterizerStorageGLES3::particles_set_trails(RID p_particles, bool p_enable, double p_length) { } -void RasterizerStorageOpenGL::particles_set_trail_bind_poses(RID p_particles, const Vector &p_bind_poses) { +void RasterizerStorageGLES3::particles_set_trail_bind_poses(RID p_particles, const Vector &p_bind_poses) { } -void RasterizerStorageOpenGL::particles_restart(RID p_particles) { +void RasterizerStorageGLES3::particles_restart(RID p_particles) { } -void RasterizerStorageOpenGL::particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) { +void RasterizerStorageGLES3::particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) { } -void RasterizerStorageOpenGL::particles_set_draw_passes(RID p_particles, int p_count) { +void RasterizerStorageGLES3::particles_set_draw_passes(RID p_particles, int p_count) { } -void RasterizerStorageOpenGL::particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) { +void RasterizerStorageGLES3::particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) { } -void RasterizerStorageOpenGL::particles_request_process(RID p_particles) { +void RasterizerStorageGLES3::particles_request_process(RID p_particles) { } -AABB RasterizerStorageOpenGL::particles_get_current_aabb(RID p_particles) { +AABB RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { return AABB(); } -AABB RasterizerStorageOpenGL::particles_get_aabb(RID p_particles) const { +AABB RasterizerStorageGLES3::particles_get_aabb(RID p_particles) const { return AABB(); } -void RasterizerStorageOpenGL::particles_set_emission_transform(RID p_particles, const Transform3D &p_transform) { +void RasterizerStorageGLES3::particles_set_emission_transform(RID p_particles, const Transform3D &p_transform) { } -bool RasterizerStorageOpenGL::particles_get_emitting(RID p_particles) { +bool RasterizerStorageGLES3::particles_get_emitting(RID p_particles) { return false; } -int RasterizerStorageOpenGL::particles_get_draw_passes(RID p_particles) const { +int RasterizerStorageGLES3::particles_get_draw_passes(RID p_particles) const { return 0; } -RID RasterizerStorageOpenGL::particles_get_draw_pass_mesh(RID p_particles, int p_pass) const { +RID RasterizerStorageGLES3::particles_get_draw_pass_mesh(RID p_particles, int p_pass) const { return RID(); } -void RasterizerStorageOpenGL::particles_add_collision(RID p_particles, RID p_instance) { +void RasterizerStorageGLES3::particles_add_collision(RID p_particles, RID p_instance) { } -void RasterizerStorageOpenGL::particles_remove_collision(RID p_particles, RID p_instance) { +void RasterizerStorageGLES3::particles_remove_collision(RID p_particles, RID p_instance) { } -void RasterizerStorageOpenGL::particles_set_canvas_sdf_collision(RID p_particles, bool p_enable, const Transform2D &p_xform, const Rect2 &p_to_screen, RID p_texture) { +void RasterizerStorageGLES3::particles_set_canvas_sdf_collision(RID p_particles, bool p_enable, const Transform2D &p_xform, const Rect2 &p_to_screen, RID p_texture) { } -void RasterizerStorageOpenGL::update_particles() { +void RasterizerStorageGLES3::update_particles() { } /* PARTICLES COLLISION */ -RID RasterizerStorageOpenGL::particles_collision_allocate() { +RID RasterizerStorageGLES3::particles_collision_allocate() { return RID(); } -void RasterizerStorageOpenGL::particles_collision_initialize(RID p_rid) { +void RasterizerStorageGLES3::particles_collision_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::particles_collision_set_collision_type(RID p_particles_collision, RS::ParticlesCollisionType p_type) { +void RasterizerStorageGLES3::particles_collision_set_collision_type(RID p_particles_collision, RS::ParticlesCollisionType p_type) { } -void RasterizerStorageOpenGL::particles_collision_set_cull_mask(RID p_particles_collision, uint32_t p_cull_mask) { +void RasterizerStorageGLES3::particles_collision_set_cull_mask(RID p_particles_collision, uint32_t p_cull_mask) { } -void RasterizerStorageOpenGL::particles_collision_set_sphere_radius(RID p_particles_collision, real_t p_radius) { +void RasterizerStorageGLES3::particles_collision_set_sphere_radius(RID p_particles_collision, real_t p_radius) { } -void RasterizerStorageOpenGL::particles_collision_set_box_extents(RID p_particles_collision, const Vector3 &p_extents) { +void RasterizerStorageGLES3::particles_collision_set_box_extents(RID p_particles_collision, const Vector3 &p_extents) { } -void RasterizerStorageOpenGL::particles_collision_set_attractor_strength(RID p_particles_collision, real_t p_strength) { +void RasterizerStorageGLES3::particles_collision_set_attractor_strength(RID p_particles_collision, real_t p_strength) { } -void RasterizerStorageOpenGL::particles_collision_set_attractor_directionality(RID p_particles_collision, real_t p_directionality) { +void RasterizerStorageGLES3::particles_collision_set_attractor_directionality(RID p_particles_collision, real_t p_directionality) { } -void RasterizerStorageOpenGL::particles_collision_set_attractor_attenuation(RID p_particles_collision, real_t p_curve) { +void RasterizerStorageGLES3::particles_collision_set_attractor_attenuation(RID p_particles_collision, real_t p_curve) { } -void RasterizerStorageOpenGL::particles_collision_set_field_texture(RID p_particles_collision, RID p_texture) { +void RasterizerStorageGLES3::particles_collision_set_field_texture(RID p_particles_collision, RID p_texture) { } -void RasterizerStorageOpenGL::particles_collision_height_field_update(RID p_particles_collision) { +void RasterizerStorageGLES3::particles_collision_height_field_update(RID p_particles_collision) { } -void RasterizerStorageOpenGL::particles_collision_set_height_field_resolution(RID p_particles_collision, RS::ParticlesCollisionHeightfieldResolution p_resolution) { +void RasterizerStorageGLES3::particles_collision_set_height_field_resolution(RID p_particles_collision, RS::ParticlesCollisionHeightfieldResolution p_resolution) { } -AABB RasterizerStorageOpenGL::particles_collision_get_aabb(RID p_particles_collision) const { +AABB RasterizerStorageGLES3::particles_collision_get_aabb(RID p_particles_collision) const { return AABB(); } -bool RasterizerStorageOpenGL::particles_collision_is_heightfield(RID p_particles_collision) const { +bool RasterizerStorageGLES3::particles_collision_is_heightfield(RID p_particles_collision) const { return false; } -RID RasterizerStorageOpenGL::particles_collision_get_heightfield_framebuffer(RID p_particles_collision) const { +RID RasterizerStorageGLES3::particles_collision_get_heightfield_framebuffer(RID p_particles_collision) const { return RID(); } -RID RasterizerStorageOpenGL::particles_collision_instance_create(RID p_collision) { +RID RasterizerStorageGLES3::particles_collision_instance_create(RID p_collision) { return RID(); } -void RasterizerStorageOpenGL::particles_collision_instance_set_transform(RID p_collision_instance, const Transform3D &p_transform) { +void RasterizerStorageGLES3::particles_collision_instance_set_transform(RID p_collision_instance, const Transform3D &p_transform) { } -void RasterizerStorageOpenGL::particles_collision_instance_set_active(RID p_collision_instance, bool p_active) { +void RasterizerStorageGLES3::particles_collision_instance_set_active(RID p_collision_instance, bool p_active) { } -/* VISIBILITY NOTIFIER */ -RID RasterizerStorageOpenGL::visibility_notifier_allocate() { +RID RasterizerStorageGLES3::fog_volume_allocate() { return RID(); } -void RasterizerStorageOpenGL::visibility_notifier_initialize(RID p_notifier) { +void RasterizerStorageGLES3::fog_volume_initialize(RID p_rid) { } -void RasterizerStorageOpenGL::visibility_notifier_set_aabb(RID p_notifier, const AABB &p_aabb) { +void RasterizerStorageGLES3::fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) { } -void RasterizerStorageOpenGL::visibility_notifier_set_callbacks(RID p_notifier, const Callable &p_enter_callbable, const Callable &p_exit_callable) { +void RasterizerStorageGLES3::fog_volume_set_extents(RID p_fog_volume, const Vector3 &p_extents) { } -AABB RasterizerStorageOpenGL::visibility_notifier_get_aabb(RID p_notifier) const { +void RasterizerStorageGLES3::fog_volume_set_material(RID p_fog_volume, RID p_material) { +} + +AABB RasterizerStorageGLES3::fog_volume_get_aabb(RID p_fog_volume) const { return AABB(); } -void RasterizerStorageOpenGL::visibility_notifier_call(RID p_notifier, bool p_enter, bool p_deferred) { +RS::FogVolumeShape RasterizerStorageGLES3::fog_volume_get_shape(RID p_fog_volume) const { + return RS::FOG_VOLUME_SHAPE_BOX; +} + +/* VISIBILITY NOTIFIER */ +RID RasterizerStorageGLES3::visibility_notifier_allocate() { + return RID(); +} + +void RasterizerStorageGLES3::visibility_notifier_initialize(RID p_notifier) { +} + +void RasterizerStorageGLES3::visibility_notifier_set_aabb(RID p_notifier, const AABB &p_aabb) { +} + +void RasterizerStorageGLES3::visibility_notifier_set_callbacks(RID p_notifier, const Callable &p_enter_callbable, const Callable &p_exit_callable) { +} + +AABB RasterizerStorageGLES3::visibility_notifier_get_aabb(RID p_notifier) const { + return AABB(); +} + +void RasterizerStorageGLES3::visibility_notifier_call(RID p_notifier, bool p_enter, bool p_deferred) { } /* GLOBAL VARIABLES */ -void RasterizerStorageOpenGL::global_variable_add(const StringName &p_name, RS::GlobalVariableType p_type, const Variant &p_value) { +void RasterizerStorageGLES3::global_variable_add(const StringName &p_name, RS::GlobalVariableType p_type, const Variant &p_value) { } -void RasterizerStorageOpenGL::global_variable_remove(const StringName &p_name) { +void RasterizerStorageGLES3::global_variable_remove(const StringName &p_name) { } -Vector RasterizerStorageOpenGL::global_variable_get_list() const { +Vector RasterizerStorageGLES3::global_variable_get_list() const { return Vector(); } -void RasterizerStorageOpenGL::global_variable_set(const StringName &p_name, const Variant &p_value) { +void RasterizerStorageGLES3::global_variable_set(const StringName &p_name, const Variant &p_value) { } -void RasterizerStorageOpenGL::global_variable_set_override(const StringName &p_name, const Variant &p_value) { +void RasterizerStorageGLES3::global_variable_set_override(const StringName &p_name, const Variant &p_value) { } -Variant RasterizerStorageOpenGL::global_variable_get(const StringName &p_name) const { +Variant RasterizerStorageGLES3::global_variable_get(const StringName &p_name) const { return Variant(); } -RS::GlobalVariableType RasterizerStorageOpenGL::global_variable_get_type(const StringName &p_name) const { +RS::GlobalVariableType RasterizerStorageGLES3::global_variable_get_type(const StringName &p_name) const { return RS::GLOBAL_VAR_TYPE_MAX; } -void RasterizerStorageOpenGL::global_variables_load_settings(bool p_load_textures) { +void RasterizerStorageGLES3::global_variables_load_settings(bool p_load_textures) { } -void RasterizerStorageOpenGL::global_variables_clear() { +void RasterizerStorageGLES3::global_variables_clear() { } -int32_t RasterizerStorageOpenGL::global_variables_instance_allocate(RID p_instance) { +int32_t RasterizerStorageGLES3::global_variables_instance_allocate(RID p_instance) { return 0; } -void RasterizerStorageOpenGL::global_variables_instance_free(RID p_instance) { +void RasterizerStorageGLES3::global_variables_instance_free(RID p_instance) { } -void RasterizerStorageOpenGL::global_variables_instance_update(RID p_instance, int p_index, const Variant &p_value) { +void RasterizerStorageGLES3::global_variables_instance_update(RID p_instance, int p_index, const Variant &p_value) { } -bool RasterizerStorageOpenGL::particles_is_inactive(RID p_particles) const { +bool RasterizerStorageGLES3::particles_is_inactive(RID p_particles) const { return false; } /* RENDER TARGET */ -void RasterizerStorageOpenGL::_set_current_render_target(RID p_render_target) { +void RasterizerStorageGLES3::_set_current_render_target(RID p_render_target) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3068,7 +3139,7 @@ void RasterizerStorageOpenGL::_set_current_render_target(RID p_render_target) { } // if (p_render_target.is_valid()) { - // RasterizerStorageOpenGL::RenderTarget *rt = storage.render_target_owner.get_or_null(p_render_target); + // RasterizerStorageGLES3::RenderTarget *rt = storage.render_target_owner.get_or_null(p_render_target); frame.current_rt = rt; ERR_FAIL_COND(!rt); frame.clear_request = false; @@ -3091,7 +3162,7 @@ void RasterizerStorageOpenGL::_set_current_render_target(RID p_render_target) { } } -void RasterizerStorageOpenGL::_render_target_allocate(RenderTarget *rt) { +void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3102,7 +3173,7 @@ void RasterizerStorageOpenGL::_render_target_allocate(RenderTarget *rt) { // do not allocate a render target that is attached to the screen if (rt->flags[RENDER_TARGET_DIRECT_TO_SCREEN]) { - rt->fbo = RasterizerStorageOpenGL::system_fbo; + rt->fbo = RasterizerStorageGLES3::system_fbo; return; } @@ -3223,7 +3294,7 @@ void RasterizerStorageOpenGL::_render_target_allocate(RenderTarget *rt) { /* For MSAA */ #ifndef JAVASCRIPT_ENABLED - if (rt->msaa >= RS::VIEWPORT_MSAA_2X && rt->msaa <= RS::VIEWPORT_MSAA_8X && config.multisample_supported) { + if (rt->msaa >= RS::VIEWPORT_MSAA_2X && rt->msaa <= RS::VIEWPORT_MSAA_8X) { rt->multisample_active = true; static const int msaa_value[] = { 0, 2, 4, 8, 16 }; @@ -3246,26 +3317,11 @@ void RasterizerStorageOpenGL::_render_target_allocate(RenderTarget *rt) { glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->multisample_depth); -#if defined(GLES_OVER_GL) || defined(IPHONE_ENABLED) - glGenRenderbuffers(1, &rt->multisample_color); glBindRenderbuffer(GL_RENDERBUFFER, rt->multisample_color); glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, color_internal_format, rt->width, rt->height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rt->multisample_color); -#elif ANDROID_ENABLED - // Render to a texture in android - glGenTextures(1, &rt->multisample_color); - glBindTexture(GL_TEXTURE_2D, rt->multisample_color); - - glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, NULL); - - // multisample buffer is same size as front buffer, so just use nearest - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->multisample_color, 0, msaa); -#endif GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); @@ -3273,7 +3329,6 @@ void RasterizerStorageOpenGL::_render_target_allocate(RenderTarget *rt) { // Delete allocated resources and default to no MSAA WARN_PRINT_ONCE("Cannot allocate back framebuffer for MSAA"); printf("err status: %x\n", status); - config.multisample_supported = false; rt->multisample_active = false; glDeleteFramebuffers(1, &rt->multisample_fbo); @@ -3281,19 +3336,13 @@ void RasterizerStorageOpenGL::_render_target_allocate(RenderTarget *rt) { glDeleteRenderbuffers(1, &rt->multisample_depth); rt->multisample_depth = 0; -#ifdef ANDROID_ENABLED - glDeleteTextures(1, &rt->multisample_color); -#else + glDeleteRenderbuffers(1, &rt->multisample_color); -#endif rt->multisample_color = 0; } glBindRenderbuffer(GL_RENDERBUFFER, 0); bind_framebuffer(0); -#ifdef ANDROID_ENABLED - glBindTexture(GL_TEXTURE_2D, 0); -#endif } else #endif // JAVASCRIPT_ENABLED @@ -3455,7 +3504,7 @@ void RasterizerStorageOpenGL::_render_target_allocate(RenderTarget *rt) { bind_framebuffer_system(); } -void RasterizerStorageOpenGL::_render_target_clear(RenderTarget *rt) { +void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3532,16 +3581,14 @@ void RasterizerStorageOpenGL::_render_target_clear(RenderTarget *rt) { glDeleteRenderbuffers(1, &rt->multisample_depth); rt->multisample_depth = 0; -#ifdef ANDROID_ENABLED - glDeleteTextures(1, &rt->multisample_color); -#else + glDeleteRenderbuffers(1, &rt->multisample_color); -#endif + rt->multisample_color = 0; } } -RID RasterizerStorageOpenGL::render_target_create() { +RID RasterizerStorageGLES3::render_target_create() { #ifdef OPENGL_DISABLE_RENDER_TARGETS // return RID(); #endif @@ -3573,7 +3620,7 @@ RID RasterizerStorageOpenGL::render_target_create() { return render_target_owner.make_rid(rt); } -void RasterizerStorageOpenGL::render_target_set_position(RID p_render_target, int p_x, int p_y) { +void RasterizerStorageGLES3::render_target_set_position(RID p_render_target, int p_x, int p_y) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3585,7 +3632,7 @@ void RasterizerStorageOpenGL::render_target_set_position(RID p_render_target, in rt->y = p_y; } -void RasterizerStorageOpenGL::render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) { +void RasterizerStorageGLES3::render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3607,7 +3654,7 @@ void RasterizerStorageOpenGL::render_target_set_size(RID p_render_target, int p_ //_render_target_allocate(rt); } -RID RasterizerStorageOpenGL::render_target_get_texture(RID p_render_target) { +RID RasterizerStorageGLES3::render_target_get_texture(RID p_render_target) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return RID(); #endif @@ -3622,7 +3669,7 @@ RID RasterizerStorageOpenGL::render_target_get_texture(RID p_render_target) { } } -void RasterizerStorageOpenGL::render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) { +void RasterizerStorageGLES3::render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3707,31 +3754,6 @@ void RasterizerStorageOpenGL::render_target_set_external_texture(RID p_render_ta t->alloc_width = rt->height; // Switch our texture on our frame buffer -#if ANDROID_ENABLED - if (rt->msaa >= RS::VIEWPORT_MSAA_2X && rt->msaa <= RS::VIEWPORT_MSAA_4X) { - // This code only applies to the Oculus Go and Oculus Quest. Due to the the tiled nature - // of the GPU we can do a single render pass by rendering directly into our texture chains - // texture and apply MSAA as we render. - - // On any other hardware these two modes are ignored and we do not have any MSAA, - // the normal MSAA modes need to be used to enable our two pass approach - - static const int msaa_value[] = { 2, 4 }; - int msaa = msaa_value[rt->msaa - RS::VIEWPORT_MSAA_2X]; - - if (rt->external.depth == 0) { - // create a multisample depth buffer, we're not reusing Godots because Godot's didn't get created.. - glGenRenderbuffers(1, &rt->external.depth); - glBindRenderbuffer(GL_RENDERBUFFER, rt->external.depth); - glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, config.depth_buffer_internalformat, rt->width, rt->height); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->external.depth); - } - - // and set our external texture as the texture... - glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_texture_id, 0, msaa); - - } else -#endif { // set our texture as the destination for our framebuffer glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_texture_id, 0); @@ -3756,7 +3778,7 @@ void RasterizerStorageOpenGL::render_target_set_external_texture(RID p_render_ta } } -void RasterizerStorageOpenGL::render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) { +void RasterizerStorageGLES3::render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3792,7 +3814,7 @@ void RasterizerStorageOpenGL::render_target_set_flag(RID p_render_target, Render } } -bool RasterizerStorageOpenGL::render_target_was_used(RID p_render_target) { +bool RasterizerStorageGLES3::render_target_was_used(RID p_render_target) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return false; #endif @@ -3803,7 +3825,7 @@ bool RasterizerStorageOpenGL::render_target_was_used(RID p_render_target) { return rt->used_in_frame; } -void RasterizerStorageOpenGL::render_target_clear_used(RID p_render_target) { +void RasterizerStorageGLES3::render_target_clear_used(RID p_render_target) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3814,7 +3836,7 @@ void RasterizerStorageOpenGL::render_target_clear_used(RID p_render_target) { rt->used_in_frame = false; } -void RasterizerStorageOpenGL::render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) { +void RasterizerStorageGLES3::render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3825,22 +3847,17 @@ void RasterizerStorageOpenGL::render_target_set_msaa(RID p_render_target, RS::Vi if (rt->msaa == p_msaa) return; - if (!config.multisample_supported) { - ERR_PRINT("MSAA not supported on this hardware."); - return; - } - _render_target_clear(rt); rt->msaa = p_msaa; _render_target_allocate(rt); } -//RasterizerStorageOpenGL::RenderTarget * RasterizerStorageOpenGL::render_target_get(RID p_render_target) +//RasterizerStorageGLES3::RenderTarget * RasterizerStorageGLES3::render_target_get(RID p_render_target) //{ // return render_target_owner.get_or_null(p_render_target); //} -void RasterizerStorageOpenGL::render_target_set_use_fxaa(RID p_render_target, bool p_fxaa) { +void RasterizerStorageGLES3::render_target_set_use_fxaa(RID p_render_target, bool p_fxaa) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3851,7 +3868,7 @@ void RasterizerStorageOpenGL::render_target_set_use_fxaa(RID p_render_target, bo rt->use_fxaa = p_fxaa; } -void RasterizerStorageOpenGL::render_target_set_use_debanding(RID p_render_target, bool p_debanding) { +void RasterizerStorageGLES3::render_target_set_use_debanding(RID p_render_target, bool p_debanding) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3866,7 +3883,7 @@ void RasterizerStorageOpenGL::render_target_set_use_debanding(RID p_render_targe rt->use_debanding = p_debanding; } -void RasterizerStorageOpenGL::render_target_request_clear(RID p_render_target, const Color &p_clear_color) { +void RasterizerStorageGLES3::render_target_request_clear(RID p_render_target, const Color &p_clear_color) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3881,7 +3898,7 @@ void RasterizerStorageOpenGL::render_target_request_clear(RID p_render_target, c // frame.clear_request_color = p_color; } -bool RasterizerStorageOpenGL::render_target_is_clear_requested(RID p_render_target) { +bool RasterizerStorageGLES3::render_target_is_clear_requested(RID p_render_target) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return false; #endif @@ -3889,7 +3906,7 @@ bool RasterizerStorageOpenGL::render_target_is_clear_requested(RID p_render_targ ERR_FAIL_COND_V(!rt, false); return rt->clear_requested; } -Color RasterizerStorageOpenGL::render_target_get_clear_request_color(RID p_render_target) { +Color RasterizerStorageGLES3::render_target_get_clear_request_color(RID p_render_target) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return Color(); #endif @@ -3899,7 +3916,7 @@ Color RasterizerStorageOpenGL::render_target_get_clear_request_color(RID p_rende return rt->clear_color; } -void RasterizerStorageOpenGL::render_target_disable_clear_request(RID p_render_target) { +void RasterizerStorageGLES3::render_target_disable_clear_request(RID p_render_target) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3908,7 +3925,7 @@ void RasterizerStorageOpenGL::render_target_disable_clear_request(RID p_render_t rt->clear_requested = false; } -void RasterizerStorageOpenGL::render_target_do_clear_request(RID p_render_target) { +void RasterizerStorageGLES3::render_target_do_clear_request(RID p_render_target) { #ifdef OPENGL_DISABLE_RENDER_TARGETS return; #endif @@ -3933,19 +3950,19 @@ void RasterizerStorageOpenGL::render_target_do_clear_request(RID p_render_target */ } -void RasterizerStorageOpenGL::render_target_set_sdf_size_and_scale(RID p_render_target, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) { +void RasterizerStorageGLES3::render_target_set_sdf_size_and_scale(RID p_render_target, RS::ViewportSDFOversize p_size, RS::ViewportSDFScale p_scale) { } -Rect2i RasterizerStorageOpenGL::render_target_get_sdf_rect(RID p_render_target) const { +Rect2i RasterizerStorageGLES3::render_target_get_sdf_rect(RID p_render_target) const { return Rect2i(); } -void RasterizerStorageOpenGL::render_target_mark_sdf_enabled(RID p_render_target, bool p_enabled) { +void RasterizerStorageGLES3::render_target_mark_sdf_enabled(RID p_render_target, bool p_enabled) { } /* CANVAS SHADOW */ -RID RasterizerStorageOpenGL::canvas_light_shadow_buffer_create(int p_width) { +RID RasterizerStorageGLES3::canvas_light_shadow_buffer_create(int p_width) { CanvasLightShadow *cls = memnew(CanvasLightShadow); if (p_width > config.max_texture_size) @@ -3997,7 +4014,7 @@ RID RasterizerStorageOpenGL::canvas_light_shadow_buffer_create(int p_width) { /* LIGHT SHADOW MAPPING */ /* -RID RasterizerStorageOpenGL::canvas_light_occluder_create() { +RID RasterizerStorageGLES3::canvas_light_occluder_create() { CanvasOccluder *co = memnew(CanvasOccluder); co->index_id = 0; co->vertex_id = 0; @@ -4006,7 +4023,7 @@ RID RasterizerStorageOpenGL::canvas_light_occluder_create() { return canvas_occluder_owner.make_rid(co); } -void RasterizerStorageOpenGL::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector &p_lines) { +void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector &p_lines) { CanvasOccluder *co = canvas_occluder_owner.get(p_occluder); ERR_FAIL_COND(!co); @@ -4093,7 +4110,7 @@ void RasterizerStorageOpenGL::canvas_light_occluder_set_polylines(RID p_occluder } */ -RS::InstanceType RasterizerStorageOpenGL::get_base_type(RID p_rid) const { +RS::InstanceType RasterizerStorageGLES3::get_base_type(RID p_rid) const { return RS::INSTANCE_NONE; /* @@ -4115,7 +4132,7 @@ RS::InstanceType RasterizerStorageOpenGL::get_base_type(RID p_rid) const { */ } -bool RasterizerStorageOpenGL::free(RID p_rid) { +bool RasterizerStorageGLES3::free(RID p_rid) { if (render_target_owner.owns(p_rid)) { RenderTarget *rt = render_target_owner.get_or_null(p_rid); _render_target_clear(rt); @@ -4327,7 +4344,7 @@ bool RasterizerStorageOpenGL::free(RID p_rid) { */ } -bool RasterizerStorageOpenGL::has_os_feature(const String &p_feature) const { +bool RasterizerStorageGLES3::has_os_feature(const String &p_feature) const { if (p_feature == "pvrtc") return config.pvrtc_supported; @@ -4335,7 +4352,7 @@ bool RasterizerStorageOpenGL::has_os_feature(const String &p_feature) const { return config.s3tc_supported; if (p_feature == "etc") - return config.etc1_supported; + return config.etc_supported; if (p_feature == "skinning_fallback") return config.use_skeleton_software; @@ -4345,14 +4362,14 @@ bool RasterizerStorageOpenGL::has_os_feature(const String &p_feature) const { //////////////////////////////////////////// -void RasterizerStorageOpenGL::set_debug_generate_wireframes(bool p_generate) { +void RasterizerStorageGLES3::set_debug_generate_wireframes(bool p_generate) { } -//void RasterizerStorageOpenGL::render_info_begin_capture() { +//void RasterizerStorageGLES3::render_info_begin_capture() { // info.snap = info.render; //} -//void RasterizerStorageOpenGL::render_info_end_capture() { +//void RasterizerStorageGLES3::render_info_end_capture() { // info.snap.object_count = info.render.object_count - info.snap.object_count; // info.snap.draw_call_count = info.render.draw_call_count - info.snap.draw_call_count; // info.snap.material_switch_count = info.render.material_switch_count - info.snap.material_switch_count; @@ -4363,7 +4380,7 @@ void RasterizerStorageOpenGL::set_debug_generate_wireframes(bool p_generate) { // info.snap._2d_draw_call_count = info.render._2d_draw_call_count - info.snap._2d_draw_call_count; //} -//int RasterizerStorageOpenGL::get_captured_render_info(RS::RenderInfo p_info) { +//int RasterizerStorageGLES3::get_captured_render_info(RS::RenderInfo p_info) { // switch (p_info) { // case RS::INFO_OBJECTS_IN_FRAME: { // return info.snap.object_count; @@ -4397,7 +4414,7 @@ void RasterizerStorageOpenGL::set_debug_generate_wireframes(bool p_generate) { // } //} -//int RasterizerStorageOpenGL::get_render_info(RS::RenderInfo p_info) { +//int RasterizerStorageGLES3::get_render_info(RS::RenderInfo p_info) { // switch (p_info) { // case RS::INFO_OBJECTS_IN_FRAME: // return info.render_final.object_count; @@ -4430,16 +4447,16 @@ void RasterizerStorageOpenGL::set_debug_generate_wireframes(bool p_generate) { // } //} -String RasterizerStorageOpenGL::get_video_adapter_name() const { +String RasterizerStorageGLES3::get_video_adapter_name() const { return (const char *)glGetString(GL_RENDERER); } -String RasterizerStorageOpenGL::get_video_adapter_vendor() const { +String RasterizerStorageGLES3::get_video_adapter_vendor() const { return (const char *)glGetString(GL_VENDOR); } -void RasterizerStorageOpenGL::initialize() { - RasterizerStorageOpenGL::system_fbo = 0; +void RasterizerStorageGLES3::initialize() { + RasterizerStorageGLES3::system_fbo = 0; { const GLubyte *extension_string = glGetString(GL_EXTENSIONS); @@ -4461,13 +4478,13 @@ void RasterizerStorageOpenGL::initialize() { config.float_texture_supported = true; config.s3tc_supported = true; config.pvrtc_supported = false; - config.etc1_supported = false; + config.etc_supported = false; config.support_npot_repeat_mipmap = true; config.depth_buffer_internalformat = GL_DEPTH_COMPONENT24; #else config.float_texture_supported = config.extensions.has("GL_ARB_texture_float") || config.extensions.has("GL_OES_texture_float"); config.s3tc_supported = config.extensions.has("GL_EXT_texture_compression_s3tc") || config.extensions.has("WEBGL_compressed_texture_s3tc"); - config.etc1_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture") || config.extensions.has("WEBGL_compressed_texture_etc1"); + config.etc_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture") || config.extensions.has("WEBGL_compressed_texture_etc1"); config.pvrtc_supported = config.extensions.has("GL_IMG_texture_compression_pvrtc") || config.extensions.has("WEBGL_compressed_texture_pvrtc"); config.support_npot_repeat_mipmap = config.extensions.has("GL_OES_texture_npot"); @@ -4490,25 +4507,6 @@ void RasterizerStorageOpenGL::initialize() { #endif #endif -#ifndef GLES_OVER_GL - //Manually load extensions for android and ios - -#ifdef IPHONE_ENABLED - // appears that IPhone doesn't need to dlopen TODO: test this rigorously before removing - //void *gles2_lib = dlopen(NULL, RTLD_LAZY); - //glRenderbufferStorageMultisampleAPPLE = dlsym(gles2_lib, "glRenderbufferStorageMultisampleAPPLE"); - //glResolveMultisampleFramebufferAPPLE = dlsym(gles2_lib, "glResolveMultisampleFramebufferAPPLE"); -#elif ANDROID_ENABLED - - void *gles2_lib = dlopen("libGLESv2.so", RTLD_LAZY); - glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)dlsym(gles2_lib, "glRenderbufferStorageMultisampleEXT"); - glFramebufferTexture2DMultisampleEXT = (PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC)dlsym(gles2_lib, "glFramebufferTexture2DMultisampleEXT"); -#endif -#endif - - // Check for multisample support - config.multisample_supported = config.extensions.has("GL_EXT_framebuffer_multisample") || config.extensions.has("GL_EXT_multisampled_render_to_texture") || config.extensions.has("GL_APPLE_framebuffer_multisample"); - #ifdef GLES_OVER_GL //TODO: causes huge problems with desktop video drivers. Making false for now, needs to be true to render SCREEN_TEXTURE mipmaps config.render_to_mipmap_supported = false; @@ -4548,14 +4546,18 @@ void RasterizerStorageOpenGL::initialize() { #ifdef JAVASCRIPT_ENABLED config.support_half_float_vertices = false; #endif - bool disable_half_float = GLOBAL_GET("rendering/opengl/compatibility/disable_half_float"); + bool disable_half_float = false; //GLOBAL_GET("rendering/opengl/compatibility/disable_half_float"); if (disable_half_float) { config.support_half_float_vertices = false; } + config.etc_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture"); + config.latc_supported = config.extensions.has("GL_EXT_texture_compression_latc"); + config.bptc_supported = config.extensions.has("GL_ARB_texture_compression_bptc"); + config.pvrtc_supported = config.extensions.has("GL_IMG_texture_compression_pvrtc"); config.rgtc_supported = config.extensions.has("GL_EXT_texture_compression_rgtc") || config.extensions.has("GL_ARB_texture_compression_rgtc") || config.extensions.has("EXT_texture_compression_rgtc"); config.bptc_supported = config.extensions.has("GL_ARB_texture_compression_bptc") || config.extensions.has("EXT_texture_compression_bptc"); - + config.srgb_decode_supported = config.extensions.has("GL_EXT_texture_sRGB_decode"); //determine formats for depth textures (or renderbuffers) if (config.support_depth_texture) { // Will use texture for depth @@ -4640,8 +4642,8 @@ void RasterizerStorageOpenGL::initialize() { shaders.copy.init(); shaders.cubemap_filter.init(); - bool ggx_hq = GLOBAL_GET("rendering/quality/reflections/high_quality_ggx"); - shaders.cubemap_filter.set_conditional(CubemapFilterShaderOpenGL::LOW_QUALITY, !ggx_hq); + bool ggx_hq = false; //GLOBAL_GET("rendering/quality/reflections/high_quality_ggx"); + shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES3::LOW_QUALITY, !ggx_hq); { // quad for copying stuff @@ -4783,36 +4785,36 @@ void RasterizerStorageOpenGL::initialize() { glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); #endif - config.force_vertex_shading = GLOBAL_GET("rendering/quality/shading/force_vertex_shading"); - config.use_fast_texture_filter = GLOBAL_GET("rendering/quality/filters/use_nearest_mipmap_filter"); + config.force_vertex_shading = false; //GLOBAL_GET("rendering/quality/shading/force_vertex_shading"); + config.use_fast_texture_filter = false; //GLOBAL_GET("rendering/quality/filters/use_nearest_mipmap_filter"); //config.should_orphan = GLOBAL_GET("rendering/options/api_usage_legacy/orphan_buffers"); } -void RasterizerStorageOpenGL::finalize() { +void RasterizerStorageGLES3::finalize() { } -void RasterizerStorageOpenGL::_copy_screen() { +void RasterizerStorageGLES3::_copy_screen() { bind_quad_array(); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } -void RasterizerStorageOpenGL::update_memory_info() { +void RasterizerStorageGLES3::update_memory_info() { } -uint64_t RasterizerStorageOpenGL::get_rendering_info(RS::RenderingInfo p_info) { +uint64_t RasterizerStorageGLES3::get_rendering_info(RS::RenderingInfo p_info) { return 0; } -void RasterizerStorageOpenGL::update_dirty_resources() { +void RasterizerStorageGLES3::update_dirty_resources() { update_dirty_shaders(); update_dirty_materials(); // update_dirty_skeletons(); // update_dirty_multimeshes(); } -RasterizerStorageOpenGL::RasterizerStorageOpenGL() { - RasterizerStorageOpenGL::system_fbo = 0; +RasterizerStorageGLES3::RasterizerStorageGLES3() { + RasterizerStorageGLES3::system_fbo = 0; config.should_orphan = true; } -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED diff --git a/drivers/opengl/rasterizer_storage_opengl.h b/drivers/gles3/rasterizer_storage_gles3.h similarity index 96% rename from drivers/opengl/rasterizer_storage_opengl.h rename to drivers/gles3/rasterizer_storage_gles3.h index c054e47a66b..eb5614f70f5 100644 --- a/drivers/opengl/rasterizer_storage_opengl.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rasterizer_storage_opengl.h */ +/* rasterizer_storage_gles3.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,34 +31,34 @@ #ifndef RASTERIZER_STORAGE_OPENGL_H #define RASTERIZER_STORAGE_OPENGL_H -#include "drivers/opengl/rasterizer_platforms.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "drivers/gles3/rasterizer_platforms.h" +#ifdef GLES3_BACKEND_ENABLED #include "core/templates/local_vector.h" #include "core/templates/rid_owner.h" #include "core/templates/self_list.h" -#include "drivers/opengl/rasterizer_asserts.h" +#include "drivers/gles3/rasterizer_asserts.h" #include "servers/rendering/renderer_compositor.h" #include "servers/rendering/renderer_storage.h" #include "servers/rendering/shader_language.h" -#include "shader_compiler_opengl.h" -#include "shader_opengl.h" +#include "shader_compiler_gles3.h" +#include "shader_gles3.h" #include "shaders/copy.glsl.gen.h" #include "shaders/cubemap_filter.glsl.gen.h" -class RasterizerCanvasOpenGL; -class RasterizerSceneOpenGL; +class RasterizerCanvasGLES3; +class RasterizerSceneGLES3; -class RasterizerStorageOpenGL : public RendererStorage { - friend class RasterizerOpenGL; +class RasterizerStorageGLES3 : public RendererStorage { + friend class RasterizerGLES3; Thread::ID _main_thread_id = 0; bool _is_main_thread(); public: - RasterizerCanvasOpenGL *canvas; - RasterizerSceneOpenGL *scene; + RasterizerCanvasGLES3 *canvas; + RasterizerSceneGLES3 *scene; static GLuint system_fbo; @@ -78,10 +78,13 @@ public: bool float_texture_supported; bool s3tc_supported; - bool etc1_supported; - bool pvrtc_supported; + bool latc_supported; bool rgtc_supported; bool bptc_supported; + bool etc_supported; + bool etc2_supported; + bool pvrtc_supported; + bool srgb_decode_supported; bool keep_original_textures; @@ -99,7 +102,6 @@ public: bool support_shadow_cubemaps; - bool multisample_supported; bool render_to_mipmap_supported; GLuint depth_internalformat; @@ -132,14 +134,14 @@ public: } resources; mutable struct Shaders { - ShaderCompilerOpenGL compiler; + ShaderCompilerGLES3 compiler; - CopyShaderOpenGL copy; - CubemapFilterShaderOpenGL cubemap_filter; + CopyShaderGLES3 copy; + CubemapFilterShaderGLES3 cubemap_filter; - ShaderCompilerOpenGL::IdentifierActions actions_canvas; - ShaderCompilerOpenGL::IdentifierActions actions_scene; - ShaderCompilerOpenGL::IdentifierActions actions_particles; + ShaderCompilerGLES3::IdentifierActions actions_canvas; + ShaderCompilerGLES3::IdentifierActions actions_scene; + ShaderCompilerGLES3::IdentifierActions actions_particles; } shaders; @@ -565,7 +567,7 @@ public: RID self; RS::ShaderMode mode; - ShaderOpenGL *shader; + ShaderGLES3 *shader; String code; SelfList::List materials; @@ -1096,6 +1098,17 @@ public: void particles_collision_instance_set_transform(RID p_collision_instance, const Transform3D &p_transform) override; void particles_collision_instance_set_active(RID p_collision_instance, bool p_active) override; + /* FOG VOLUMES */ + + RID fog_volume_allocate() override; + void fog_volume_initialize(RID p_rid) override; + + void fog_volume_set_shape(RID p_fog_volume, RS::FogVolumeShape p_shape) override; + void fog_volume_set_extents(RID p_fog_volume, const Vector3 &p_extents) override; + void fog_volume_set_material(RID p_fog_volume, RID p_material) override; + AABB fog_volume_get_aabb(RID p_fog_volume) const override; + RS::FogVolumeShape fog_volume_get_shape(RID p_fog_volume) const override; + /* VISIBILITY NOTIFIER */ RID visibility_notifier_allocate() override; void visibility_notifier_initialize(RID p_notifier) override; @@ -1392,13 +1405,13 @@ public: } void bind_framebuffer_system() { - glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageOpenGL::system_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo); } - RasterizerStorageOpenGL(); + RasterizerStorageGLES3(); }; -inline bool RasterizerStorageOpenGL::safe_buffer_sub_data(unsigned int p_total_buffer_size, GLenum p_target, unsigned int p_offset, unsigned int p_data_size, const void *p_data, unsigned int &r_offset_after) const { +inline bool RasterizerStorageGLES3::safe_buffer_sub_data(unsigned int p_total_buffer_size, GLenum p_target, unsigned int p_offset, unsigned int p_data_size, const void *p_data, unsigned int &r_offset_after) const { r_offset_after = p_offset + p_data_size; #ifdef DEBUG_ENABLED // we are trying to write across the edge of the buffer @@ -1411,7 +1424,7 @@ inline bool RasterizerStorageOpenGL::safe_buffer_sub_data(unsigned int p_total_b // standardize the orphan / upload in one place so it can be changed per platform as necessary, and avoid future // bugs causing pipeline stalls -inline void RasterizerStorageOpenGL::buffer_orphan_and_upload(unsigned int p_buffer_size, unsigned int p_offset, unsigned int p_data_size, const void *p_data, GLenum p_target, GLenum p_usage, bool p_optional_orphan) const { +inline void RasterizerStorageGLES3::buffer_orphan_and_upload(unsigned int p_buffer_size, unsigned int p_offset, unsigned int p_data_size, const void *p_data, GLenum p_target, GLenum p_usage, bool p_optional_orphan) const { // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData // Was previously #ifndef GLES_OVER_GL however this causes stalls on desktop mac also (and possibly other) if (!p_optional_orphan || (config.should_orphan)) { @@ -1435,6 +1448,6 @@ inline void RasterizerStorageOpenGL::buffer_orphan_and_upload(unsigned int p_buf glBufferSubData(p_target, p_offset, p_data_size, p_data); } -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED #endif // RASTERIZER_STORAGE_OPENGL_H diff --git a/drivers/opengl/shader_compiler_opengl.cpp b/drivers/gles3/shader_compiler_gles3.cpp similarity index 97% rename from drivers/opengl/shader_compiler_opengl.cpp rename to drivers/gles3/shader_compiler_gles3.cpp index 9638626d785..fa607472d36 100644 --- a/drivers/opengl/shader_compiler_opengl.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* shader_compiler_opengl.cpp */ +/* shader_compiler_gles3.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "shader_compiler_opengl.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "shader_compiler_gles3.h" +#ifdef GLES3_BACKEND_ENABLED #include "core/config/project_settings.h" #include "core/os/os.h" @@ -206,7 +206,7 @@ static String get_constant_text(SL::DataType p_type, const Vector &p_func_code, StringBuilder &r_to_add, Set &r_added) { +void ShaderCompilerGLES3::_dump_function_deps(SL::ShaderNode *p_node, const StringName &p_for_func, const Map &p_func_code, StringBuilder &r_to_add, Set &r_added) { int fidx = -1; for (int i = 0; i < p_node->functions.size(); i++) { @@ -264,7 +264,7 @@ void ShaderCompilerOpenGL::_dump_function_deps(SL::ShaderNode *p_node, const Str } } -String ShaderCompilerOpenGL::_dump_node_code(SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_use_scope) { +String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_use_scope) { StringBuilder code; switch (p_node->type) { @@ -649,7 +649,7 @@ String ShaderCompilerOpenGL::_dump_node_code(SL::Node *p_node, int p_level, Gene if (op_node->arguments[1]->get_datatype() == SL::TYPE_SAMPLER2D) { // || // op_node->arguments[1]->get_datatype() == SL::TYPE_SAMPLEREXT) { - code += "texture2D"; + code += "texture"; } else if (op_node->arguments[1]->get_datatype() == SL::TYPE_SAMPLERCUBE) { code += "textureCube"; } @@ -658,7 +658,7 @@ String ShaderCompilerOpenGL::_dump_node_code(SL::Node *p_node, int p_level, Gene // emit texture call if (op_node->arguments[1]->get_datatype() == SL::TYPE_SAMPLER2D) { - code += "texture2DLod"; + code += "textureLod"; } else if (op_node->arguments[1]->get_datatype() == SL::TYPE_SAMPLERCUBE) { code += "textureCubeLod"; } @@ -842,13 +842,13 @@ String ShaderCompilerOpenGL::_dump_node_code(SL::Node *p_node, int p_level, Gene return code.as_string(); } -ShaderLanguage::DataType ShaderCompilerOpenGL::_get_variable_type(const StringName &p_type) { +ShaderLanguage::DataType ShaderCompilerGLES3::_get_variable_type(const StringName &p_type) { // RS::GlobalVariableType gvt = ((RasterizerStorageRD *)(RendererStorage::base_singleton))->global_variable_get_type_internal(p_type); RS::GlobalVariableType gvt = RS::GLOBAL_VAR_TYPE_MAX; return RS::global_variable_type_get_shader_datatype(gvt); } -Error ShaderCompilerOpenGL::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) { +Error ShaderCompilerGLES3::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) { ShaderLanguage::VaryingFunctionNames var_names; Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), var_names, ShaderTypes::get_singleton()->get_types(), _get_variable_type); @@ -860,7 +860,7 @@ Error ShaderCompilerOpenGL::compile(RS::ShaderMode p_mode, const String &p_code, print_line(itos(i + 1) + " " + shader[i]); } - _err_print_error(NULL, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER); + _err_print_error(NULL, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), false, ERR_HANDLER_SHADER); return err; } @@ -885,7 +885,7 @@ Error ShaderCompilerOpenGL::compile(RS::ShaderMode p_mode, const String &p_code, return OK; } -ShaderCompilerOpenGL::ShaderCompilerOpenGL() { +ShaderCompilerGLES3::ShaderCompilerGLES3() { /** CANVAS ITEM SHADER **/ actions[RS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy"; @@ -1117,4 +1117,4 @@ ShaderCompilerOpenGL::ShaderCompilerOpenGL() { } } -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED diff --git a/drivers/opengl/shader_compiler_opengl.h b/drivers/gles3/shader_compiler_gles3.h similarity index 94% rename from drivers/opengl/shader_compiler_opengl.h rename to drivers/gles3/shader_compiler_gles3.h index b57d28ffe55..f3efbe9fc3c 100644 --- a/drivers/opengl/shader_compiler_opengl.h +++ b/drivers/gles3/shader_compiler_gles3.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* shader_compiler_opengl.h */ +/* shader_compiler_gles3.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,8 +31,8 @@ #ifndef SHADER_COMPILER_OPENGL_H #define SHADER_COMPILER_OPENGL_H -#include "drivers/opengl/rasterizer_platforms.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "drivers/gles3/rasterizer_platforms.h" +#ifdef GLES3_BACKEND_ENABLED #include "core/string/string_builder.h" #include "core/templates/pair.h" @@ -40,7 +40,7 @@ #include "servers/rendering/shader_types.h" #include "servers/rendering_server.h" -class ShaderCompilerOpenGL { +class ShaderCompilerGLES3 { public: struct IdentifierActions { Map> render_mode_values; @@ -98,9 +98,9 @@ private: public: Error compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code); - ShaderCompilerOpenGL(); + ShaderCompilerGLES3(); }; -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED #endif // SHADER_COMPILER_OPENGL_H diff --git a/drivers/opengl/shader_opengl.cpp b/drivers/gles3/shader_gles3.cpp similarity index 94% rename from drivers/opengl/shader_opengl.cpp rename to drivers/gles3/shader_gles3.cpp index a80a745047f..7d93d50ceb0 100644 --- a/drivers/opengl/shader_opengl.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* shader_opengl.cpp */ +/* shader_gles3.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,12 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "shader_opengl.h" -#include "drivers/opengl/rasterizer_platforms.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "shader_gles3.h" +#include "drivers/gles3/rasterizer_platforms.h" +#ifdef GLES3_BACKEND_ENABLED -#include "rasterizer_opengl.h" -#include "rasterizer_storage_opengl.h" +#include "rasterizer_gles3.h" +#include "rasterizer_storage_gles3.h" #include "core/config/project_settings.h" #include "core/os/memory.h" @@ -59,7 +59,7 @@ #endif -ShaderOpenGL *ShaderOpenGL::active = NULL; +ShaderGLES3 *ShaderGLES3::active = NULL; //#define DEBUG_SHADER @@ -73,13 +73,13 @@ ShaderOpenGL *ShaderOpenGL::active = NULL; #endif -GLint ShaderOpenGL::get_uniform_location(int p_index) const { +GLint ShaderGLES3::get_uniform_location(int p_index) const { ERR_FAIL_COND_V(!version, -1); return version->uniform_location[p_index]; } -bool ShaderOpenGL::bind() { +bool ShaderGLES3::bind() { if (active != this || !version || new_conditional_version.key != conditional_version.key) { conditional_version = new_conditional_version; version = get_current_version(); @@ -104,7 +104,7 @@ bool ShaderOpenGL::bind() { return true; } -void ShaderOpenGL::unbind() { +void ShaderGLES3::unbind() { version = NULL; glUseProgram(0); uniforms_dirty = true; @@ -134,7 +134,7 @@ static String _mkid(const String &p_id) { return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl } -ShaderOpenGL::Version *ShaderOpenGL::get_current_version() { +ShaderGLES3::Version *ShaderGLES3::get_current_version() { if (!valid) return nullptr; @@ -172,32 +172,20 @@ ShaderOpenGL::Version *ShaderOpenGL::get_current_version() { Vector strings; #ifdef GLES_OVER_GL - strings.push_back("#version 120\n"); + strings.push_back("#version 330\n"); strings.push_back("#define USE_GLES_OVER_GL\n"); - - // test - strings.push_back("#define highp\n"); - //#ifdef USE_GLES_OVER_GL - //#define lowp - //#define mediump - //#define highp - //#else - // precision highp float; - // precision highp int; - //#endif - #else - strings.push_back("#version 100\n"); + strings.push_back("#version 300 es\n"); //angle does not like #ifdef JAVASCRIPT_ENABLED strings.push_back("#define USE_HIGHP_PRECISION\n"); #endif - if (GLOBAL_GET("rendering/opengl/compatibility/enable_high_float.Android")) { - // enable USE_HIGHP_PRECISION but safeguarded by an availability check as highp support is optional in OpenGL - // see Section 4.5.4 of the GLSL_ES_Specification_1.00 - strings.push_back("#ifdef GL_FRAGMENT_PRECISION_HIGH\n #define USE_HIGHP_PRECISION\n#endif\n"); - } + //if (GLOBAL_GET("rendering/opengl/compatibility/enable_high_float.Android")) { + // enable USE_HIGHP_PRECISION but safeguarded by an availability check as highp support is optional in OpenGL + // see Section 4.5.4 of the GLSL_ES_Specification_1.00 + //strings.push_back("#ifdef GL_FRAGMENT_PRECISION_HIGH\n #define USE_HIGHP_PRECISION\n#endif\n"); + //} #endif @@ -484,12 +472,12 @@ ShaderOpenGL::Version *ShaderOpenGL::get_current_version() { return &v; } -GLint ShaderOpenGL::get_uniform_location(const String &p_name) const { +GLint ShaderGLES3::get_uniform_location(const String &p_name) const { ERR_FAIL_COND_V(!version, -1); return glGetUniformLocation(version->id, p_name.ascii().get_data()); } -void ShaderOpenGL::setup( +void ShaderGLES3::setup( const char **p_conditional_defines, int p_conditional_count, const char **p_uniform_names, @@ -579,7 +567,7 @@ void ShaderOpenGL::setup( valid = true; } -void ShaderOpenGL::finish() { +void ShaderGLES3::finish() { const VersionKey *V = NULL; while ((V = version_map.next(V))) { @@ -593,7 +581,7 @@ void ShaderOpenGL::finish() { } } -void ShaderOpenGL::clear_caches() { +void ShaderGLES3::clear_caches() { const VersionKey *V = NULL; while ((V = version_map.next(V))) { @@ -612,13 +600,13 @@ void ShaderOpenGL::clear_caches() { uniforms_dirty = true; } -uint32_t ShaderOpenGL::create_custom_shader() { +uint32_t ShaderGLES3::create_custom_shader() { custom_code_map[last_custom_code] = CustomCode(); custom_code_map[last_custom_code].version = 1; return last_custom_code++; } -void ShaderOpenGL::set_custom_shader_code(uint32_t p_code_id, +void ShaderGLES3::set_custom_shader_code(uint32_t p_code_id, const String &p_vertex, const String &p_vertex_globals, const String &p_fragment, @@ -641,11 +629,11 @@ void ShaderOpenGL::set_custom_shader_code(uint32_t p_code_id, cc->version++; } -void ShaderOpenGL::set_custom_shader(uint32_t p_code_id) { +void ShaderGLES3::set_custom_shader(uint32_t p_code_id) { new_conditional_version.code_version = p_code_id; } -void ShaderOpenGL::free_custom_shader(uint32_t p_code_id) { +void ShaderGLES3::free_custom_shader(uint32_t p_code_id) { ERR_FAIL_COND(!custom_code_map.has(p_code_id)); if (conditional_version.code_version == p_code_id) { conditional_version.code_version = 0; //do not keep using a version that is going away @@ -671,8 +659,8 @@ void ShaderOpenGL::free_custom_shader(uint32_t p_code_id) { custom_code_map.erase(p_code_id); } -void ShaderOpenGL::use_material(void *p_material) { - RasterizerStorageOpenGL::Material *material = (RasterizerStorageOpenGL::Material *)p_material; +void ShaderGLES3::use_material(void *p_material) { + RasterizerStorageGLES3::Material *material = (RasterizerStorageGLES3::Material *)p_material; if (!material) { return; @@ -1115,14 +1103,14 @@ void ShaderOpenGL::use_material(void *p_material) { } } -ShaderOpenGL::ShaderOpenGL() { +ShaderGLES3::ShaderGLES3() { version = NULL; last_custom_code = 1; uniforms_dirty = true; } -ShaderOpenGL::~ShaderOpenGL() { +ShaderGLES3::~ShaderGLES3() { finish(); } -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED diff --git a/drivers/opengl/shader_opengl.h b/drivers/gles3/shader_gles3.h similarity index 93% rename from drivers/opengl/shader_opengl.h rename to drivers/gles3/shader_gles3.h index 4896bd6f2b1..1aca3a1cf62 100644 --- a/drivers/opengl/shader_opengl.h +++ b/drivers/gles3/shader_gles3.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* shader_opengl.h */ +/* shader_gles3.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,8 +31,8 @@ #ifndef SHADER_OPENGL_H #define SHADER_OPENGL_H -#include "drivers/opengl/rasterizer_platforms.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "drivers/gles3/rasterizer_platforms.h" +#ifdef GLES3_BACKEND_ENABLED // This must come first to avoid windows.h mess #include "platform_config.h" @@ -51,9 +51,9 @@ #include -class RasterizerStorageOpenGL; +class RasterizerStorageGLES3; -class ShaderOpenGL { +class ShaderGLES3 { protected: struct Enum { uint64_t mask; @@ -172,7 +172,7 @@ private: Version *get_current_version(); - static ShaderOpenGL *active; + static ShaderGLES3 *active; int max_image_units; @@ -195,7 +195,7 @@ protected: int p_vertex_code_start, int p_fragment_code_start); - ShaderOpenGL(); + ShaderGLES3(); public: enum { @@ -205,7 +205,7 @@ public: GLint get_uniform_location(const String &p_name) const; GLint get_uniform_location(int p_index) const; - static _FORCE_INLINE_ ShaderOpenGL *get_active() { return active; } + static _FORCE_INLINE_ ShaderGLES3 *get_active() { return active; } bool bind(); void unbind(); @@ -229,7 +229,7 @@ public: uint32_t get_version_key() const { return conditional_version.version; } - // this void* is actually a RasterizerStorageOpenGL::Material, but C++ doesn't + // this void* is actually a RasterizerStorageGLES3::Material, but C++ doesn't // like forward declared nested classes. void use_material(void *p_material); @@ -253,18 +253,18 @@ public: custom_defines.erase(p_define.utf8()); } - virtual ~ShaderOpenGL(); + virtual ~ShaderGLES3(); }; // called a lot, made inline -int ShaderOpenGL::_get_uniform(int p_which) const { +int ShaderGLES3::_get_uniform(int p_which) const { ERR_FAIL_INDEX_V(p_which, uniform_count, -1); ERR_FAIL_COND_V(!version, -1); return version->uniform_location[p_which]; } -void ShaderOpenGL::_set_conditional(int p_which, bool p_value) { +void ShaderGLES3::_set_conditional(int p_which, bool p_value) { ERR_FAIL_INDEX(p_which, conditional_count); if (p_value) new_conditional_version.version |= (1 << p_which); @@ -272,6 +272,6 @@ void ShaderOpenGL::_set_conditional(int p_which, bool p_value) { new_conditional_version.version &= ~(1 << p_which); } -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED #endif // SHADER_OPENGL_H diff --git a/drivers/gles3/shaders/SCsub b/drivers/gles3/shaders/SCsub new file mode 100644 index 00000000000..47d56b9947c --- /dev/null +++ b/drivers/gles3/shaders/SCsub @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +Import("env") + +if "GLES3_GLSL" in env["BUILDERS"]: + env.GLES3_GLSL("copy.glsl") + env.GLES3_GLSL("canvas.glsl") + env.GLES3_GLSL("canvas_shadow.glsl") + env.GLES3_GLSL("scene.glsl") + env.GLES3_GLSL("cubemap_filter.glsl") + env.GLES3_GLSL("cube_to_dp.glsl") + env.GLES3_GLSL("effect_blur.glsl") + env.GLES3_GLSL("tonemap.glsl") + env.GLES3_GLSL("lens_distorted.glsl") diff --git a/drivers/opengl/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl similarity index 86% rename from drivers/opengl/shaders/canvas.glsl rename to drivers/gles3/shaders/canvas.glsl index 3dee2faa888..f2b141252a0 100644 --- a/drivers/opengl/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -13,44 +13,42 @@ precision highp int; uniform highp mat4 projection_matrix; /* clang-format on */ -#include "stdlib.glsl" - uniform highp mat4 modelview_matrix; uniform highp mat4 extra_matrix; -attribute highp vec2 vertex; // attrib:0 +layout(location = 0) in highp vec2 vertex; #ifdef USE_ATTRIB_LIGHT_ANGLE // shared with tangent, not used in canvas shader -attribute highp float light_angle; // attrib:2 +layout(location = 2) in highp float light_angle; #endif -attribute vec4 color_attrib; // attrib:3 -attribute vec2 uv_attrib; // attrib:4 +layout(location = 3) in vec4 color_attrib; +layout(location = 4) in vec2 uv_attrib; #ifdef USE_ATTRIB_MODULATE -attribute highp vec4 modulate_attrib; // attrib:5 +layout(location = 5) in highp vec4 modulate_attrib; #endif #ifdef USE_ATTRIB_LARGE_VERTEX // shared with skeleton attributes, not used in batched shader -attribute highp vec2 translate_attrib; // attrib:6 -attribute highp vec4 basis_attrib; // attrib:7 +layout(location = 6) in highp vec2 translate_attrib; +layout(location = 7) in highp vec4 basis_attrib; #endif #ifdef USE_SKELETON -attribute highp vec4 bone_indices; // attrib:6 -attribute highp vec4 bone_weights; // attrib:7 +layout(location = 6) in highp vec4 bone_indices; +layout(location = 7) in highp vec4 bone_weights; #endif #ifdef USE_INSTANCING -attribute highp vec4 instance_xform0; //attrib:8 -attribute highp vec4 instance_xform1; //attrib:9 -attribute highp vec4 instance_xform2; //attrib:10 -attribute highp vec4 instance_color; //attrib:11 +layout(location = 8) in highp vec4 instance_xform0; +layout(location = 9) in highp vec4 instance_xform1; +layout(location = 10) in highp vec4 instance_xform2; +layout(location = 11) in highp vec4 instance_color; #ifdef USE_INSTANCE_CUSTOM -attribute highp vec4 instance_custom_data; //attrib:12 +layout(location = 12) in highp vec4 instance_custom_data; #endif #endif @@ -62,12 +60,12 @@ uniform highp mat4 skeleton_transform; uniform highp mat4 skeleton_transform_inverse; #endif -varying vec2 uv_interp; -varying vec4 color_interp; +out vec2 uv_interp; +out vec4 color_interp; #ifdef USE_ATTRIB_MODULATE // modulate doesn't need interpolating but we need to send it to the fragment shader -varying vec4 modulate_interp; +flat out vec4 modulate_interp; #endif #ifdef MODULATE_USED @@ -101,12 +99,12 @@ uniform highp float light_height; uniform highp float light_outside_alpha; uniform highp float shadow_distance_mult; -varying vec4 light_uv_interp; -varying vec2 transformed_light_uv; -varying vec4 local_rot; +out vec4 light_uv_interp; +out vec2 transformed_light_uv; +out vec4 local_rot; #ifdef USE_SHADOWS -varying highp vec2 pos; +out highp vec2 pos; #endif const bool at_light_pass = true; @@ -295,25 +293,6 @@ VERTEX_SHADER_CODE /* clang-format off */ [fragment] -// texture2DLodEXT and textureCubeLodEXT are fragment shader specific. -// Do not copy these defines in the vertex section. -#ifndef USE_GLES_OVER_GL -#ifdef GL_EXT_shader_texture_lod -#extension GL_EXT_shader_texture_lod : enable -#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod) -#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod) -#endif -#endif // !USE_GLES_OVER_GL - -#ifdef GL_ARB_shader_texture_lod -#extension GL_ARB_shader_texture_lod : enable -#endif - -#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod) -#define texture2DLod(img, coord, lod) texture2D(img, coord, lod) -#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod) -#endif - #ifdef USE_GLES_OVER_GL #define lowp #define mediump @@ -328,18 +307,16 @@ precision mediump int; #endif #endif -#include "stdlib.glsl" - uniform sampler2D color_texture; // texunit:-1 /* clang-format on */ uniform highp vec2 color_texpixel_size; uniform mediump sampler2D normal_texture; // texunit:-2 -varying mediump vec2 uv_interp; -varying mediump vec4 color_interp; +in mediump vec2 uv_interp; +in mediump vec4 color_interp; #ifdef USE_ATTRIB_MODULATE -varying mediump vec4 modulate_interp; +in mediump vec4 modulate_interp; #endif uniform highp float time; @@ -373,15 +350,15 @@ uniform highp float light_outside_alpha; uniform highp float shadow_distance_mult; uniform lowp sampler2D light_texture; // texunit:-6 -varying vec4 light_uv_interp; -varying vec2 transformed_light_uv; +in vec4 light_uv_interp; +in vec2 transformed_light_uv; -varying vec4 local_rot; +in vec4 local_rot; #ifdef USE_SHADOWS uniform highp sampler2D shadow_texture; // texunit:-5 -varying highp vec2 pos; +in highp vec2 pos; #endif @@ -392,6 +369,8 @@ const bool at_light_pass = false; uniform bool use_default_normal; +layout(location = 0) out mediump vec4 frag_color; + /* clang-format off */ FRAGMENT_SHADER_GLOBALS @@ -434,7 +413,7 @@ void main() { #if !defined(COLOR_USED) //default behavior, texture by color - color *= texture2D(color_texture, uv); + color *= texture(color_texture, uv); #endif #ifdef SCREEN_UV_USED @@ -451,7 +430,7 @@ void main() { #endif if (use_default_normal) { - normal.xy = texture2D(normal_texture, uv).xy * 2.0 - 1.0; + normal.xy = texture(normal_texture, uv).xy * 2.0 - 1.0; normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); normal_used = true; } else { @@ -497,7 +476,7 @@ FRAGMENT_SHADER_CODE float att = 1.0; vec2 light_uv = light_uv_interp.xy; - vec4 light = texture2D(light_texture, light_uv); + vec4 light = texture(light_texture, light_uv); if (any(lessThan(light_uv_interp.xy, vec2(0.0, 0.0))) || any(greaterThanEqual(light_uv_interp.xy, vec2(1.0, 1.0)))) { color.a *= light_outside_alpha; //invisible @@ -579,11 +558,11 @@ FRAGMENT_SHADER_CODE highp float shadow_attenuation = 0.0; #ifdef USE_RGBA_SHADOWS -#define SHADOW_DEPTH(m_tex, m_uv) dot(texture2D((m_tex), (m_uv)), vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0)) +#define SHADOW_DEPTH(m_tex, m_uv) dot(texture((m_tex), (m_uv)), vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0)) #else -#define SHADOW_DEPTH(m_tex, m_uv) (texture2D((m_tex), (m_uv)).r) +#define SHADOW_DEPTH(m_tex, m_uv) (texture((m_tex), (m_uv)).r) #endif @@ -682,5 +661,5 @@ FRAGMENT_SHADER_CODE //use lighting #endif - gl_FragColor = color; + frag_color = color; } diff --git a/drivers/opengl/shaders/canvas_shadow.glsl b/drivers/gles3/shaders/canvas_shadow.glsl similarity index 86% rename from drivers/opengl/shaders/canvas_shadow.glsl rename to drivers/gles3/shaders/canvas_shadow.glsl index 2abcd5e67c5..2b3be43f6ea 100644 --- a/drivers/opengl/shaders/canvas_shadow.glsl +++ b/drivers/gles3/shaders/canvas_shadow.glsl @@ -10,7 +10,7 @@ precision highp float; precision highp int; #endif -attribute highp vec3 vertex; // attrib:0 +layout(location = 0) highp vec3 vertex; uniform highp mat4 projection_matrix; /* clang-format on */ @@ -18,7 +18,7 @@ uniform highp mat4 light_matrix; uniform highp mat4 world_matrix; uniform highp float distance_norm; -varying highp vec4 position_interp; +out highp vec4 position_interp; void main() { gl_Position = projection_matrix * (light_matrix * (world_matrix * vec4(vertex, 1.0))); @@ -42,7 +42,7 @@ precision mediump int; #endif #endif -varying highp vec4 position_interp; +in highp vec4 position_interp; /* clang-format on */ void main() { @@ -52,9 +52,9 @@ void main() { highp vec4 comp = fract(depth * vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0)); comp -= comp.xxyz * vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0); - gl_FragColor = comp; + frag_color = comp; #else - gl_FragColor = vec4(depth); + frag_color = vec4(depth); #endif } diff --git a/drivers/opengl/shaders/copy.glsl b/drivers/gles3/shaders/copy.glsl similarity index 88% rename from drivers/opengl/shaders/copy.glsl rename to drivers/gles3/shaders/copy.glsl index e833722ac3d..598c6fd614e 100644 --- a/drivers/opengl/shaders/copy.glsl +++ b/drivers/gles3/shaders/copy.glsl @@ -10,23 +10,23 @@ precision highp float; precision highp int; #endif -attribute highp vec4 vertex_attrib; // attrib:0 +layout(location = 0) highp vec4 vertex_attrib; /* clang-format on */ #if defined(USE_CUBEMAP) || defined(USE_PANORAMA) -attribute vec3 cube_in; // attrib:4 +layout(location = 4) vec3 cube_in; #else -attribute vec2 uv_in; // attrib:4 +layout(location = 4) vec2 uv_in; #endif -attribute vec2 uv2_in; // attrib:5 +layout(location = 5) vec2 uv2_in; #if defined(USE_CUBEMAP) || defined(USE_PANORAMA) -varying vec3 cube_interp; +out vec3 cube_interp; #else -varying vec2 uv_interp; +out vec2 uv_interp; #endif -varying vec2 uv2_interp; +out vec2 uv2_interp; // These definitions are here because the shader-wrapper builder does // not understand `#elif defined()` @@ -79,9 +79,9 @@ precision mediump int; #endif #if defined(USE_CUBEMAP) || defined(USE_PANORAMA) -varying vec3 cube_interp; +in vec3 cube_interp; #else -varying vec2 uv_interp; +in vec2 uv_interp; #endif /* clang-format on */ @@ -100,7 +100,7 @@ uniform sampler2D source; // texunit:0 uniform sampler2D CbCr; //texunit:1 #endif -varying vec2 uv2_interp; +in vec2 uv2_interp; #ifdef USE_MULTIPLIER uniform float multiplier; @@ -123,11 +123,13 @@ vec4 texturePanorama(sampler2D pano, vec3 normal) { st /= vec2(M_PI * 2.0, M_PI); - return texture2D(pano, st); + return texture(pano, st); } #endif +layout(location = 0) out vec4 frag_color; + void main() { #ifdef USE_PANORAMA @@ -157,11 +159,11 @@ void main() { vec4 color = textureCube(source_cube, normalize(cube_interp)); #elif defined(SEP_CBCR_TEXTURE) vec4 color; - color.r = texture2D(source, uv_interp).r; - color.gb = texture2D(CbCr, uv_interp).rg - vec2(0.5, 0.5); + color.r = texture(source, uv_interp).r; + color.gb = texture(CbCr, uv_interp).rg - vec2(0.5, 0.5); color.a = 1.0; #else - vec4 color = texture2D(source, uv_interp); + vec4 color = texture(source, uv_interp); #endif #ifdef YCBCR_TO_RGB @@ -172,7 +174,7 @@ void main() { vec3(1.00000, 1.00000, 1.00000), vec3(0.00000, -0.34413, 1.77200), vec3(1.40200, -0.71414, 0.00000)) * - color.rgb; + color.rgb; #endif #ifdef USE_NO_ALPHA @@ -187,5 +189,5 @@ void main() { color.rgb *= multiplier; #endif - gl_FragColor = color; + frag_color = color; } diff --git a/drivers/opengl/shaders/cube_to_dp.glsl b/drivers/gles3/shaders/cube_to_dp.glsl similarity index 94% rename from drivers/opengl/shaders/cube_to_dp.glsl rename to drivers/gles3/shaders/cube_to_dp.glsl index 1612ec3d5a6..ea4df79d4e4 100644 --- a/drivers/opengl/shaders/cube_to_dp.glsl +++ b/drivers/gles3/shaders/cube_to_dp.glsl @@ -10,11 +10,11 @@ precision mediump float; precision mediump int; #endif -attribute highp vec4 vertex_attrib; // attrib:0 +layout(location = 0) highp vec4 vertex_attrib; /* clang-format on */ -attribute vec2 uv_in; // attrib:4 +layout(location = 4) vec2 uv_in; -varying vec2 uv_interp; +out vec2 uv_interp; void main() { uv_interp = uv_in; @@ -40,7 +40,7 @@ precision mediump int; uniform highp samplerCube source_cube; //texunit:0 /* clang-format on */ -varying vec2 uv_interp; +in vec2 uv_interp; uniform bool z_flip; uniform highp float z_far; diff --git a/drivers/opengl/shaders/cubemap_filter.glsl b/drivers/gles3/shaders/cubemap_filter.glsl similarity index 79% rename from drivers/opengl/shaders/cubemap_filter.glsl rename to drivers/gles3/shaders/cubemap_filter.glsl index f5c91cc7072..04bf3ebf02e 100644 --- a/drivers/opengl/shaders/cubemap_filter.glsl +++ b/drivers/gles3/shaders/cubemap_filter.glsl @@ -10,11 +10,11 @@ precision highp float; precision highp int; #endif -attribute highp vec2 vertex; // attrib:0 +layout(location = 0) highp vec2 vertex; /* clang-format on */ -attribute highp vec2 uv; // attrib:4 +layout(location = 4) highp vec2 uv; -varying highp vec2 uv_interp; +out highp vec2 uv_interp; void main() { uv_interp = uv; @@ -24,25 +24,6 @@ void main() { /* clang-format off */ [fragment] -// texture2DLodEXT and textureCubeLodEXT are fragment shader specific. -// Do not copy these defines in the vertex section. -#ifndef USE_GLES_OVER_GL -#ifdef GL_EXT_shader_texture_lod -#extension GL_EXT_shader_texture_lod : enable -#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod) -#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod) -#endif -#endif // !USE_GLES_OVER_GL - -#ifdef GL_ARB_shader_texture_lod -#extension GL_ARB_shader_texture_lod : enable -#endif - -#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod) -#define texture2DLod(img, coord, lod) texture2D(img, coord, lod) -#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod) -#endif - #ifdef USE_GLES_OVER_GL #define lowp #define mediump @@ -67,7 +48,7 @@ uniform samplerCube source_cube; //texunit:0 uniform int face_id; uniform float roughness; -varying highp vec2 uv_interp; +in highp vec2 uv_interp; uniform sampler2D radical_inverse_vdc_cache; // texunit:1 @@ -95,7 +76,7 @@ vec4 texturePanorama(sampler2D pano, vec3 normal) { st /= vec2(M_PI * 2.0, M_PI); - return texture2DLod(pano, st, 0.0); + return textureLod(pano, st, 0.0); } #endif @@ -167,7 +148,7 @@ vec3 ImportanceSampleGGX(vec2 Xi, float Roughness, vec3 N) { } float radical_inverse_VdC(int i) { - return texture2D(radical_inverse_vdc_cache, vec2(float(i) / 512.0, 0.0)).x; + return texture(radical_inverse_vdc_cache, vec2(float(i) / 512.0, 0.0)).x; } vec2 Hammersley(int i, int N) { @@ -176,6 +157,8 @@ vec2 Hammersley(int i, int N) { uniform bool z_flip; +layout(location = 0) out vec4 frag_color; + void main() { vec3 color = vec3(0.0); @@ -186,10 +169,10 @@ void main() { #ifdef USE_SOURCE_PANORAMA - gl_FragColor = vec4(texturePanorama(source_panorama, N).rgb, 1.0); + frag_color = vec4(texturePanorama(source_panorama, N).rgb, 1.0); #else - gl_FragColor = vec4(textureCube(source_cube, N).rgb, 1.0); + frag_color = vec4(textureCube(source_cube, N).rgb, 1.0); #endif //USE_SOURCE_PANORAMA #else @@ -226,6 +209,6 @@ void main() { vec3 a = vec3(0.055); sum.rgb = mix((vec3(1.0) + a) * pow(sum.rgb, vec3(1.0 / 2.4)) - a, 12.92 * sum.rgb, vec3(lessThan(sum.rgb, vec3(0.0031308)))); - gl_FragColor = vec4(sum.rgb, 1.0); + frag_color = vec4(sum.rgb, 1.0); #endif } diff --git a/drivers/opengl/shaders/effect_blur.glsl b/drivers/gles3/shaders/effect_blur.glsl similarity index 71% rename from drivers/opengl/shaders/effect_blur.glsl rename to drivers/gles3/shaders/effect_blur.glsl index 7b607dd76a0..80063a71750 100644 --- a/drivers/opengl/shaders/effect_blur.glsl +++ b/drivers/gles3/shaders/effect_blur.glsl @@ -10,11 +10,11 @@ precision highp float; precision highp int; #endif -attribute vec2 vertex_attrib; // attrib:0 +layout(location = 0) vec2 vertex_attrib; /* clang-format on */ -attribute vec2 uv_in; // attrib:4 +layout(location = 4) vec2 uv_in; -varying vec2 uv_interp; +out vec2 uv_interp; #ifdef USE_BLUR_SECTION @@ -35,25 +35,6 @@ void main() { /* clang-format off */ [fragment] -// texture2DLodEXT and textureCubeLodEXT are fragment shader specific. -// Do not copy these defines in the vertex section. -#ifndef USE_GLES_OVER_GL -#ifdef GL_EXT_shader_texture_lod -#extension GL_EXT_shader_texture_lod : enable -#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod) -#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod) -#endif -#endif // !USE_GLES_OVER_GL - -#ifdef GL_ARB_shader_texture_lod -#extension GL_ARB_shader_texture_lod : enable -#endif - -#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod) -#define texture2DLod(img, coord, lod) texture2D(img, coord, lod) -#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod) -#endif - #ifdef USE_GLES_OVER_GL #define lowp #define mediump @@ -68,7 +49,7 @@ precision mediump int; #endif #endif -varying vec2 uv_interp; +in vec2 uv_interp; /* clang-format on */ uniform sampler2D source_color; //texunit:0 @@ -125,29 +106,31 @@ uniform float glow_hdr_scale; uniform float camera_z_far; uniform float camera_z_near; +layout(location = 0) out vec4 frag_color; + void main() { #ifdef GLOW_GAUSSIAN_HORIZONTAL vec2 pix_size = pixel_size; pix_size *= 0.5; //reading from larger buffer, so use more samples - vec4 color = texture2DLod(source_color, uv_interp + vec2(0.0, 0.0) * pix_size, lod) * 0.174938; - color += texture2DLod(source_color, uv_interp + vec2(1.0, 0.0) * pix_size, lod) * 0.165569; - color += texture2DLod(source_color, uv_interp + vec2(2.0, 0.0) * pix_size, lod) * 0.140367; - color += texture2DLod(source_color, uv_interp + vec2(3.0, 0.0) * pix_size, lod) * 0.106595; - color += texture2DLod(source_color, uv_interp + vec2(-1.0, 0.0) * pix_size, lod) * 0.165569; - color += texture2DLod(source_color, uv_interp + vec2(-2.0, 0.0) * pix_size, lod) * 0.140367; - color += texture2DLod(source_color, uv_interp + vec2(-3.0, 0.0) * pix_size, lod) * 0.106595; + vec4 color = textureLod(source_color, uv_interp + vec2(0.0, 0.0) * pix_size, lod) * 0.174938; + color += textureLod(source_color, uv_interp + vec2(1.0, 0.0) * pix_size, lod) * 0.165569; + color += textureLod(source_color, uv_interp + vec2(2.0, 0.0) * pix_size, lod) * 0.140367; + color += textureLod(source_color, uv_interp + vec2(3.0, 0.0) * pix_size, lod) * 0.106595; + color += textureLod(source_color, uv_interp + vec2(-1.0, 0.0) * pix_size, lod) * 0.165569; + color += textureLod(source_color, uv_interp + vec2(-2.0, 0.0) * pix_size, lod) * 0.140367; + color += textureLod(source_color, uv_interp + vec2(-3.0, 0.0) * pix_size, lod) * 0.106595; color *= glow_strength; - gl_FragColor = color; + frag_color = color; #endif #ifdef GLOW_GAUSSIAN_VERTICAL - vec4 color = texture2DLod(source_color, uv_interp + vec2(0.0, 0.0) * pixel_size, lod) * 0.288713; - color += texture2DLod(source_color, uv_interp + vec2(0.0, 1.0) * pixel_size, lod) * 0.233062; - color += texture2DLod(source_color, uv_interp + vec2(0.0, 2.0) * pixel_size, lod) * 0.122581; - color += texture2DLod(source_color, uv_interp + vec2(0.0, -1.0) * pixel_size, lod) * 0.233062; - color += texture2DLod(source_color, uv_interp + vec2(0.0, -2.0) * pixel_size, lod) * 0.122581; + vec4 color = textureLod(source_color, uv_interp + vec2(0.0, 0.0) * pixel_size, lod) * 0.288713; + color += textureLod(source_color, uv_interp + vec2(0.0, 1.0) * pixel_size, lod) * 0.233062; + color += textureLod(source_color, uv_interp + vec2(0.0, 2.0) * pixel_size, lod) * 0.122581; + color += textureLod(source_color, uv_interp + vec2(0.0, -1.0) * pixel_size, lod) * 0.233062; + color += textureLod(source_color, uv_interp + vec2(0.0, -2.0) * pixel_size, lod) * 0.122581; color *= glow_strength; - gl_FragColor = color; + frag_color = color; #endif #ifndef USE_GLES_OVER_GL @@ -214,7 +197,7 @@ void main() { vec4 color_accum = vec4(0.0); - float depth = texture2DLod(dof_source_depth, uv_interp, 0.0).r; + float depth = textureLod(dof_source_depth, uv_interp, 0.0).r; depth = depth * 2.0 - 1.0; #ifdef USE_ORTHOGONAL_PROJECTION depth = ((depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0; @@ -231,7 +214,7 @@ void main() { float tap_k = dof_kernel[i]; - float tap_depth = texture2D(dof_source_depth, tap_uv, 0.0).r; + float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r; tap_depth = tap_depth * 2.0 - 1.0; #ifdef USE_ORTHOGONAL_PROJECTION tap_depth = ((tap_depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0; @@ -241,7 +224,7 @@ void main() { float tap_amount = int_ofs == 0 ? 1.0 : smoothstep(dof_begin, dof_end, tap_depth); tap_amount *= tap_amount * tap_amount; //prevent undesired glow effect - vec4 tap_color = texture2DLod(source_color, tap_uv, 0.0) * tap_k; + vec4 tap_color = textureLod(source_color, tap_uv, 0.0) * tap_k; k_accum += tap_k * tap_amount; color_accum += tap_color * tap_amount; @@ -251,7 +234,7 @@ void main() { color_accum /= k_accum; } - gl_FragColor = color_accum; ///k_accum; + frag_color = color_accum; ///k_accum; #endif @@ -268,9 +251,9 @@ void main() { float tap_k = dof_kernel[i]; - vec4 tap_color = texture2DLod(source_color, tap_uv, 0.0); + vec4 tap_color = textureLod(source_color, tap_uv, 0.0); - float tap_depth = texture2D(dof_source_depth, tap_uv, 0.0).r; + float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r; tap_depth = tap_depth * 2.0 - 1.0; #ifdef USE_ORTHOGONAL_PROJECTION tap_depth = ((tap_depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0; @@ -293,16 +276,16 @@ void main() { color_accum.a = max(color_accum.a, sqrt(max_accum)); - gl_FragColor = color_accum; + frag_color = color_accum; #endif #ifdef GLOW_FIRST_PASS - float luminance = max(gl_FragColor.r, max(gl_FragColor.g, gl_FragColor.b)); + float luminance = max(frag_color.r, max(frag_color.g, frag_color.b)); float feedback = max(smoothstep(glow_hdr_threshold, glow_hdr_threshold + glow_hdr_scale, luminance), glow_bloom); - gl_FragColor = min(gl_FragColor * feedback, vec4(luminance_cap)); + frag_color = min(frag_color * feedback, vec4(luminance_cap)); #endif } diff --git a/drivers/opengl/shaders/lens_distorted.glsl b/drivers/gles3/shaders/lens_distorted.glsl similarity index 87% rename from drivers/opengl/shaders/lens_distorted.glsl rename to drivers/gles3/shaders/lens_distorted.glsl index d568006cccf..64c2d70cc87 100644 --- a/drivers/opengl/shaders/lens_distorted.glsl +++ b/drivers/gles3/shaders/lens_distorted.glsl @@ -10,13 +10,13 @@ precision highp float; precision highp int; #endif -attribute highp vec2 vertex; // attrib:0 +layout(location = 0) highp vec2 vertex; /* clang-format on */ uniform vec2 offset; uniform vec2 scale; -varying vec2 uv_interp; +out vec2 uv_interp; void main() { uv_interp = vertex.xy * 2.0 - 1.0; @@ -51,7 +51,9 @@ uniform float k2; uniform float upscale; uniform float aspect_ratio; -varying vec2 uv_interp; +in vec2 uv_interp; + +layout(location = 0) out vec4 frag_color; void main() { vec2 coords = uv_interp; @@ -76,9 +78,9 @@ void main() { // and check our color if (coords.x < -1.0 || coords.y < -1.0 || coords.x > 1.0 || coords.y > 1.0) { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + frag_color = vec4(0.0, 0.0, 0.0, 1.0); } else { coords = (coords + vec2(1.0)) / vec2(2.0); - gl_FragColor = texture2D(source, coords); + frag_color = texture(source, coords); } } diff --git a/drivers/opengl/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl similarity index 93% rename from drivers/opengl/shaders/scene.glsl rename to drivers/gles3/shaders/scene.glsl index ba3a81a5328..de2aa0fc48b 100644 --- a/drivers/opengl/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -10,11 +10,7 @@ precision highp float; precision highp int; #endif -/* clang-format on */ -#include "stdlib.glsl" -/* clang-format off */ - -#define SHADER_IS_SRGB true +#define SHADER_IS_SRGB true //TODO remove #define M_PI 3.14159265359 @@ -22,38 +18,38 @@ precision highp int; // attributes // -attribute highp vec4 vertex_attrib; // attrib:0 +layout(location = 0) highp vec4 vertex_attrib; /* clang-format on */ -attribute vec3 normal_attrib; // attrib:1 +layout(location = 1) vec3 normal_attrib; #if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) -attribute vec4 tangent_attrib; // attrib:2 +layout(location = 2) vec4 tangent_attrib; #endif #if defined(ENABLE_COLOR_INTERP) -attribute vec4 color_attrib; // attrib:3 +layout(location = 3) vec4 color_attrib; #endif #if defined(ENABLE_UV_INTERP) -attribute vec2 uv_attrib; // attrib:4 +layout(location = 4) vec2 uv_attrib; #endif #if defined(ENABLE_UV2_INTERP) || defined(USE_LIGHTMAP) -attribute vec2 uv2_attrib; // attrib:5 +layout(location = 5) vec2 uv2_attrib; #endif #ifdef USE_SKELETON #ifdef USE_SKELETON_SOFTWARE -attribute highp vec4 bone_transform_row_0; // attrib:13 -attribute highp vec4 bone_transform_row_1; // attrib:14 -attribute highp vec4 bone_transform_row_2; // attrib:15 +layout(location = 13) highp vec4 bone_transform_row_0; +layout(location = 14) highp vec4 bone_transform_row_1; +layout(location = 15) highp vec4 bone_transform_row_2; #else -attribute vec4 bone_ids; // attrib:6 -attribute highp vec4 bone_weights; // attrib:7 +layout(location = 6) vec4 bone_ids; +layout(location = 7) highp vec4 bone_weights; uniform highp sampler2D bone_transforms; // texunit:-1 uniform ivec2 skeleton_texture_size; @@ -64,12 +60,12 @@ uniform ivec2 skeleton_texture_size; #ifdef USE_INSTANCING -attribute highp vec4 instance_xform_row_0; // attrib:8 -attribute highp vec4 instance_xform_row_1; // attrib:9 -attribute highp vec4 instance_xform_row_2; // attrib:10 +layout(location = 8) highp vec4 instance_xform_row_0; +layout(location = 9) highp vec4 instance_xform_row_1; +layout(location = 10) highp vec4 instance_xform_row_2; -attribute highp vec4 instance_color; // attrib:11 -attribute highp vec4 instance_custom_data; // attrib:12 +layout(location = 11) highp vec4 instance_color; +layout(location = 12) highp vec4 instance_custom_data; #endif @@ -98,27 +94,27 @@ uniform float light_normal_bias; // #if defined(RENDER_DEPTH) && defined(USE_RGBA_SHADOWS) -varying highp vec4 position_interp; +out highp vec4 position_interp; #endif -varying highp vec3 vertex_interp; -varying vec3 normal_interp; +out highp vec3 vertex_interp; +out vec3 normal_interp; #if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) -varying vec3 tangent_interp; -varying vec3 binormal_interp; +out vec3 tangent_interp; +out vec3 binormal_interp; #endif #if defined(ENABLE_COLOR_INTERP) -varying vec4 color_interp; +out vec4 color_interp; #endif #if defined(ENABLE_UV_INTERP) -varying vec2 uv_interp; +out vec2 uv_interp; #endif #if defined(ENABLE_UV2_INTERP) || defined(USE_LIGHTMAP) -varying vec2 uv2_interp; +out vec2 uv2_interp; #endif /* clang-format off */ @@ -129,7 +125,7 @@ VERTEX_SHADER_GLOBALS #ifdef RENDER_DEPTH_DUAL_PARABOLOID -varying highp float dp_clip; +out highp float dp_clip; uniform highp float shadow_dual_paraboloid_render_zfar; uniform highp float shadow_dual_paraboloid_render_side; @@ -138,19 +134,19 @@ uniform highp float shadow_dual_paraboloid_render_side; #if defined(USE_SHADOW) && defined(USE_LIGHTING) uniform highp mat4 light_shadow_matrix; -varying highp vec4 shadow_coord; +out highp vec4 shadow_coord; #if defined(LIGHT_USE_PSSM2) || defined(LIGHT_USE_PSSM4) uniform highp mat4 light_shadow_matrix2; -varying highp vec4 shadow_coord2; +out highp vec4 shadow_coord2; #endif #if defined(LIGHT_USE_PSSM4) uniform highp mat4 light_shadow_matrix3; uniform highp mat4 light_shadow_matrix4; -varying highp vec4 shadow_coord3; -varying highp vec4 shadow_coord4; +out highp vec4 shadow_coord3; +out highp vec4 shadow_coord4; #endif @@ -158,8 +154,8 @@ varying highp vec4 shadow_coord4; #if defined(USE_VERTEX_LIGHTING) && defined(USE_LIGHTING) -varying highp vec3 diffuse_interp; -varying highp vec3 specular_interp; +out highp vec3 diffuse_interp; +out highp vec3 specular_interp; // general for all lights uniform highp vec4 light_color; @@ -266,11 +262,11 @@ void light_compute( #ifdef USE_REFLECTION_PROBE1 uniform highp mat4 refprobe1_local_matrix; -varying mediump vec4 refprobe1_reflection_normal_blend; +out mediump vec4 refprobe1_reflection_normal_blend; uniform highp vec3 refprobe1_box_extents; #ifndef USE_LIGHTMAP -varying mediump vec3 refprobe1_ambient_normal; +out mediump vec3 refprobe1_ambient_normal; #endif #endif //reflection probe1 @@ -278,11 +274,11 @@ varying mediump vec3 refprobe1_ambient_normal; #ifdef USE_REFLECTION_PROBE2 uniform highp mat4 refprobe2_local_matrix; -varying mediump vec4 refprobe2_reflection_normal_blend; +out mediump vec4 refprobe2_reflection_normal_blend; uniform highp vec3 refprobe2_box_extents; #ifndef USE_LIGHTMAP -varying mediump vec3 refprobe2_ambient_normal; +out mediump vec3 refprobe2_ambient_normal; #endif #endif //reflection probe2 @@ -291,7 +287,7 @@ varying mediump vec3 refprobe2_ambient_normal; #if defined(FOG_DEPTH_ENABLED) || defined(FOG_HEIGHT_ENABLED) -varying vec4 fog_interp; +out vec4 fog_interp; uniform mediump vec4 fog_color_base; #ifdef LIGHT_MODE_DIRECTIONAL @@ -663,25 +659,6 @@ VERTEX_SHADER_CODE /* clang-format off */ [fragment] -// texture2DLodEXT and textureCubeLodEXT are fragment shader specific. -// Do not copy these defines in the vertex section. -#ifndef USE_GLES_OVER_GL -#ifdef GL_EXT_shader_texture_lod -#extension GL_EXT_shader_texture_lod : enable -#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod) -#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod) -#endif -#endif // !USE_GLES_OVER_GL - -#ifdef GL_ARB_shader_texture_lod -#extension GL_ARB_shader_texture_lod : enable -#endif - -#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod) -#define texture2DLod(img, coord, lod) texture2D(img, coord, lod) -#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod) -#endif - #ifdef USE_GLES_OVER_GL #define lowp #define mediump @@ -696,8 +673,6 @@ precision mediump int; #endif #endif -#include "stdlib.glsl" - #define M_PI 3.14159265359 #define SHADER_IS_SRGB true @@ -732,9 +707,9 @@ uniform highp sampler2D depth_texture; //texunit:-4 #ifdef USE_VERTEX_LIGHTING -varying mediump vec4 refprobe1_reflection_normal_blend; +in mediump vec4 refprobe1_reflection_normal_blend; #ifndef USE_LIGHTMAP -varying mediump vec3 refprobe1_ambient_normal; +in mediump vec3 refprobe1_ambient_normal; #endif #else @@ -759,9 +734,9 @@ uniform vec4 refprobe1_ambient; #ifdef USE_VERTEX_LIGHTING -varying mediump vec4 refprobe2_reflection_normal_blend; +in mediump vec4 refprobe2_reflection_normal_blend; #ifndef USE_LIGHTMAP -varying mediump vec3 refprobe2_ambient_normal; +in mediump vec3 refprobe2_ambient_normal; #endif #else @@ -909,8 +884,8 @@ uniform highp vec4 shadow_color; #ifdef USE_VERTEX_LIGHTING //get from vertex -varying highp vec3 diffuse_interp; -varying highp vec3 specular_interp; +in highp vec3 diffuse_interp; +in highp vec3 specular_interp; uniform highp vec3 light_direction; //may be used by fog, so leave here @@ -950,16 +925,16 @@ uniform highp sampler2D light_directional_shadow; // texunit:-3 uniform highp vec4 light_split_offsets; #endif -varying highp vec4 shadow_coord; +in highp vec4 shadow_coord; #if defined(LIGHT_USE_PSSM2) || defined(LIGHT_USE_PSSM4) -varying highp vec4 shadow_coord2; +in highp vec4 shadow_coord2; #endif #if defined(LIGHT_USE_PSSM4) -varying highp vec4 shadow_coord3; -varying highp vec4 shadow_coord4; +in highp vec4 shadow_coord3; +in highp vec4 shadow_coord4; #endif @@ -976,30 +951,32 @@ uniform vec4 light_clamp; // #if defined(RENDER_DEPTH) && defined(USE_RGBA_SHADOWS) -varying highp vec4 position_interp; +in highp vec4 position_interp; #endif -varying highp vec3 vertex_interp; -varying vec3 normal_interp; +in highp vec3 vertex_interp; +in vec3 normal_interp; #if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) -varying vec3 tangent_interp; -varying vec3 binormal_interp; +in vec3 tangent_interp; +in vec3 binormal_interp; #endif #if defined(ENABLE_COLOR_INTERP) -varying vec4 color_interp; +in vec4 color_interp; #endif #if defined(ENABLE_UV_INTERP) -varying vec2 uv_interp; +in vec2 uv_interp; #endif #if defined(ENABLE_UV2_INTERP) || defined(USE_LIGHTMAP) -varying vec2 uv2_interp; +in vec2 uv2_interp; #endif -varying vec3 view_interp; +in vec3 view_interp; + +layout(location = 0) out vec4 frag_color; vec3 F0(float metallic, float specular, vec3 albedo) { float dielectric = 0.16 * specular * specular; @@ -1016,7 +993,7 @@ FRAGMENT_SHADER_GLOBALS #ifdef RENDER_DEPTH_DUAL_PARABOLOID -varying highp float dp_clip; +in highp float dp_clip; #endif @@ -1354,8 +1331,8 @@ LIGHT_SHADER_CODE #endif -#define SAMPLE_SHADOW_TEXEL(p_shadow, p_pos, p_depth) step(p_depth, SHADOW_DEPTH(texture2D(p_shadow, p_pos))) -#define SAMPLE_SHADOW_TEXEL_PROJ(p_shadow, p_pos) step(p_pos.z, SHADOW_DEPTH(texture2DProj(p_shadow, p_pos))) +#define SAMPLE_SHADOW_TEXEL(p_shadow, p_pos, p_depth) step(p_depth, SHADOW_DEPTH(texture(p_shadow, p_pos))) +#define SAMPLE_SHADOW_TEXEL_PROJ(p_shadow, p_pos) step(p_pos.z, SHADOW_DEPTH(textureProj(p_shadow, p_pos))) float sample_shadow(highp sampler2D shadow, highp vec4 spos) { #ifdef SHADOW_MODE_PCF_13 @@ -1407,7 +1384,7 @@ float sample_shadow(highp sampler2D shadow, highp vec4 spos) { #if defined(USE_VERTEX_LIGHTING) -varying vec4 fog_interp; +in vec4 fog_interp; #else uniform mediump vec4 fog_color_base; @@ -1648,7 +1625,7 @@ FRAGMENT_SHADER_CODE #ifdef USE_LIGHTMAP //ambient light will come entirely from lightmap is lightmap is used - ambient_light = texture2D(lightmap, uv2_interp).rgb * lightmap_energy; + ambient_light = texture(lightmap, uv2_interp).rgb * lightmap_energy; #endif #ifdef USE_LIGHTMAP_CAPTURE @@ -2084,7 +2061,7 @@ FRAGMENT_SHADER_CODE #ifdef SHADELESS - gl_FragColor = vec4(albedo, alpha); + frag_color = vec4(albedo, alpha); #else ambient_light *= albedo; @@ -2099,13 +2076,13 @@ FRAGMENT_SHADER_CODE diffuse_light *= 1.0 - metallic; ambient_light *= 1.0 - metallic; - gl_FragColor = vec4(ambient_light + diffuse_light + specular_light, alpha); + frag_color = vec4(ambient_light + diffuse_light + specular_light, alpha); //add emission if in base pass #ifdef BASE_PASS - gl_FragColor.rgb += emission; + frag_color.rgb += emission; #endif - // gl_FragColor = vec4(normal, 1.0); + // frag_color = vec4(normal, 1.0); //apply fog #if defined(FOG_DEPTH_ENABLED) || defined(FOG_HEIGHT_ENABLED) @@ -2113,9 +2090,9 @@ FRAGMENT_SHADER_CODE #if defined(USE_VERTEX_LIGHTING) #if defined(BASE_PASS) - gl_FragColor.rgb = mix(gl_FragColor.rgb, fog_interp.rgb, fog_interp.a); + frag_color.rgb = mix(frag_color.rgb, fog_interp.rgb, fog_interp.a); #else - gl_FragColor.rgb *= (1.0 - fog_interp.a); + frag_color.rgb *= (1.0 - fog_interp.a); #endif // BASE_PASS #else //pixel based fog @@ -2136,7 +2113,7 @@ FRAGMENT_SHADER_CODE fog_amount = pow(fog_z, fog_depth_curve) * fog_color_base.a; if (fog_transmit_enabled) { - vec3 total_light = gl_FragColor.rgb; + vec3 total_light = frag_color.rgb; float transmit = pow(fog_z, fog_transmit_curve); fog_color = mix(max(total_light, fog_color), fog_color, transmit); } @@ -2151,9 +2128,9 @@ FRAGMENT_SHADER_CODE #endif #if defined(BASE_PASS) - gl_FragColor.rgb = mix(gl_FragColor.rgb, fog_color, fog_amount); + frag_color.rgb = mix(frag_color.rgb, fog_color, fog_amount); #else - gl_FragColor.rgb *= (1.0 - fog_amount); + frag_color.rgb *= (1.0 - fog_amount); #endif // BASE_PASS #endif //use vertex lit @@ -2169,7 +2146,7 @@ FRAGMENT_SHADER_CODE highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias highp vec4 comp = fract(depth * vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0)); comp -= comp.xxyz * vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0); - gl_FragColor = comp; + frag_color = comp; #endif #endif diff --git a/drivers/opengl/shaders/tonemap.glsl b/drivers/gles3/shaders/tonemap.glsl similarity index 74% rename from drivers/opengl/shaders/tonemap.glsl rename to drivers/gles3/shaders/tonemap.glsl index 0117bdb3d30..8b3aa4d3090 100644 --- a/drivers/opengl/shaders/tonemap.glsl +++ b/drivers/gles3/shaders/tonemap.glsl @@ -10,11 +10,11 @@ precision highp float; precision highp int; #endif -attribute vec2 vertex_attrib; // attrib:0 +layout(location = 0) vec2 vertex_attrib; /* clang-format on */ -attribute vec2 uv_in; // attrib:4 +layout(location = 4) vec2 uv_in; -varying vec2 uv_interp; +out vec2 uv_interp; void main() { gl_Position = vec4(vertex_attrib, 0.0, 1.0); @@ -25,30 +25,6 @@ void main() { /* clang-format off */ [fragment] -// texture2DLodEXT and textureCubeLodEXT are fragment shader specific. -// Do not copy these defines in the vertex section. -#ifndef USE_GLES_OVER_GL -#ifdef GL_EXT_shader_texture_lod -#extension GL_EXT_shader_texture_lod : enable -#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod) -#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod) -#endif -#endif // !USE_GLES_OVER_GL - -#ifdef GL_ARB_shader_texture_lod -#extension GL_ARB_shader_texture_lod : enable -#endif - -#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod) -#define texture2DLod(img, coord, lod) texture2D(img, coord, lod) -#define textureCubeLod(img, coord, lod) textureCube(img, coord, lod) -#endif - -// Allows the use of bitshift operators for bicubic upscale -#ifdef GL_EXT_gpu_shader4 -#extension GL_EXT_gpu_shader4 : enable -#endif - #ifdef USE_GLES_OVER_GL #define lowp #define mediump @@ -63,11 +39,11 @@ precision mediump int; #endif #endif -#include "stdlib.glsl" - -varying vec2 uv_interp; +in vec2 uv_interp; /* clang-format on */ +layout(location = 0) out vec4 frag_color; + uniform highp sampler2D source; //texunit:0 #if defined(USE_GLOW_LEVEL1) || defined(USE_GLOW_LEVEL2) || defined(USE_GLOW_LEVEL3) || defined(USE_GLOW_LEVEL4) || defined(USE_GLOW_LEVEL5) || defined(USE_GLOW_LEVEL6) || defined(USE_GLOW_LEVEL7) @@ -101,7 +77,6 @@ uniform vec2 pixel_size; uniform sampler2D color_correction; //texunit:1 #endif -#ifdef GL_EXT_gpu_shader4 #ifdef USE_GLOW_FILTER_BICUBIC // w0, w1, w2, and w3 are the four cubic B-spline basis functions float w0(float a) { @@ -140,7 +115,7 @@ float h1(float a) { uniform ivec2 glow_texture_size; -vec4 texture2D_bicubic(sampler2D tex, vec2 uv, int p_lod) { +vec4 texture_bicubic(sampler2D tex, vec2 uv, int p_lod) { float lod = float(p_lod); vec2 tex_size = vec2(glow_texture_size >> p_lod); vec2 texel_size = vec2(1.0) / tex_size; @@ -162,19 +137,15 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv, int p_lod) { vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - vec2(0.5)) * texel_size; vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - vec2(0.5)) * texel_size; - return (g0(fuv.y) * (g0x * texture2DLod(tex, p0, lod) + g1x * texture2DLod(tex, p1, lod))) + - (g1(fuv.y) * (g0x * texture2DLod(tex, p2, lod) + g1x * texture2DLod(tex, p3, lod))); + return (g0(fuv.y) * (g0x * textureLod(tex, p0, lod) + g1x * textureLod(tex, p1, lod))) + + (g1(fuv.y) * (g0x * textureLod(tex, p2, lod) + g1x * textureLod(tex, p3, lod))); } -#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture2D_bicubic(m_tex, m_uv, m_lod) +#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture_bicubic(m_tex, m_uv, m_lod) #else //!USE_GLOW_FILTER_BICUBIC -#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture2DLod(m_tex, m_uv, float(m_lod)) +#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) textureLod(m_tex, m_uv, float(m_lod)) #endif //USE_GLOW_FILTER_BICUBIC -#else //!GL_EXT_gpu_shader4 -#define GLOW_TEXTURE_SAMPLE(m_tex, m_uv, m_lod) texture2DLod(m_tex, m_uv, float(m_lod)) -#endif //GL_EXT_gpu_shader4 - vec3 apply_glow(vec3 color, vec3 glow) { // apply glow using the selected blending mode #ifdef USE_GLOW_REPLACE color = glow; @@ -208,9 +179,9 @@ vec3 apply_bcs(vec3 color, vec3 bcs) { } vec3 apply_color_correction(vec3 color, sampler2D correction_tex) { - color.r = texture2D(correction_tex, vec2(color.r, 0.0)).r; - color.g = texture2D(correction_tex, vec2(color.g, 0.0)).g; - color.b = texture2D(correction_tex, vec2(color.b, 0.0)).b; + color.r = texture(correction_tex, vec2(color.r, 0.0)).r; + color.g = texture(correction_tex, vec2(color.g, 0.0)).g; + color.b = texture(correction_tex, vec2(color.b, 0.0)).b; return color; } @@ -220,10 +191,10 @@ vec3 apply_fxaa(vec3 color, vec2 uv_interp, vec2 pixel_size) { const float FXAA_REDUCE_MUL = (1.0 / 8.0); const float FXAA_SPAN_MAX = 8.0; - vec3 rgbNW = texture2DLod(source, uv_interp + vec2(-1.0, -1.0) * pixel_size, 0.0).xyz; - vec3 rgbNE = texture2DLod(source, uv_interp + vec2(1.0, -1.0) * pixel_size, 0.0).xyz; - vec3 rgbSW = texture2DLod(source, uv_interp + vec2(-1.0, 1.0) * pixel_size, 0.0).xyz; - vec3 rgbSE = texture2DLod(source, uv_interp + vec2(1.0, 1.0) * pixel_size, 0.0).xyz; + vec3 rgbNW = textureLod(source, uv_interp + vec2(-1.0, -1.0) * pixel_size, 0.0).xyz; + vec3 rgbNE = textureLod(source, uv_interp + vec2(1.0, -1.0) * pixel_size, 0.0).xyz; + vec3 rgbSW = textureLod(source, uv_interp + vec2(-1.0, 1.0) * pixel_size, 0.0).xyz; + vec3 rgbSE = textureLod(source, uv_interp + vec2(1.0, 1.0) * pixel_size, 0.0).xyz; vec3 rgbM = color; vec3 luma = vec3(0.299, 0.587, 0.114); float lumaNW = dot(rgbNW, luma); @@ -239,18 +210,17 @@ vec3 apply_fxaa(vec3 color, vec2 uv_interp, vec2 pixel_size) { dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * - (0.25 * FXAA_REDUCE_MUL), + (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * - pixel_size; + pixel_size; - vec3 rgbA = 0.5 * (texture2DLod(source, uv_interp + dir * (1.0 / 3.0 - 0.5), 0.0).xyz + texture2DLod(source, uv_interp + dir * (2.0 / 3.0 - 0.5), 0.0).xyz); - vec3 rgbB = rgbA * 0.5 + 0.25 * (texture2DLod(source, uv_interp + dir * -0.5, 0.0).xyz + - texture2DLod(source, uv_interp + dir * 0.5, 0.0).xyz); + vec3 rgbA = 0.5 * (textureLod(source, uv_interp + dir * (1.0 / 3.0 - 0.5), 0.0).xyz + textureLod(source, uv_interp + dir * (2.0 / 3.0 - 0.5), 0.0).xyz); + vec3 rgbB = rgbA * 0.5 + 0.25 * (textureLod(source, uv_interp + dir * -0.5, 0.0).xyz + textureLod(source, uv_interp + dir * 0.5, 0.0).xyz); float lumaB = dot(rgbB, luma); if ((lumaB < lumaMin) || (lumaB > lumaMax)) { @@ -261,7 +231,7 @@ vec3 apply_fxaa(vec3 color, vec2 uv_interp, vec2 pixel_size) { } void main() { - vec3 color = texture2DLod(source, uv_interp, 0.0).rgb; + vec3 color = textureLod(source, uv_interp, 0.0).rgb; #ifdef USE_FXAA color = apply_fxaa(color, uv_interp, pixel_size); @@ -339,5 +309,5 @@ void main() { color = apply_color_correction(color, color_correction); #endif - gl_FragColor = vec4(color, 1.0); + frag_color = vec4(color, 1.0); } diff --git a/drivers/opengl/texture_loader_opengl.cpp b/drivers/gles3/texture_loader_gles3.cpp similarity index 97% rename from drivers/opengl/texture_loader_opengl.cpp rename to drivers/gles3/texture_loader_gles3.cpp index f4ead75a86c..1954eff9234 100644 --- a/drivers/opengl/texture_loader_opengl.cpp +++ b/drivers/gles3/texture_loader_gles3.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* texture_loader_opengl.cpp */ +/* texture_loader_gles3.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "texture_loader_opengl.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "texture_loader_gles3.h" +#ifdef GLES3_BACKEND_ENABLED #include "core/io/file_access.h" #include "core/string/print_string.h" diff --git a/drivers/opengl/texture_loader_opengl.h b/drivers/gles3/texture_loader_gles3.h similarity index 94% rename from drivers/opengl/texture_loader_opengl.h rename to drivers/gles3/texture_loader_gles3.h index e98438624bb..64a635fb067 100644 --- a/drivers/opengl/texture_loader_opengl.h +++ b/drivers/gles3/texture_loader_gles3.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* texture_loader_opengl.h */ +/* texture_loader_gles3.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,8 +31,8 @@ #ifndef TEXTURE_LOADER_OPENGL_H #define TEXTURE_LOADER_OPENGL_H -#include "drivers/opengl/rasterizer_platforms.h" -#ifdef OPENGL_BACKEND_ENABLED +#include "drivers/gles3/rasterizer_platforms.h" +#ifdef GLES3_BACKEND_ENABLED #include "core/io/resource_loader.h" #include "scene/resources/texture.h" @@ -47,6 +47,6 @@ public: virtual ~ResourceFormatGLES2Texture() {} }; -#endif // OPENGL_BACKEND_ENABLED +#endif // GLES3_BACKEND_ENABLED #endif // TEXTURE_LOADER_OPENGL_H diff --git a/drivers/opengl/rasterizer_scene_opengl.cpp b/drivers/opengl/rasterizer_scene_opengl.cpp deleted file mode 100644 index 5895147f945..00000000000 --- a/drivers/opengl/rasterizer_scene_opengl.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/*************************************************************************/ -/* rasterizer_scene_opengl.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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. */ -/*************************************************************************/ - -#include "rasterizer_scene_opengl.h" -#ifdef OPENGL_BACKEND_ENABLED - -// TODO: 3D support not implemented yet. - -RasterizerSceneOpenGL::GeometryInstance *RasterizerSceneOpenGL::geometry_instance_create(RID p_base) { - return nullptr; -} - -void RasterizerSceneOpenGL::geometry_instance_set_skeleton(GeometryInstance *p_geometry_instance, RID p_skeleton) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_material_override(GeometryInstance *p_geometry_instance, RID p_override) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_surface_materials(GeometryInstance *p_geometry_instance, const Vector &p_material) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_mesh_instance(GeometryInstance *p_geometry_instance, RID p_mesh_instance) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_transform(GeometryInstance *p_geometry_instance, const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabbb) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_layer_mask(GeometryInstance *p_geometry_instance, uint32_t p_layer_mask) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_lod_bias(GeometryInstance *p_geometry_instance, float p_lod_bias) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_use_baked_light(GeometryInstance *p_geometry_instance, bool p_enable) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_use_dynamic_gi(GeometryInstance *p_geometry_instance, bool p_enable) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_use_lightmap(GeometryInstance *p_geometry_instance, RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_lightmap_capture(GeometryInstance *p_geometry_instance, const Color *p_sh9) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_instance_shader_parameters_offset(GeometryInstance *p_geometry_instance, int32_t p_offset) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_cast_double_sided_shadows(GeometryInstance *p_geometry_instance, bool p_enable) { -} - -uint32_t RasterizerSceneOpenGL::geometry_instance_get_pair_mask() { - return 0; -} - -void RasterizerSceneOpenGL::geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) { -} - -void RasterizerSceneOpenGL::geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) { -} - -void RasterizerSceneOpenGL::geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) { -} - -void RasterizerSceneOpenGL::geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) { -} - -void RasterizerSceneOpenGL::geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) { -} - -void RasterizerSceneOpenGL::geometry_instance_free(GeometryInstance *p_geometry_instance) { -} - -/* SHADOW ATLAS API */ - -RID RasterizerSceneOpenGL::shadow_atlas_create() { - return RID(); -} - -void RasterizerSceneOpenGL::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits) { -} - -void RasterizerSceneOpenGL::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) { -} - -bool RasterizerSceneOpenGL::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) { - return false; -} - -void RasterizerSceneOpenGL::directional_shadow_atlas_set_size(int p_size, bool p_16_bits) { -} - -int RasterizerSceneOpenGL::get_directional_light_shadow_size(RID p_light_intance) { - return 0; -} - -void RasterizerSceneOpenGL::set_directional_shadow_count(int p_count) { -} - -/* SDFGI UPDATE */ - -void RasterizerSceneOpenGL::sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position) { -} - -int RasterizerSceneOpenGL::sdfgi_get_pending_region_count(RID p_render_buffers) const { - return 0; -} - -AABB RasterizerSceneOpenGL::sdfgi_get_pending_region_bounds(RID p_render_buffers, int p_region) const { - return AABB(); -} - -uint32_t RasterizerSceneOpenGL::sdfgi_get_pending_region_cascade(RID p_render_buffers, int p_region) const { - return 0; -} - -/* SKY API */ - -RID RasterizerSceneOpenGL::sky_allocate() { - return RID(); -} - -void RasterizerSceneOpenGL::sky_initialize(RID p_rid) { -} - -void RasterizerSceneOpenGL::sky_set_radiance_size(RID p_sky, int p_radiance_size) { -} - -void RasterizerSceneOpenGL::sky_set_mode(RID p_sky, RS::SkyMode p_samples) { -} - -void RasterizerSceneOpenGL::sky_set_material(RID p_sky, RID p_material) { -} - -Ref RasterizerSceneOpenGL::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) { - return Ref(); -} - -/* ENVIRONMENT API */ - -RID RasterizerSceneOpenGL::environment_allocate() { - return RID(); -} - -void RasterizerSceneOpenGL::environment_initialize(RID p_rid) { -} - -void RasterizerSceneOpenGL::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) { -} - -void RasterizerSceneOpenGL::environment_set_sky(RID p_env, RID p_sky) { -} - -void RasterizerSceneOpenGL::environment_set_sky_custom_fov(RID p_env, float p_scale) { -} - -void RasterizerSceneOpenGL::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) { -} - -void RasterizerSceneOpenGL::environment_set_bg_color(RID p_env, const Color &p_color) { -} - -void RasterizerSceneOpenGL::environment_set_bg_energy(RID p_env, float p_energy) { -} - -void RasterizerSceneOpenGL::environment_set_canvas_max_layer(RID p_env, int p_max_layer) { -} - -void RasterizerSceneOpenGL::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source) { -} - -void RasterizerSceneOpenGL::environment_set_glow(RID p_env, bool p_enable, Vector p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) { -} - -void RasterizerSceneOpenGL::environment_glow_set_use_bicubic_upscale(bool p_enable) { -} - -void RasterizerSceneOpenGL::environment_glow_set_use_high_quality(bool p_enable) { -} - -void RasterizerSceneOpenGL::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) { -} - -void RasterizerSceneOpenGL::environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) { -} - -void RasterizerSceneOpenGL::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) { -} - -void RasterizerSceneOpenGL::environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) { -} - -void RasterizerSceneOpenGL::environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) { -} - -void RasterizerSceneOpenGL::environment_set_sdfgi_ray_count(RS::EnvironmentSDFGIRayCount p_ray_count) { -} - -void RasterizerSceneOpenGL::environment_set_sdfgi_frames_to_converge(RS::EnvironmentSDFGIFramesToConverge p_frames) { -} - -void RasterizerSceneOpenGL::environment_set_sdfgi_frames_to_update_light(RS::EnvironmentSDFGIFramesToUpdateLight p_update) { -} - -void RasterizerSceneOpenGL::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) { -} - -void RasterizerSceneOpenGL::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) { -} - -void RasterizerSceneOpenGL::environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_aerial_perspective) { -} - -void RasterizerSceneOpenGL::environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount) { -} - -void RasterizerSceneOpenGL::environment_set_volumetric_fog_volume_size(int p_size, int p_depth) { -} - -void RasterizerSceneOpenGL::environment_set_volumetric_fog_filter_active(bool p_enable) { -} - -Ref RasterizerSceneOpenGL::environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) { - return Ref(); -} - -bool RasterizerSceneOpenGL::is_environment(RID p_env) const { - return false; -} - -RS::EnvironmentBG RasterizerSceneOpenGL::environment_get_background(RID p_env) const { - return RS::ENV_BG_KEEP; -} - -int RasterizerSceneOpenGL::environment_get_canvas_max_layer(RID p_env) const { - return 0; -} - -RID RasterizerSceneOpenGL::camera_effects_allocate() { - return RID(); -} - -void RasterizerSceneOpenGL::camera_effects_initialize(RID p_rid) { -} - -void RasterizerSceneOpenGL::camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) { -} - -void RasterizerSceneOpenGL::camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) { -} - -void RasterizerSceneOpenGL::camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) { -} - -void RasterizerSceneOpenGL::camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) { -} - -void RasterizerSceneOpenGL::shadows_quality_set(RS::ShadowQuality p_quality) { -} - -void RasterizerSceneOpenGL::directional_shadow_quality_set(RS::ShadowQuality p_quality) { -} - -RID RasterizerSceneOpenGL::light_instance_create(RID p_light) { - return RID(); -} - -void RasterizerSceneOpenGL::light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) { -} - -void RasterizerSceneOpenGL::light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) { -} - -void RasterizerSceneOpenGL::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale, float p_range_begin, const Vector2 &p_uv_scale) { -} - -void RasterizerSceneOpenGL::light_instance_mark_visible(RID p_light_instance) { -} - -RID RasterizerSceneOpenGL::reflection_atlas_create() { - return RID(); -} - -int RasterizerSceneOpenGL::reflection_atlas_get_size(RID p_ref_atlas) const { - return 0; -} - -void RasterizerSceneOpenGL::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) { -} - -RID RasterizerSceneOpenGL::reflection_probe_instance_create(RID p_probe) { - return RID(); -} - -void RasterizerSceneOpenGL::reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) { -} - -void RasterizerSceneOpenGL::reflection_probe_release_atlas_index(RID p_instance) { -} - -bool RasterizerSceneOpenGL::reflection_probe_instance_needs_redraw(RID p_instance) { - return false; -} - -bool RasterizerSceneOpenGL::reflection_probe_instance_has_reflection(RID p_instance) { - return false; -} - -bool RasterizerSceneOpenGL::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) { - return false; -} - -bool RasterizerSceneOpenGL::reflection_probe_instance_postprocess_step(RID p_instance) { - return true; -} - -RID RasterizerSceneOpenGL::decal_instance_create(RID p_decal) { - return RID(); -} - -void RasterizerSceneOpenGL::decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) { -} - -RID RasterizerSceneOpenGL::lightmap_instance_create(RID p_lightmap) { - return RID(); -} - -void RasterizerSceneOpenGL::lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) { -} - -RID RasterizerSceneOpenGL::voxel_gi_instance_create(RID p_voxel_gi) { - return RID(); -} - -void RasterizerSceneOpenGL::voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) { -} - -bool RasterizerSceneOpenGL::voxel_gi_needs_update(RID p_probe) const { - return false; -} - -void RasterizerSceneOpenGL::voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector &p_light_instances, const PagedArray &p_dynamic_objects) { -} - -void RasterizerSceneOpenGL::voxel_gi_set_quality(RS::VoxelGIQuality) { -} - -void RasterizerSceneOpenGL::render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray &p_instances, const PagedArray &p_lights, const PagedArray &p_reflection_probes, const PagedArray &p_voxel_gi_instances, const PagedArray &p_decals, const PagedArray &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data, RendererScene::RenderInfo *r_info) { -} - -void RasterizerSceneOpenGL::render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray &p_instances, RID p_framebuffer, const Rect2i &p_region) { -} - -void RasterizerSceneOpenGL::render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray &p_instances) { -} - -void RasterizerSceneOpenGL::set_scene_pass(uint64_t p_pass) { -} - -void RasterizerSceneOpenGL::set_time(double p_time, double p_step) { -} - -void RasterizerSceneOpenGL::set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) { -} - -RID RasterizerSceneOpenGL::render_buffers_create() { - return RID(); -} - -void RasterizerSceneOpenGL::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) { -} - -void RasterizerSceneOpenGL::gi_set_use_half_resolution(bool p_enable) { -} - -void RasterizerSceneOpenGL::screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_curve) { -} - -bool RasterizerSceneOpenGL::screen_space_roughness_limiter_is_active() const { - return false; -} - -void RasterizerSceneOpenGL::sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) { -} - -void RasterizerSceneOpenGL::sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) { -} - -TypedArray RasterizerSceneOpenGL::bake_render_uv2(RID p_base, const Vector &p_material_overrides, const Size2i &p_image_size) { - return TypedArray(); -} - -bool RasterizerSceneOpenGL::free(RID p_rid) { - return false; -} - -void RasterizerSceneOpenGL::update() { -} - -void RasterizerSceneOpenGL::sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) { -} - -void RasterizerSceneOpenGL::decals_set_filter(RS::DecalFilter p_filter) { -} - -void RasterizerSceneOpenGL::light_projectors_set_filter(RS::LightProjectorFilter p_filter) { -} - -RasterizerSceneOpenGL::RasterizerSceneOpenGL() { -} - -#endif // OPENGL_BACKEND_ENABLED diff --git a/drivers/opengl/shaders/SCsub b/drivers/opengl/shaders/SCsub deleted file mode 100644 index dcd8bf60307..00000000000 --- a/drivers/opengl/shaders/SCsub +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python - -Import("env") - -if "OpenGL_GLSL" in env["BUILDERS"]: - env.OpenGL_GLSL("copy.glsl") - env.OpenGL_GLSL("canvas.glsl") - env.OpenGL_GLSL("canvas_shadow.glsl") - env.OpenGL_GLSL("scene.glsl") - env.OpenGL_GLSL("cubemap_filter.glsl") - env.OpenGL_GLSL("cube_to_dp.glsl") - env.OpenGL_GLSL("effect_blur.glsl") - env.OpenGL_GLSL("tonemap.glsl") - env.OpenGL_GLSL("lens_distorted.glsl") diff --git a/drivers/opengl/shaders/stdlib.glsl b/drivers/opengl/shaders/stdlib.glsl deleted file mode 100644 index 9c744187430..00000000000 --- a/drivers/opengl/shaders/stdlib.glsl +++ /dev/null @@ -1,420 +0,0 @@ - -vec2 select2(vec2 a, vec2 b, bvec2 c) { - vec2 ret; - - ret.x = c.x ? b.x : a.x; - ret.y = c.y ? b.y : a.y; - - return ret; -} - -vec3 select3(vec3 a, vec3 b, bvec3 c) { - vec3 ret; - - ret.x = c.x ? b.x : a.x; - ret.y = c.y ? b.y : a.y; - ret.z = c.z ? b.z : a.z; - - return ret; -} - -vec4 select4(vec4 a, vec4 b, bvec4 c) { - vec4 ret; - - ret.x = c.x ? b.x : a.x; - ret.y = c.y ? b.y : a.y; - ret.z = c.z ? b.z : a.z; - ret.w = c.w ? b.w : a.w; - - return ret; -} - -highp vec4 texel2DFetch(highp sampler2D tex, ivec2 size, ivec2 coord) { - float x_coord = float(2 * coord.x + 1) / float(size.x * 2); - float y_coord = float(2 * coord.y + 1) / float(size.y * 2); - - return texture2DLod(tex, vec2(x_coord, y_coord), 0.0); -} - -#if defined(SINH_USED) - -highp float sinh(highp float x) { - return 0.5 * (exp(x) - exp(-x)); -} - -highp vec2 sinh(highp vec2 x) { - return 0.5 * vec2(exp(x.x) - exp(-x.x), exp(x.y) - exp(-x.y)); -} - -highp vec3 sinh(highp vec3 x) { - return 0.5 * vec3(exp(x.x) - exp(-x.x), exp(x.y) - exp(-x.y), exp(x.z) - exp(-x.z)); -} - -highp vec4 sinh(highp vec4 x) { - return 0.5 * vec4(exp(x.x) - exp(-x.x), exp(x.y) - exp(-x.y), exp(x.z) - exp(-x.z), exp(x.w) - exp(-x.w)); -} - -#endif - -#if defined(COSH_USED) - -highp float cosh(highp float x) { - return 0.5 * (exp(x) + exp(-x)); -} - -highp vec2 cosh(highp vec2 x) { - return 0.5 * vec2(exp(x.x) + exp(-x.x), exp(x.y) + exp(-x.y)); -} - -highp vec3 cosh(highp vec3 x) { - return 0.5 * vec3(exp(x.x) + exp(-x.x), exp(x.y) + exp(-x.y), exp(x.z) + exp(-x.z)); -} - -highp vec4 cosh(highp vec4 x) { - return 0.5 * vec4(exp(x.x) + exp(-x.x), exp(x.y) + exp(-x.y), exp(x.z) + exp(-x.z), exp(x.w) + exp(-x.w)); -} - -#endif - -#if defined(TANH_USED) - -highp float tanh(highp float x) { - highp float exp2x = exp(2.0 * x); - return (exp2x - 1.0) / (exp2x + 1.0); -} - -highp vec2 tanh(highp vec2 x) { - highp float exp2x = exp(2.0 * x.x); - highp float exp2y = exp(2.0 * x.y); - return vec2((exp2x - 1.0) / (exp2x + 1.0), (exp2y - 1.0) / (exp2y + 1.0)); -} - -highp vec3 tanh(highp vec3 x) { - highp float exp2x = exp(2.0 * x.x); - highp float exp2y = exp(2.0 * x.y); - highp float exp2z = exp(2.0 * x.z); - return vec3((exp2x - 1.0) / (exp2x + 1.0), (exp2y - 1.0) / (exp2y + 1.0), (exp2z - 1.0) / (exp2z + 1.0)); -} - -highp vec4 tanh(highp vec4 x) { - highp float exp2x = exp(2.0 * x.x); - highp float exp2y = exp(2.0 * x.y); - highp float exp2z = exp(2.0 * x.z); - highp float exp2w = exp(2.0 * x.w); - return vec4((exp2x - 1.0) / (exp2x + 1.0), (exp2y - 1.0) / (exp2y + 1.0), (exp2z - 1.0) / (exp2z + 1.0), (exp2w - 1.0) / (exp2w + 1.0)); -} - -#endif - -#if defined(ASINH_USED) - -highp float asinh(highp float x) { - return sign(x) * log(abs(x) + sqrt(1.0 + x * x)); -} - -highp vec2 asinh(highp vec2 x) { - return vec2(sign(x.x) * log(abs(x.x) + sqrt(1.0 + x.x * x.x)), sign(x.y) * log(abs(x.y) + sqrt(1.0 + x.y * x.y))); -} - -highp vec3 asinh(highp vec3 x) { - return vec3(sign(x.x) * log(abs(x.x) + sqrt(1.0 + x.x * x.x)), sign(x.y) * log(abs(x.y) + sqrt(1.0 + x.y * x.y)), sign(x.z) * log(abs(x.z) + sqrt(1.0 + x.z * x.z))); -} - -highp vec4 asinh(highp vec4 x) { - return vec4(sign(x.x) * log(abs(x.x) + sqrt(1.0 + x.x * x.x)), sign(x.y) * log(abs(x.y) + sqrt(1.0 + x.y * x.y)), sign(x.z) * log(abs(x.z) + sqrt(1.0 + x.z * x.z)), sign(x.w) * log(abs(x.w) + sqrt(1.0 + x.w * x.w))); -} - -#endif - -#if defined(ACOSH_USED) - -highp float acosh(highp float x) { - return log(x + sqrt(x * x - 1.0)); -} - -highp vec2 acosh(highp vec2 x) { - return vec2(log(x.x + sqrt(x.x * x.x - 1.0)), log(x.y + sqrt(x.y * x.y - 1.0))); -} - -highp vec3 acosh(highp vec3 x) { - return vec3(log(x.x + sqrt(x.x * x.x - 1.0)), log(x.y + sqrt(x.y * x.y - 1.0)), log(x.z + sqrt(x.z * x.z - 1.0))); -} - -highp vec4 acosh(highp vec4 x) { - return vec4(log(x.x + sqrt(x.x * x.x - 1.0)), log(x.y + sqrt(x.y * x.y - 1.0)), log(x.z + sqrt(x.z * x.z - 1.0)), log(x.w + sqrt(x.w * x.w - 1.0))); -} - -#endif - -#if defined(ATANH_USED) - -highp float atanh(highp float x) { - return 0.5 * log((1.0 + x) / (1.0 - x)); -} - -highp vec2 atanh(highp vec2 x) { - return 0.5 * vec2(log((1.0 + x.x) / (1.0 - x.x)), log((1.0 + x.y) / (1.0 - x.y))); -} - -highp vec3 atanh(highp vec3 x) { - return 0.5 * vec3(log((1.0 + x.x) / (1.0 - x.x)), log((1.0 + x.y) / (1.0 - x.y)), log((1.0 + x.z) / (1.0 - x.z))); -} - -highp vec4 atanh(highp vec4 x) { - return 0.5 * vec4(log((1.0 + x.x) / (1.0 - x.x)), log((1.0 + x.y) / (1.0 - x.y)), log((1.0 + x.z) / (1.0 - x.z)), log((1.0 + x.w) / (1.0 - x.w))); -} - -#endif - -#if defined(ROUND_USED) - -highp float round(highp float x) { - return floor(x + 0.5); -} - -highp vec2 round(highp vec2 x) { - return floor(x + vec2(0.5)); -} - -highp vec3 round(highp vec3 x) { - return floor(x + vec3(0.5)); -} - -highp vec4 round(highp vec4 x) { - return floor(x + vec4(0.5)); -} - -#endif - -#if defined(ROUND_EVEN_USED) - -highp float roundEven(highp float x) { - highp float t = x + 0.5; - highp float f = floor(t); - highp float r; - if (t == f) { - if (x > 0) - r = f - mod(f, 2); - else - r = f + mod(f, 2); - } else - r = f; - return r; -} - -highp vec2 roundEven(highp vec2 x) { - return vec2(roundEven(x.x), roundEven(x.y)); -} - -highp vec3 roundEven(highp vec3 x) { - return vec3(roundEven(x.x), roundEven(x.y), roundEven(x.z)); -} - -highp vec4 roundEven(highp vec4 x) { - return vec4(roundEven(x.x), roundEven(x.y), roundEven(x.z), roundEven(x.w)); -} - -#endif - -#if defined(IS_INF_USED) - -bool isinf(highp float x) { - return (2 * x == x) && (x != 0); -} - -bvec2 isinf(highp vec2 x) { - return bvec2((2 * x.x == x.x) && (x.x != 0), (2 * x.y == x.y) && (x.y != 0)); -} - -bvec3 isinf(highp vec3 x) { - return bvec3((2 * x.x == x.x) && (x.x != 0), (2 * x.y == x.y) && (x.y != 0), (2 * x.z == x.z) && (x.z != 0)); -} - -bvec4 isinf(highp vec4 x) { - return bvec4((2 * x.x == x.x) && (x.x != 0), (2 * x.y == x.y) && (x.y != 0), (2 * x.z == x.z) && (x.z != 0), (2 * x.w == x.w) && (x.w != 0)); -} - -#endif - -#if defined(IS_NAN_USED) - -bool isnan(highp float x) { - return x != x; -} - -bvec2 isnan(highp vec2 x) { - return bvec2(x.x != x.x, x.y != x.y); -} - -bvec3 isnan(highp vec3 x) { - return bvec3(x.x != x.x, x.y != x.y, x.z != x.z); -} - -bvec4 isnan(highp vec4 x) { - return bvec4(x.x != x.x, x.y != x.y, x.z != x.z, x.w != x.w); -} - -#endif - -#if defined(TRUNC_USED) - -highp float trunc(highp float x) { - return x < 0 ? -floor(-x) : floor(x); -} - -highp vec2 trunc(highp vec2 x) { - return vec2(x.x < 0 ? -floor(-x.x) : floor(x.x), x.y < 0 ? -floor(-x.y) : floor(x.y)); -} - -highp vec3 trunc(highp vec3 x) { - return vec3(x.x < 0 ? -floor(-x.x) : floor(x.x), x.y < 0 ? -floor(-x.y) : floor(x.y), x.z < 0 ? -floor(-x.z) : floor(x.z)); -} - -highp vec4 trunc(highp vec4 x) { - return vec4(x.x < 0 ? -floor(-x.x) : floor(x.x), x.y < 0 ? -floor(-x.y) : floor(x.y), x.z < 0 ? -floor(-x.z) : floor(x.z), x.w < 0 ? -floor(-x.w) : floor(x.w)); -} - -#endif - -#if defined(DETERMINANT_USED) - -highp float determinant(highp mat2 m) { - return m[0].x * m[1].y - m[1].x * m[0].y; -} - -highp float determinant(highp mat3 m) { - return m[0].x * (m[1].y * m[2].z - m[2].y * m[1].z) - m[1].x * (m[0].y * m[2].z - m[2].y * m[0].z) + m[2].x * (m[0].y * m[1].z - m[1].y * m[0].z); -} - -highp float determinant(highp mat4 m) { - highp float s00 = m[2].z * m[3].w - m[3].z * m[2].w; - highp float s01 = m[2].y * m[3].w - m[3].y * m[2].w; - highp float s02 = m[2].y * m[3].z - m[3].y * m[2].z; - highp float s03 = m[2].x * m[3].w - m[3].x * m[2].w; - highp float s04 = m[2].x * m[3].z - m[3].x * m[2].z; - highp float s05 = m[2].x * m[3].y - m[3].x * m[2].y; - highp vec4 c = vec4((m[1].y * s00 - m[1].z * s01 + m[1].w * s02), -(m[1].x * s00 - m[1].z * s03 + m[1].w * s04), (m[1].x * s01 - m[1].y * s03 + m[1].w * s05), -(m[1].x * s02 - m[1].y * s04 + m[1].z * s05)); - return m[0].x * c.x + m[0].y * c.y + m[0].z * c.z + m[0].w * c.w; -} - -#endif - -#if defined(INVERSE_USED) - -highp mat2 inverse(highp mat2 m) { - highp float d = 1.0 / (m[0].x * m[1].y - m[1].x * m[0].y); - return mat2( - vec2(m[1].y * d, -m[0].y * d), - vec2(-m[1].x * d, m[0].x * d)); -} - -highp mat3 inverse(highp mat3 m) { - highp float d = 1.0 / (m[0].x * (m[1].y * m[2].z - m[2].y * m[1].z) - m[1].x * (m[0].y * m[2].z - m[2].y * m[0].z) + m[2].x * (m[0].y * m[1].z - m[1].y * m[0].z)); - return mat3( - vec3((m[1].y * m[2].z - m[2].y * m[1].z), -(m[1].x * m[2].z - m[2].x * m[1].z), (m[1].x * m[2].y - m[2].x * m[1].y)) * d, - vec3(-(m[0].y * m[2].z - m[2].y * m[0].z), (m[0].x * m[2].z - m[2].x * m[0].z), -(m[0].x * m[2].y - m[2].x * m[0].y)) * d, - vec3((m[0].y * m[1].z - m[1].y * m[0].z), -(m[0].x * m[1].z - m[1].x * m[0].z), (m[0].x * m[1].y - m[1].x * m[0].y)) * d); -} - -highp mat4 inverse(highp mat4 m) { - highp float c00 = m[2].z * m[3].w - m[3].z * m[2].w; - highp float c02 = m[1].z * m[3].w - m[3].z * m[1].w; - highp float c03 = m[1].z * m[2].w - m[2].z * m[1].w; - - highp float c04 = m[2].y * m[3].w - m[3].y * m[2].w; - highp float c06 = m[1].y * m[3].w - m[3].y * m[1].w; - highp float c07 = m[1].y * m[2].w - m[2].y * m[1].w; - - highp float c08 = m[2].y * m[3].z - m[3].y * m[2].z; - highp float c10 = m[1].y * m[3].z - m[3].y * m[1].z; - highp float c11 = m[1].y * m[2].z - m[2].y * m[1].z; - - highp float c12 = m[2].x * m[3].w - m[3].x * m[2].w; - highp float c14 = m[1].x * m[3].w - m[3].x * m[1].w; - highp float c15 = m[1].x * m[2].w - m[2].x * m[1].w; - - highp float c16 = m[2].x * m[3].z - m[3].x * m[2].z; - highp float c18 = m[1].x * m[3].z - m[3].x * m[1].z; - highp float c19 = m[1].x * m[2].z - m[2].x * m[1].z; - - highp float c20 = m[2].x * m[3].y - m[3].x * m[2].y; - highp float c22 = m[1].x * m[3].y - m[3].x * m[1].y; - highp float c23 = m[1].x * m[2].y - m[2].x * m[1].y; - - vec4 f0 = vec4(c00, c00, c02, c03); - vec4 f1 = vec4(c04, c04, c06, c07); - vec4 f2 = vec4(c08, c08, c10, c11); - vec4 f3 = vec4(c12, c12, c14, c15); - vec4 f4 = vec4(c16, c16, c18, c19); - vec4 f5 = vec4(c20, c20, c22, c23); - - vec4 v0 = vec4(m[1].x, m[0].x, m[0].x, m[0].x); - vec4 v1 = vec4(m[1].y, m[0].y, m[0].y, m[0].y); - vec4 v2 = vec4(m[1].z, m[0].z, m[0].z, m[0].z); - vec4 v3 = vec4(m[1].w, m[0].w, m[0].w, m[0].w); - - vec4 inv0 = vec4(v1 * f0 - v2 * f1 + v3 * f2); - vec4 inv1 = vec4(v0 * f0 - v2 * f3 + v3 * f4); - vec4 inv2 = vec4(v0 * f1 - v1 * f3 + v3 * f5); - vec4 inv3 = vec4(v0 * f2 - v1 * f4 + v2 * f5); - - vec4 sa = vec4(+1, -1, +1, -1); - vec4 sb = vec4(-1, +1, -1, +1); - - mat4 inv = mat4(inv0 * sa, inv1 * sb, inv2 * sa, inv3 * sb); - - vec4 r0 = vec4(inv[0].x, inv[1].x, inv[2].x, inv[3].x); - vec4 d0 = vec4(m[0] * r0); - - highp float d1 = (d0.x + d0.y) + (d0.z + d0.w); - highp float d = 1.0 / d1; - - return inv * d; -} - -#endif - -#ifndef USE_GLES_OVER_GL - -#if defined(TRANSPOSE_USED) - -highp mat2 transpose(highp mat2 m) { - return mat2( - vec2(m[0].x, m[1].x), - vec2(m[0].y, m[1].y)); -} - -highp mat3 transpose(highp mat3 m) { - return mat3( - vec3(m[0].x, m[1].x, m[2].x), - vec3(m[0].y, m[1].y, m[2].y), - vec3(m[0].z, m[1].z, m[2].z)); -} - -#endif - -highp mat4 transpose(highp mat4 m) { - return mat4( - vec4(m[0].x, m[1].x, m[2].x, m[3].x), - vec4(m[0].y, m[1].y, m[2].y, m[3].y), - vec4(m[0].z, m[1].z, m[2].z, m[3].z), - vec4(m[0].w, m[1].w, m[2].w, m[3].w)); -} - -#if defined(OUTER_PRODUCT_USED) - -highp mat2 outerProduct(highp vec2 c, highp vec2 r) { - return mat2(c * r.x, c * r.y); -} - -highp mat3 outerProduct(highp vec3 c, highp vec3 r) { - return mat3(c * r.x, c * r.y, c * r.z); -} - -highp mat4 outerProduct(highp vec4 c, highp vec4 r) { - return mat4(c * r.x, c * r.y, c * r.z, c * r.w); -} - -#endif - -#endif diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index bc4d9fb156f..372d01d89aa 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1498,7 +1498,7 @@ String EditorExportPlatform::test_etc2() const { bool etc_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc"); bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2"); - if (driver == "OpenGL" && !etc_supported) { + if (driver == "OpenGL3" && !etc_supported) { return TTR("Target platform requires 'ETC' texture compression for OpenGL. Enable 'Import Etc' in Project Settings."); } else if (driver == "Vulkan" && !etc2_supported) { // FIXME: Review if this is true for Vulkan. @@ -1515,7 +1515,7 @@ String EditorExportPlatform::test_etc2_or_pvrtc() const { // bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2"); // bool pvrtc_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_pvrtc"); - if (driver == "OpenGL" && !pvrtc_supported) { + if (driver == "OpenGL3" && !pvrtc_supported) { return TTR("Target platform requires 'PVRTC' texture compression for OpenGL. Enable 'Import Pvrtc' in Project Settings."); } else if (driver == "Vulkan" && !etc2_supported && !pvrtc_supported) { // FIXME: Review if this is true for Vulkan. diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d3d055a0095..9edf0a24fc6 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5596,7 +5596,7 @@ void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) { } void EditorNode::_update_rendering_driver_color() { - if (rendering_driver->get_text() == "opengl") { + if (rendering_driver->get_text() == "opengl3") { rendering_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff)); } else if (rendering_driver->get_text() == "vulkan") { rendering_driver->add_theme_color_override("font_color", theme_base->get_theme_color("vulkan_color", "Editor")); @@ -6619,28 +6619,12 @@ EditorNode::EditorNode() { HBoxContainer *right_menu_hb = memnew(HBoxContainer); menu_hb->add_child(right_menu_hb); - // Toggle for video driver - // video_driver = memnew(OptionButton); - // video_driver->set_focus_mode(Control::FOCUS_NONE); - // video_driver->connect("item_selected", callable_mp(this, &EditorNode::_video_driver_selected)); - // video_driver->add_theme_font_override("font", gui_base->get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); - // video_driver->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"))); - // // TODO: Show again when OpenGL is ported. - // video_driver->set_visible(false); - // right_menu_hb->add_child(video_driver); - - //#ifndef _MSC_VER - //#warning needs to be reimplemented - //#endif - //#if 0 - // String video_drivers = ProjectSettings::get_singleton()->get_custom_property_info()["rendering/driver/driver_name"].hint_string; - // String current_video_driver = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver()); - // video_driver_current = 0; - // for (int i = 0; i < video_drivers.get_slice_count(","); i++) { - // String driver = video_drivers.get_slice(",", i); - // video_driver->add_item(driver); - // video_driver->set_item_metadata(i, driver); rendering_driver = memnew(OptionButton); + + // Hide the renderer selection dropdown until OpenGL support is more mature. + // The renderer can still be changed in the project settings or using `--rendering-driver opengl3`. + rendering_driver->set_visible(false); + rendering_driver->set_flat(true); rendering_driver->set_focus_mode(Control::FOCUS_NONE); rendering_driver->connect("item_selected", callable_mp(this, &EditorNode::_rendering_driver_selected)); @@ -6649,23 +6633,23 @@ EditorNode::EditorNode() { right_menu_hb->add_child(rendering_driver); - // only display the render drivers that are available for this display driver + // Only display the render drivers that are available for this display driver. int display_driver_idx = OS::get_singleton()->get_display_driver_id(); Vector render_drivers = DisplayServer::get_create_function_rendering_drivers(display_driver_idx); String current_rendering_driver = OS::get_singleton()->get_current_rendering_driver_name(); - // as we are doing string comparisons, keep in standard case to prevent problems with capitals - // 'vulkan' in particular uses lower case v in the code, and upper case in the UI . + // As we are doing string comparisons, keep in standard case to prevent problems with capitals + // "vulkan" in particular uses lowercase "v" in the code, and uppercase in the UI. current_rendering_driver = current_rendering_driver.to_lower(); for (int i = 0; i < render_drivers.size(); i++) { String driver = render_drivers[i]; - // add the driver to the user interface + // Add the driver to the UI. rendering_driver->add_item(driver); rendering_driver->set_item_metadata(i, driver); - // lower case for standard comparison + // Lowercase for standard comparison. driver = driver.to_lower(); if (current_rendering_driver == driver) { @@ -6673,29 +6657,6 @@ EditorNode::EditorNode() { rendering_driver_current = i; } } -#if 0 - // commented out old version, gets the driver list from the project settings - // just in case we decide to revert to this method - String rendering_drivers = ProjectSettings::get_singleton()->get_custom_property_info()["rendering/driver/driver_name"].hint_string; - String current_rendering_driver = OS::get_singleton()->get_current_rendering_driver_name(); - current_rendering_driver = current_rendering_driver.to_lower(); - print_line("current_rendering_driver " + current_rendering_driver); - - rendering_driver_current = 0; - for (int i = 0; i < rendering_drivers.get_slice_count(","); i++) { - String driver = rendering_drivers.get_slice(",", i); - rendering_driver->add_item(driver); - rendering_driver->set_item_metadata(i, driver); - - driver = driver.to_lower(); - print_line("\tdriver " + driver); - - if (current_rendering_driver == driver) { - rendering_driver->select(i); - rendering_driver_current = i; - } - } -#endif _update_rendering_driver_color(); video_restart_dialog = memnew(ConfirmationDialog); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 2bd99debedd..9189c751621 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1246,7 +1246,7 @@ void VisualShaderEditor::_update_options_menu() { Color unsupported_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); Color supported_color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); - static bool low_driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "opengl"; + static bool low_driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "opengl3"; Map folders; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 8d14fa899ef..dc35e01a560 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -478,7 +478,7 @@ private: if (rasterizer_button_group->get_pressed_button()->get_meta("driver_name") == "Vulkan") { initial_settings["rendering/driver/driver_name"] = "Vulkan"; } else { - initial_settings["rendering/driver/driver_name"] = "OpenGL"; + initial_settings["rendering/driver/driver_name"] = "OpenGL3"; initial_settings["rendering/textures/vram_compression/import_etc2"] = false; initial_settings["rendering/textures/vram_compression/import_etc"] = true; } diff --git a/opengl_builders.py b/gles3_builders.py similarity index 98% rename from opengl_builders.py rename to gles3_builders.py index 179b5c69abf..acaff286852 100644 --- a/opengl_builders.py +++ b/gles3_builders.py @@ -519,11 +519,9 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs): fd.close() -def build_opengl_headers(target, source, env): +def build_gles3_headers(target, source, env): for x in source: - build_legacygl_header( - str(x), include="drivers/opengl/shader_opengl.h", class_suffix="OpenGL", output_attribs=True - ) + build_legacygl_header(str(x), include="drivers/gles3/shader_gles3.h", class_suffix="GLES3", output_attribs=True) if __name__ == "__main__": diff --git a/main/main.cpp b/main/main.cpp index bc23d498dc1..fe0f2693e4d 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1573,8 +1573,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) { String display_driver = DisplayServer::get_create_function_name(display_driver_idx); // rendering_driver now held in static global String in main and initialized in setup() - print_line("creating display driver : " + display_driver); - print_line("creating rendering driver : " + rendering_driver); Error err; display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_vsync_mode, window_flags, window_size, err); if (err != OK || display_server == nullptr) { diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index 084761b794f..34f0064a5e7 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -344,8 +344,8 @@ void DisplayServerAndroid::process_events() { Vector DisplayServerAndroid::get_rendering_drivers_func() { Vector drivers; -#ifdef OPENGL_ENABLED - drivers.push_back("opengl"); +#ifdef GLES3_ENABLED + drivers.push_back("opengl3"); #endif #ifdef VULKAN_ENABLED drivers.push_back("vulkan"); @@ -407,13 +407,13 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis keep_screen_on = GLOBAL_GET("display/window/energy_saving/keep_screen_on"); -#if defined(OPENGL_ENABLED) - if (rendering_driver == "opengl") { +#if defined(GLES3_ENABLED) + if (rendering_driver == "opengl3") { bool gl_initialization_error = false; - if (RasterizerOpenGLis_viable() == OK) { - RasterizerOpenGLregister_config(); - RasterizerOpenGLmake_current(); + if (RasterizerGLES3::is_viable() == OK) { + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); } else { gl_initialization_error = true; } diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 1cac0ed4ce5..8df61831c2e 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -31,2833 +31,6 @@ #include "export.h" #include "export_plugin.h" -//#include "core/config/project_settings.h" -//#include "core/io/image_loader.h" -//#include "core/io/marshalls.h" -//#include "core/io/zip_io.h" -//#include "core/os/dir_access.h" -//#include "core/os/file_access.h" -//#include "core/os/os.h" -//#include "core/version.h" -//#include "drivers/png/png_driver_common.h" -//#include "editor/editor_export.h" -//#include "editor/editor_log.h" -//#include "editor/editor_node.h" -//#include "editor/editor_settings.h" -//#include "main/splash.gen.h" -//#include "platform/android/export/gradle_export_util.h" -//#include "platform/android/logo.gen.h" -//#include "platform/android/plugin/godot_plugin_config.h" -//#include "platform/android/run_icon.gen.h" - -//#include - -//static const char *android_perms[] = { -// "ACCESS_CHECKIN_PROPERTIES", -// "ACCESS_COARSE_LOCATION", -// "ACCESS_FINE_LOCATION", -// "ACCESS_LOCATION_EXTRA_COMMANDS", -// "ACCESS_MOCK_LOCATION", -// "ACCESS_NETWORK_STATE", -// "ACCESS_SURFACE_FLINGER", -// "ACCESS_WIFI_STATE", -// "ACCOUNT_MANAGER", -// "ADD_VOICEMAIL", -// "AUTHENTICATE_ACCOUNTS", -// "BATTERY_STATS", -// "BIND_ACCESSIBILITY_SERVICE", -// "BIND_APPWIDGET", -// "BIND_DEVICE_ADMIN", -// "BIND_INPUT_METHOD", -// "BIND_NFC_SERVICE", -// "BIND_NOTIFICATION_LISTENER_SERVICE", -// "BIND_PRINT_SERVICE", -// "BIND_REMOTEVIEWS", -// "BIND_TEXT_SERVICE", -// "BIND_VPN_SERVICE", -// "BIND_WALLPAPER", -// "BLUETOOTH", -// "BLUETOOTH_ADMIN", -// "BLUETOOTH_PRIVILEGED", -// "BRICK", -// "BROADCAST_PACKAGE_REMOVED", -// "BROADCAST_SMS", -// "BROADCAST_STICKY", -// "BROADCAST_WAP_PUSH", -// "CALL_PHONE", -// "CALL_PRIVILEGED", -// "CAMERA", -// "CAPTURE_AUDIO_OUTPUT", -// "CAPTURE_SECURE_VIDEO_OUTPUT", -// "CAPTURE_VIDEO_OUTPUT", -// "CHANGE_COMPONENT_ENABLED_STATE", -// "CHANGE_CONFIGURATION", -// "CHANGE_NETWORK_STATE", -// "CHANGE_WIFI_MULTICAST_STATE", -// "CHANGE_WIFI_STATE", -// "CLEAR_APP_CACHE", -// "CLEAR_APP_USER_DATA", -// "CONTROL_LOCATION_UPDATES", -// "DELETE_CACHE_FILES", -// "DELETE_PACKAGES", -// "DEVICE_POWER", -// "DIAGNOSTIC", -// "DISABLE_KEYGUARD", -// "DUMP", -// "EXPAND_STATUS_BAR", -// "FACTORY_TEST", -// "FLASHLIGHT", -// "FORCE_BACK", -// "GET_ACCOUNTS", -// "GET_PACKAGE_SIZE", -// "GET_TASKS", -// "GET_TOP_ACTIVITY_INFO", -// "GLOBAL_SEARCH", -// "HARDWARE_TEST", -// "INJECT_EVENTS", -// "INSTALL_LOCATION_PROVIDER", -// "INSTALL_PACKAGES", -// "INSTALL_SHORTCUT", -// "INTERNAL_SYSTEM_WINDOW", -// "INTERNET", -// "KILL_BACKGROUND_PROCESSES", -// "LOCATION_HARDWARE", -// "MANAGE_ACCOUNTS", -// "MANAGE_APP_TOKENS", -// "MANAGE_DOCUMENTS", -// "MASTER_CLEAR", -// "MEDIA_CONTENT_CONTROL", -// "MODIFY_AUDIO_SETTINGS", -// "MODIFY_PHONE_STATE", -// "MOUNT_FORMAT_FILESYSTEMS", -// "MOUNT_UNMOUNT_FILESYSTEMS", -// "NFC", -// "PERSISTENT_ACTIVITY", -// "PROCESS_OUTGOING_CALLS", -// "READ_CALENDAR", -// "READ_CALL_LOG", -// "READ_CONTACTS", -// "READ_EXTERNAL_STORAGE", -// "READ_FRAME_BUFFER", -// "READ_HISTORY_BOOKMARKS", -// "READ_INPUT_STATE", -// "READ_LOGS", -// "READ_PHONE_STATE", -// "READ_PROFILE", -// "READ_SMS", -// "READ_SOCIAL_STREAM", -// "READ_SYNC_SETTINGS", -// "READ_SYNC_STATS", -// "READ_USER_DICTIONARY", -// "REBOOT", -// "RECEIVE_BOOT_COMPLETED", -// "RECEIVE_MMS", -// "RECEIVE_SMS", -// "RECEIVE_WAP_PUSH", -// "RECORD_AUDIO", -// "REORDER_TASKS", -// "RESTART_PACKAGES", -// "SEND_RESPOND_VIA_MESSAGE", -// "SEND_SMS", -// "SET_ACTIVITY_WATCHER", -// "SET_ALARM", -// "SET_ALWAYS_FINISH", -// "SET_ANIMATION_SCALE", -// "SET_DEBUG_APP", -// "SET_ORIENTATION", -// "SET_POINTER_SPEED", -// "SET_PREFERRED_APPLICATIONS", -// "SET_PROCESS_LIMIT", -// "SET_TIME", -// "SET_TIME_ZONE", -// "SET_WALLPAPER", -// "SET_WALLPAPER_HINTS", -// "SIGNAL_PERSISTENT_PROCESSES", -// "STATUS_BAR", -// "SUBSCRIBED_FEEDS_READ", -// "SUBSCRIBED_FEEDS_WRITE", -// "SYSTEM_ALERT_WINDOW", -// "TRANSMIT_IR", -// "UNINSTALL_SHORTCUT", -// "UPDATE_DEVICE_STATS", -// "USE_CREDENTIALS", -// "USE_SIP", -// "VIBRATE", -// "WAKE_LOCK", -// "WRITE_APN_SETTINGS", -// "WRITE_CALENDAR", -// "WRITE_CALL_LOG", -// "WRITE_CONTACTS", -// "WRITE_EXTERNAL_STORAGE", -// "WRITE_GSERVICES", -// "WRITE_HISTORY_BOOKMARKS", -// "WRITE_PROFILE", -// "WRITE_SECURE_SETTINGS", -// "WRITE_SETTINGS", -// "WRITE_SMS", -// "WRITE_SOCIAL_STREAM", -// "WRITE_SYNC_SETTINGS", -// "WRITE_USER_DICTIONARY", -// nullptr -//}; - -//static const char *SPLASH_IMAGE_EXPORT_PATH = "res/drawable/splash.png"; -//static const char *SPLASH_BG_COLOR_PATH = "res/drawable/splash_bg_color.png"; - -//struct LauncherIcon { -// const char *export_path; -// int dimensions = 0; -//}; - -//static const int icon_densities_count = 6; -//static const char *launcher_icon_option = "launcher_icons/main_192x192"; -//static const char *launcher_adaptive_icon_foreground_option = "launcher_icons/adaptive_foreground_432x432"; -//static const char *launcher_adaptive_icon_background_option = "launcher_icons/adaptive_background_432x432"; - -//static const LauncherIcon launcher_icons[icon_densities_count] = { -// { "res/mipmap-xxxhdpi-v4/icon.png", 192 }, -// { "res/mipmap-xxhdpi-v4/icon.png", 144 }, -// { "res/mipmap-xhdpi-v4/icon.png", 96 }, -// { "res/mipmap-hdpi-v4/icon.png", 72 }, -// { "res/mipmap-mdpi-v4/icon.png", 48 }, -// { "res/mipmap/icon.png", 192 } -//}; - -//static const LauncherIcon launcher_adaptive_icon_foregrounds[icon_densities_count] = { -// { "res/mipmap-xxxhdpi-v4/icon_foreground.png", 432 }, -// { "res/mipmap-xxhdpi-v4/icon_foreground.png", 324 }, -// { "res/mipmap-xhdpi-v4/icon_foreground.png", 216 }, -// { "res/mipmap-hdpi-v4/icon_foreground.png", 162 }, -// { "res/mipmap-mdpi-v4/icon_foreground.png", 108 }, -// { "res/mipmap/icon_foreground.png", 432 } -//}; - -//static const LauncherIcon launcher_adaptive_icon_backgrounds[icon_densities_count] = { -// { "res/mipmap-xxxhdpi-v4/icon_background.png", 432 }, -// { "res/mipmap-xxhdpi-v4/icon_background.png", 324 }, -// { "res/mipmap-xhdpi-v4/icon_background.png", 216 }, -// { "res/mipmap-hdpi-v4/icon_background.png", 162 }, -// { "res/mipmap-mdpi-v4/icon_background.png", 108 }, -// { "res/mipmap/icon_background.png", 432 } -//}; - -//static const int EXPORT_FORMAT_APK = 0; -//static const int EXPORT_FORMAT_AAB = 1; - -//class EditorExportPlatformAndroid : public EditorExportPlatform { -// GDCLASS(EditorExportPlatformAndroid, EditorExportPlatform); - -// Ref logo; -// Ref run_icon; - -// struct Device { -// String id; -// String name; -// String description; -// int api_level = 0; -// }; - -// struct APKExportData { -// zipFile apk; -// EditorProgress *ep = nullptr; -// }; - -// Vector plugins; -// String last_plugin_names; -// uint64_t last_custom_build_time = 0; -// volatile bool plugins_changed; -// Mutex plugins_lock; -// Vector devices; -// volatile bool devices_changed; -// Mutex device_lock; -// Thread *check_for_changes_thread; -// volatile bool quit_request; - -// static void _check_for_changes_poll_thread(void *ud) { -// EditorExportPlatformAndroid *ea = (EditorExportPlatformAndroid *)ud; - -// while (!ea->quit_request) { -// // Check for plugins updates -// { -// // Nothing to do if we already know the plugins have changed. -// if (!ea->plugins_changed) { -// Vector loaded_plugins = get_plugins(); - -// MutexLock lock(ea->plugins_lock); - -// if (ea->plugins.size() != loaded_plugins.size()) { -// ea->plugins_changed = true; -// } else { -// for (int i = 0; i < ea->plugins.size(); i++) { -// if (ea->plugins[i].name != loaded_plugins[i].name) { -// ea->plugins_changed = true; -// break; -// } -// } -// } - -// if (ea->plugins_changed) { -// ea->plugins = loaded_plugins; -// } -// } -// } - -// // Check for devices updates -// String adb = get_adb_path(); -// if (FileAccess::exists(adb)) { -// String devices; -// List args; -// args.push_back("devices"); -// int ec; -// OS::get_singleton()->execute(adb, args, true, nullptr, &devices, &ec); - -// Vector ds = devices.split("\n"); -// Vector ldevices; -// for (int i = 1; i < ds.size(); i++) { -// String d = ds[i]; -// int dpos = d.find("device"); -// if (dpos == -1) { -// continue; -// } -// d = d.substr(0, dpos).strip_edges(); -// ldevices.push_back(d); -// } - -// MutexLock lock(ea->device_lock); - -// bool different = false; - -// if (ea->devices.size() != ldevices.size()) { -// different = true; -// } else { -// for (int i = 0; i < ea->devices.size(); i++) { -// if (ea->devices[i].id != ldevices[i]) { -// different = true; -// break; -// } -// } -// } - -// if (different) { -// Vector ndevices; - -// for (int i = 0; i < ldevices.size(); i++) { -// Device d; -// d.id = ldevices[i]; -// for (int j = 0; j < ea->devices.size(); j++) { -// if (ea->devices[j].id == ldevices[i]) { -// d.description = ea->devices[j].description; -// d.name = ea->devices[j].name; -// d.api_level = ea->devices[j].api_level; -// } -// } - -// if (d.description == "") { -// //in the oven, request! -// args.clear(); -// args.push_back("-s"); -// args.push_back(d.id); -// args.push_back("shell"); -// args.push_back("getprop"); -// int ec2; -// String dp; - -// OS::get_singleton()->execute(adb, args, true, nullptr, &dp, &ec2); - -// Vector props = dp.split("\n"); -// String vendor; -// String device; -// d.description = "Device ID: " + d.id + "\n"; -// d.api_level = 0; -// for (int j = 0; j < props.size(); j++) { -// // got information by `shell cat /system/build.prop` before and its format is "property=value" -// // it's now changed to use `shell getporp` because of permission issue with Android 8.0 and above -// // its format is "[property]: [value]" so changed it as like build.prop -// String p = props[j]; -// p = p.replace("]: ", "="); -// p = p.replace("[", ""); -// p = p.replace("]", ""); - -// if (p.begins_with("ro.product.model=")) { -// device = p.get_slice("=", 1).strip_edges(); -// } else if (p.begins_with("ro.product.brand=")) { -// vendor = p.get_slice("=", 1).strip_edges().capitalize(); -// } else if (p.begins_with("ro.build.display.id=")) { -// d.description += "Build: " + p.get_slice("=", 1).strip_edges() + "\n"; -// } else if (p.begins_with("ro.build.version.release=")) { -// d.description += "Release: " + p.get_slice("=", 1).strip_edges() + "\n"; -// } else if (p.begins_with("ro.build.version.sdk=")) { -// d.api_level = p.get_slice("=", 1).to_int(); -// } else if (p.begins_with("ro.product.cpu.abi=")) { -// d.description += "CPU: " + p.get_slice("=", 1).strip_edges() + "\n"; -// } else if (p.begins_with("ro.product.manufacturer=")) { -// d.description += "Manufacturer: " + p.get_slice("=", 1).strip_edges() + "\n"; -// } else if (p.begins_with("ro.board.platform=")) { -// d.description += "Chipset: " + p.get_slice("=", 1).strip_edges() + "\n"; -// } else if (p.begins_with("ro.opengles.version=")) { -// uint32_t opengl = p.get_slice("=", 1).to_int(); -// d.description += "OpenGL: " + itos(opengl >> 16) + "." + itos((opengl >> 8) & 0xFF) + "." + itos((opengl)&0xFF) + "\n"; -// } -// } - -// d.name = vendor + " " + device; -// if (device == String()) { -// continue; -// } -// } - -// ndevices.push_back(d); -// } - -// ea->devices = ndevices; -// ea->devices_changed = true; -// } -// } - -// uint64_t sleep = 200; -// uint64_t wait = 3000000; -// uint64_t time = OS::get_singleton()->get_ticks_usec(); -// while (OS::get_singleton()->get_ticks_usec() - time < wait) { -// OS::get_singleton()->delay_usec(1000 * sleep); -// if (ea->quit_request) { -// break; -// } -// } -// } - -// if (EditorSettings::get_singleton()->get("export/android/shutdown_adb_on_exit")) { -// String adb = get_adb_path(); -// if (!FileAccess::exists(adb)) { -// return; //adb not configured -// } - -// List args; -// args.push_back("kill-server"); -// OS::get_singleton()->execute(adb, args, true); -// }; -// } - -// String get_project_name(const String &p_name) const { -// String aname; -// if (p_name != "") { -// aname = p_name; -// } else { -// aname = ProjectSettings::get_singleton()->get("application/config/name"); -// } - -// if (aname == "") { -// aname = VERSION_NAME; -// } - -// return aname; -// } - -// String get_package_name(const String &p_package) const { -// String pname = p_package; -// String basename = ProjectSettings::get_singleton()->get("application/config/name"); -// basename = basename.to_lower(); - -// String name; -// bool first = true; -// for (int i = 0; i < basename.length(); i++) { -// char32_t c = basename[i]; -// if (c >= '0' && c <= '9' && first) { -// continue; -// } -// if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) { -// name += String::chr(c); -// first = false; -// } -// } -// if (name == "") { -// name = "noname"; -// } - -// pname = pname.replace("$genname", name); - -// return pname; -// } - -// bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const { -// String pname = p_package; - -// if (pname.length() == 0) { -// if (r_error) { -// *r_error = TTR("Package name is missing."); -// } -// return false; -// } - -// int segments = 0; -// bool first = true; -// for (int i = 0; i < pname.length(); i++) { -// char32_t c = pname[i]; -// if (first && c == '.') { -// if (r_error) { -// *r_error = TTR("Package segments must be of non-zero length."); -// } -// return false; -// } -// if (c == '.') { -// segments++; -// first = true; -// continue; -// } -// if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) { -// if (r_error) { -// *r_error = vformat(TTR("The character '%s' is not allowed in Android application package names."), String::chr(c)); -// } -// return false; -// } -// if (first && (c >= '0' && c <= '9')) { -// if (r_error) { -// *r_error = TTR("A digit cannot be the first character in a package segment."); -// } -// return false; -// } -// if (first && c == '_') { -// if (r_error) { -// *r_error = vformat(TTR("The character '%s' cannot be the first character in a package segment."), String::chr(c)); -// } -// return false; -// } -// first = false; -// } - -// if (segments == 0) { -// if (r_error) { -// *r_error = TTR("The package must have at least one '.' separator."); -// } -// return false; -// } - -// if (first) { -// if (r_error) { -// *r_error = TTR("Package segments must be of non-zero length."); -// } -// return false; -// } - -// return true; -// } - -// static bool _should_compress_asset(const String &p_path, const Vector &p_data) { -// /* -// * By not compressing files with little or not benefit in doing so, -// * a performance gain is expected attime. Moreover, if the APK is -// * zip-aligned, assets stored as they are can be efficiently read by -// * Android by memory-mapping them. -// */ - -// // -- Unconditional uncompress to mimic AAPT plus some other - -// static const char *unconditional_compress_ext[] = { -// // From https://github.com/android/platform_frameworks_base/blob/master/tools/aapt/Package.cpp -// // These formats are already compressed, or don't compress well: -// ".jpg", ".jpeg", ".png", ".gif", -// ".wav", ".mp2", ".mp3", ".ogg", ".aac", -// ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet", -// ".rtttl", ".imy", ".xmf", ".mp4", ".m4a", -// ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2", -// ".amr", ".awb", ".wma", ".wmv", -// // Godot-specific: -// ".webp", // Same reasoning as .png -// ".cfb", // Don't let small config files slow-down startup -// ".scn", // Binary scenes are usually already compressed -// ".stex", // Streamable textures are usually already compressed -// // Trailer for easier processing -// nullptr -// }; - -// for (const char **ext = unconditional_compress_ext; *ext; ++ext) { -// if (p_path.to_lower().ends_with(String(*ext))) { -// return false; -// } -// } - -// // -- Compressed resource? - -// if (p_data.size() >= 4 && p_data[0] == 'R' && p_data[1] == 'S' && p_data[2] == 'C' && p_data[3] == 'C') { -// // Already compressed -// return false; -// } - -// // --- TODO: Decide on texture resources according to their image compression setting - -// return true; -// } - -// static zip_fileinfo get_zip_fileinfo() { -// OS::Time time = OS::get_singleton()->get_time(); -// OS::Date date = OS::get_singleton()->get_date(); - -// zip_fileinfo zipfi; -// zipfi.tmz_date.tm_hour = time.hour; -// zipfi.tmz_date.tm_mday = date.day; -// zipfi.tmz_date.tm_min = time.min; -// zipfi.tmz_date.tm_mon = date.month - 1; // tm_mon is zero indexed -// zipfi.tmz_date.tm_sec = time.sec; -// zipfi.tmz_date.tm_year = date.year; -// zipfi.dosDate = 0; -// zipfi.external_fa = 0; -// zipfi.internal_fa = 0; - -// return zipfi; -// } - -// static Vector get_abis() { -// Vector abis; -// abis.push_back("armeabi-v7a"); -// abis.push_back("arm64-v8a"); -// abis.push_back("x86"); -// abis.push_back("x86_64"); -// return abis; -// } - -// /// List the gdap files in the directory specified by the p_path parameter. -// static Vector list_gdap_files(const String &p_path) { -// Vector dir_files; -// DirAccessRef da = DirAccess::open(p_path); -// if (da) { -// da->list_dir_begin(); -// while (true) { -// String file = da->get_next(); -// if (file == "") { -// break; -// } - -// if (da->current_is_dir() || da->current_is_hidden()) { -// continue; -// } - -// if (file.ends_with(PLUGIN_CONFIG_EXT)) { -// dir_files.push_back(file); -// } -// } -// da->list_dir_end(); -// } - -// return dir_files; -// } - -// static Vector get_plugins() { -// Vector loaded_plugins; - -// String plugins_dir = ProjectSettings::get_singleton()->get_resource_path().plus_file("android/plugins"); - -// // Add the prebuilt plugins -// loaded_plugins.append_array(get_prebuilt_plugins(plugins_dir)); - -// if (DirAccess::exists(plugins_dir)) { -// Vector plugins_filenames = list_gdap_files(plugins_dir); - -// if (!plugins_filenames.is_empty()) { -// Ref config_file = memnew(ConfigFile); -// for (int i = 0; i < plugins_filenames.size(); i++) { -// PluginConfig config = load_plugin_config(config_file, plugins_dir.plus_file(plugins_filenames[i])); -// if (config.valid_config) { -// loaded_plugins.push_back(config); -// } else { -// print_error("Invalid plugin config file " + plugins_filenames[i]); -// } -// } -// } -// } - -// return loaded_plugins; -// } - -// static Vector get_enabled_plugins(const Ref &p_presets) { -// Vector enabled_plugins; -// Vector all_plugins = get_plugins(); -// for (int i = 0; i < all_plugins.size(); i++) { -// PluginConfig plugin = all_plugins[i]; -// bool enabled = p_presets->get("plugins/" + plugin.name); -// if (enabled) { -// enabled_plugins.push_back(plugin); -// } -// } - -// return enabled_plugins; -// } - -// static Error store_in_apk(APKExportData *ed, const String &p_path, const Vector &p_data, int compression_method = Z_DEFLATED) { -// zip_fileinfo zipfi = get_zip_fileinfo(); -// zipOpenNewFileInZip(ed->apk, -// p_path.utf8().get_data(), -// &zipfi, -// nullptr, -// 0, -// nullptr, -// 0, -// nullptr, -// compression_method, -// Z_DEFAULT_COMPRESSION); - -// zipWriteInFileInZip(ed->apk, p_data.ptr(), p_data.size()); -// zipCloseFileInZip(ed->apk); - -// return OK; -// } - -// static Error save_apk_so(void *p_userdata, const SharedObject &p_so) { -// if (!p_so.path.get_file().begins_with("lib")) { -// String err = "Android .so file names must start with \"lib\", but got: " + p_so.path; -// ERR_PRINT(err); -// return FAILED; -// } -// APKExportData *ed = (APKExportData *)p_userdata; -// Vector abis = get_abis(); -// bool exported = false; -// for (int i = 0; i < p_so.tags.size(); ++i) { -// // shared objects can be fat (compatible with multiple ABIs) -// int abi_index = abis.find(p_so.tags[i]); -// if (abi_index != -1) { -// exported = true; -// String abi = abis[abi_index]; -// String dst_path = String("lib").plus_file(abi).plus_file(p_so.path.get_file()); -// Vector array = FileAccess::get_file_as_array(p_so.path); -// Error store_err = store_in_apk(ed, dst_path, array); -// ERR_FAIL_COND_V_MSG(store_err, store_err, "Cannot store in apk file '" + dst_path + "'."); -// } -// } -// if (!exported) { -// String abis_string = String(" ").join(abis); -// String err = "Cannot determine ABI for library \"" + p_so.path + "\". One of the supported ABIs must be used as a tag: " + abis_string; -// ERR_PRINT(err); -// return FAILED; -// } -// return OK; -// } - -// static Error save_apk_file(void *p_userdata, const String &p_path, const Vector &p_data, int p_file, int p_total, const Vector &p_enc_in_filters, const Vector &p_enc_ex_filters, const Vector &p_key) { -// APKExportData *ed = (APKExportData *)p_userdata; -// String dst_path = p_path.replace_first("res://", "assets/"); - -// store_in_apk(ed, dst_path, p_data, _should_compress_asset(p_path, p_data) ? Z_DEFLATED : 0); -// return OK; -// } - -// static Error ignore_apk_file(void *p_userdata, const String &p_path, const Vector &p_data, int p_file, int p_total, const Vector &p_enc_in_filters, const Vector &p_enc_ex_filters, const Vector &p_key) { -// return OK; -// } - -// void _get_permissions(const Ref &p_preset, bool p_give_internet, Vector &r_permissions) { -// const char **aperms = android_perms; -// while (*aperms) { -// bool enabled = p_preset->get("permissions/" + String(*aperms).to_lower()); -// if (enabled) { -// r_permissions.push_back("android.permission." + String(*aperms)); -// } -// aperms++; -// } -// PackedStringArray user_perms = p_preset->get("permissions/custom_permissions"); -// for (int i = 0; i < user_perms.size(); i++) { -// String user_perm = user_perms[i].strip_edges(); -// if (!user_perm.is_empty()) { -// r_permissions.push_back(user_perm); -// } -// } -// if (p_give_internet) { -// if (r_permissions.find("android.permission.INTERNET") == -1) { -// r_permissions.push_back("android.permission.INTERNET"); -// } -// } - -// int xr_mode_index = p_preset->get("xr_features/xr_mode"); -// if (xr_mode_index == 1 /* XRMode.OVR */) { -// int hand_tracking_index = p_preset->get("xr_features/hand_tracking"); // 0: none, 1: optional, 2: required -// if (hand_tracking_index > 0) { -// if (r_permissions.find("com.oculus.permission.HAND_TRACKING") == -1) { -// r_permissions.push_back("com.oculus.permission.HAND_TRACKING"); -// } -// } -// } -// } - -// void _write_tmp_manifest(const Ref &p_preset, bool p_give_internet, bool p_debug) { -// String manifest_text = -// "\n" -// "\n"; - -// manifest_text += _get_screen_sizes_tag(p_preset); -// manifest_text += _get_gles_tag(); - -// Vector perms; -// _get_permissions(p_preset, p_give_internet, perms); -// for (int i = 0; i < perms.size(); i++) { -// manifest_text += vformat(" \n", perms.get(i)); -// } - -// manifest_text += _get_xr_features_tag(p_preset); -// manifest_text += _get_instrumentation_tag(p_preset); -// String plugins_names = get_plugins_names(get_enabled_plugins(p_preset)); -// manifest_text += _get_application_tag(p_preset, plugins_names); -// manifest_text += "\n"; -// String manifest_path = vformat("res://android/build/src/%s/AndroidManifest.xml", (p_debug ? "debug" : "release")); -// store_string_at_path(manifest_path, manifest_text); -// } - -// void _fix_manifest(const Ref &p_preset, Vector &p_manifest, bool p_give_internet) { -// // Leaving the unused types commented because looking these constants up -// // again later would be annoying -// // const int CHUNK_AXML_FILE = 0x00080003; -// // const int CHUNK_RESOURCEIDS = 0x00080180; -// const int CHUNK_STRINGS = 0x001C0001; -// // const int CHUNK_XML_END_NAMESPACE = 0x00100101; -// const int CHUNK_XML_END_TAG = 0x00100103; -// // const int CHUNK_XML_START_NAMESPACE = 0x00100100; -// const int CHUNK_XML_START_TAG = 0x00100102; -// // const int CHUNK_XML_TEXT = 0x00100104; -// const int UTF8_FLAG = 0x00000100; - -// Vector string_table; - -// uint32_t ofs = 8; - -// uint32_t string_count = 0; -// //uint32_t styles_count = 0; -// uint32_t string_flags = 0; -// uint32_t string_data_offset = 0; - -// //uint32_t styles_offset = 0; -// uint32_t string_table_begins = 0; -// uint32_t string_table_ends = 0; -// Vector stable_extra; - -// String version_name = p_preset->get("version/name"); -// int version_code = p_preset->get("version/code"); -// String package_name = p_preset->get("package/unique_name"); - -// const int screen_orientation = _get_android_orientation_value(_get_screen_orientation()); - -// bool screen_support_small = p_preset->get("screen/support_small"); -// bool screen_support_normal = p_preset->get("screen/support_normal"); -// bool screen_support_large = p_preset->get("screen/support_large"); -// bool screen_support_xlarge = p_preset->get("screen/support_xlarge"); - -// int xr_mode_index = p_preset->get("xr_features/xr_mode"); -// bool focus_awareness = p_preset->get("xr_features/focus_awareness"); - -// String plugins_names = get_plugins_names(get_enabled_plugins(p_preset)); - -// Vector perms; -// // Write permissions into the perms variable. -// _get_permissions(p_preset, p_give_internet, perms); - -// while (ofs < (uint32_t)p_manifest.size()) { -// uint32_t chunk = decode_uint32(&p_manifest[ofs]); -// uint32_t size = decode_uint32(&p_manifest[ofs + 4]); - -// switch (chunk) { -// case CHUNK_STRINGS: { -// int iofs = ofs + 8; - -// string_count = decode_uint32(&p_manifest[iofs]); -// //styles_count = decode_uint32(&p_manifest[iofs + 4]); -// string_flags = decode_uint32(&p_manifest[iofs + 8]); -// string_data_offset = decode_uint32(&p_manifest[iofs + 12]); -// //styles_offset = decode_uint32(&p_manifest[iofs + 16]); -// /* -// printf("string count: %i\n",string_count); -// printf("flags: %i\n",string_flags); -// printf("sdata ofs: %i\n",string_data_offset); -// printf("styles ofs: %i\n",styles_offset); -// */ -// uint32_t st_offset = iofs + 20; -// string_table.resize(string_count); -// uint32_t string_end = 0; - -// string_table_begins = st_offset; - -// for (uint32_t i = 0; i < string_count; i++) { -// uint32_t string_at = decode_uint32(&p_manifest[st_offset + i * 4]); -// string_at += st_offset + string_count * 4; - -// ERR_FAIL_COND_MSG(string_flags & UTF8_FLAG, "Unimplemented, can't read UTF-8 string table."); - -// if (string_flags & UTF8_FLAG) { -// } else { -// uint32_t len = decode_uint16(&p_manifest[string_at]); -// Vector ucstring; -// ucstring.resize(len + 1); -// for (uint32_t j = 0; j < len; j++) { -// uint16_t c = decode_uint16(&p_manifest[string_at + 2 + 2 * j]); -// ucstring.write[j] = c; -// } -// string_end = MAX(string_at + 2 + 2 * len, string_end); -// ucstring.write[len] = 0; -// string_table.write[i] = ucstring.ptr(); -// } -// } - -// for (uint32_t i = string_end; i < (ofs + size); i++) { -// stable_extra.push_back(p_manifest[i]); -// } - -// string_table_ends = ofs + size; - -// } break; -// case CHUNK_XML_START_TAG: { -// int iofs = ofs + 8; -// uint32_t name = decode_uint32(&p_manifest[iofs + 12]); - -// String tname = string_table[name]; -// uint32_t attrcount = decode_uint32(&p_manifest[iofs + 20]); -// iofs += 28; -// bool is_focus_aware_metadata = false; - -// for (uint32_t i = 0; i < attrcount; i++) { -// uint32_t attr_nspace = decode_uint32(&p_manifest[iofs]); -// uint32_t attr_name = decode_uint32(&p_manifest[iofs + 4]); -// uint32_t attr_value = decode_uint32(&p_manifest[iofs + 8]); -// uint32_t attr_resid = decode_uint32(&p_manifest[iofs + 16]); - -// const String value = (attr_value != 0xFFFFFFFF) ? string_table[attr_value] : "Res #" + itos(attr_resid); -// String attrname = string_table[attr_name]; -// const String nspace = (attr_nspace != 0xFFFFFFFF) ? string_table[attr_nspace] : ""; - -// //replace project information -// if (tname == "manifest" && attrname == "package") { -// string_table.write[attr_value] = get_package_name(package_name); -// } - -// if (tname == "manifest" && attrname == "versionCode") { -// encode_uint32(version_code, &p_manifest.write[iofs + 16]); -// } - -// if (tname == "manifest" && attrname == "versionName") { -// if (attr_value == 0xFFFFFFFF) { -// WARN_PRINT("Version name in a resource, should be plain text"); -// } else { -// string_table.write[attr_value] = version_name; -// } -// } - -// if (tname == "instrumentation" && attrname == "targetPackage") { -// string_table.write[attr_value] = get_package_name(package_name); -// } - -// if (tname == "activity" && attrname == "screenOrientation") { -// encode_uint32(screen_orientation, &p_manifest.write[iofs + 16]); -// } - -// if (tname == "supports-screens") { -// if (attrname == "smallScreens") { -// encode_uint32(screen_support_small ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); - -// } else if (attrname == "normalScreens") { -// encode_uint32(screen_support_normal ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); - -// } else if (attrname == "largeScreens") { -// encode_uint32(screen_support_large ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); - -// } else if (attrname == "xlargeScreens") { -// encode_uint32(screen_support_xlarge ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); -// } -// } - -// // FIXME: `attr_value != 0xFFFFFFFF` below added as a stopgap measure for GH-32553, -// // but the issue should be debugged further and properly addressed. -// if (tname == "meta-data" && attrname == "name" && value == "xr_mode_metadata_name") { -// // Update the meta-data 'android:name' attribute based on the selected XR mode. -// if (xr_mode_index == 1 /* XRMode.OVR */) { -// string_table.write[attr_value] = "com.samsung.android.vr.application.mode"; -// } -// } - -// if (tname == "meta-data" && attrname == "value" && value == "xr_mode_metadata_value") { -// // Update the meta-data 'android:value' attribute based on the selected XR mode. -// if (xr_mode_index == 1 /* XRMode.OVR */) { -// string_table.write[attr_value] = "vr_only"; -// } -// } - -// if (tname == "meta-data" && attrname == "value" && is_focus_aware_metadata) { -// // Update the focus awareness meta-data value -// encode_uint32(xr_mode_index == /* XRMode.OVR */ 1 && focus_awareness ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); -// } - -// if (tname == "meta-data" && attrname == "value" && value == "plugins_value" && !plugins_names.is_empty()) { -// // Update the meta-data 'android:value' attribute with the list of enabled plugins. -// string_table.write[attr_value] = plugins_names; -// } - -// is_focus_aware_metadata = tname == "meta-data" && attrname == "name" && value == "com.oculus.vr.focusaware"; -// iofs += 20; -// } - -// } break; -// case CHUNK_XML_END_TAG: { -// int iofs = ofs + 8; -// uint32_t name = decode_uint32(&p_manifest[iofs + 12]); -// String tname = string_table[name]; - -// if (tname == "uses-feature") { -// Vector feature_names; -// Vector feature_required_list; -// Vector feature_versions; - -// if (xr_mode_index == 1 /* XRMode.OVR */) { -// // Check for degrees of freedom -// int dof_index = p_preset->get("xr_features/degrees_of_freedom"); // 0: none, 1: 3dof and 6dof, 2: 6dof - -// if (dof_index > 0) { -// feature_names.push_back("android.hardware.vr.headtracking"); -// feature_required_list.push_back(dof_index == 2); -// feature_versions.push_back(1); -// } - -// // Check for hand tracking -// int hand_tracking_index = p_preset->get("xr_features/hand_tracking"); // 0: none, 1: optional, 2: required -// if (hand_tracking_index > 0) { -// feature_names.push_back("oculus.software.handtracking"); -// feature_required_list.push_back(hand_tracking_index == 2); -// feature_versions.push_back(-1); // no version attribute should be added. -// } -// } - -// if (feature_names.size() > 0) { -// ofs += 24; // skip over end tag - -// // save manifest ending so we can restore it -// Vector manifest_end; -// uint32_t manifest_cur_size = p_manifest.size(); - -// manifest_end.resize(p_manifest.size() - ofs); -// memcpy(manifest_end.ptrw(), &p_manifest[ofs], manifest_end.size()); - -// int32_t attr_name_string = string_table.find("name"); -// ERR_FAIL_COND_MSG(attr_name_string == -1, "Template does not have 'name' attribute."); - -// int32_t ns_android_string = string_table.find("http://schemas.android.com/apk/res/android"); -// if (ns_android_string == -1) { -// string_table.push_back("http://schemas.android.com/apk/res/android"); -// ns_android_string = string_table.size() - 1; -// } - -// int32_t attr_uses_feature_string = string_table.find("uses-feature"); -// if (attr_uses_feature_string == -1) { -// string_table.push_back("uses-feature"); -// attr_uses_feature_string = string_table.size() - 1; -// } - -// int32_t attr_required_string = string_table.find("required"); -// if (attr_required_string == -1) { -// string_table.push_back("required"); -// attr_required_string = string_table.size() - 1; -// } - -// for (int i = 0; i < feature_names.size(); i++) { -// String feature_name = feature_names[i]; -// bool feature_required = feature_required_list[i]; -// int feature_version = feature_versions[i]; -// bool has_version_attribute = feature_version != -1; - -// print_line("Adding feature " + feature_name); - -// int32_t feature_string = string_table.find(feature_name); -// if (feature_string == -1) { -// string_table.push_back(feature_name); -// feature_string = string_table.size() - 1; -// } - -// String required_value_string = feature_required ? "true" : "false"; -// int32_t required_value = string_table.find(required_value_string); -// if (required_value == -1) { -// string_table.push_back(required_value_string); -// required_value = string_table.size() - 1; -// } - -// int32_t attr_version_string = -1; -// int32_t version_value = -1; -// int tag_size; -// int attr_count; -// if (has_version_attribute) { -// attr_version_string = string_table.find("version"); -// if (attr_version_string == -1) { -// string_table.push_back("version"); -// attr_version_string = string_table.size() - 1; -// } - -// version_value = string_table.find(itos(feature_version)); -// if (version_value == -1) { -// string_table.push_back(itos(feature_version)); -// version_value = string_table.size() - 1; -// } - -// tag_size = 96; // node and three attrs + end node -// attr_count = 3; -// } else { -// tag_size = 76; // node and two attrs + end node -// attr_count = 2; -// } -// manifest_cur_size += tag_size + 24; -// p_manifest.resize(manifest_cur_size); - -// // start tag -// encode_uint16(0x102, &p_manifest.write[ofs]); // type -// encode_uint16(16, &p_manifest.write[ofs + 2]); // headersize -// encode_uint32(tag_size, &p_manifest.write[ofs + 4]); // size -// encode_uint32(0, &p_manifest.write[ofs + 8]); // lineno -// encode_uint32(-1, &p_manifest.write[ofs + 12]); // comment -// encode_uint32(-1, &p_manifest.write[ofs + 16]); // ns -// encode_uint32(attr_uses_feature_string, &p_manifest.write[ofs + 20]); // name -// encode_uint16(20, &p_manifest.write[ofs + 24]); // attr_start -// encode_uint16(20, &p_manifest.write[ofs + 26]); // attr_size -// encode_uint16(attr_count, &p_manifest.write[ofs + 28]); // num_attrs -// encode_uint16(0, &p_manifest.write[ofs + 30]); // id_index -// encode_uint16(0, &p_manifest.write[ofs + 32]); // class_index -// encode_uint16(0, &p_manifest.write[ofs + 34]); // style_index - -// // android:name attribute -// encode_uint32(ns_android_string, &p_manifest.write[ofs + 36]); // ns -// encode_uint32(attr_name_string, &p_manifest.write[ofs + 40]); // 'name' -// encode_uint32(feature_string, &p_manifest.write[ofs + 44]); // raw_value -// encode_uint16(8, &p_manifest.write[ofs + 48]); // typedvalue_size -// p_manifest.write[ofs + 50] = 0; // typedvalue_always0 -// p_manifest.write[ofs + 51] = 0x03; // typedvalue_type (string) -// encode_uint32(feature_string, &p_manifest.write[ofs + 52]); // typedvalue reference - -// // android:required attribute -// encode_uint32(ns_android_string, &p_manifest.write[ofs + 56]); // ns -// encode_uint32(attr_required_string, &p_manifest.write[ofs + 60]); // 'name' -// encode_uint32(required_value, &p_manifest.write[ofs + 64]); // raw_value -// encode_uint16(8, &p_manifest.write[ofs + 68]); // typedvalue_size -// p_manifest.write[ofs + 70] = 0; // typedvalue_always0 -// p_manifest.write[ofs + 71] = 0x03; // typedvalue_type (string) -// encode_uint32(required_value, &p_manifest.write[ofs + 72]); // typedvalue reference - -// ofs += 76; - -// if (has_version_attribute) { -// // android:version attribute -// encode_uint32(ns_android_string, &p_manifest.write[ofs]); // ns -// encode_uint32(attr_version_string, &p_manifest.write[ofs + 4]); // 'name' -// encode_uint32(version_value, &p_manifest.write[ofs + 8]); // raw_value -// encode_uint16(8, &p_manifest.write[ofs + 12]); // typedvalue_size -// p_manifest.write[ofs + 14] = 0; // typedvalue_always0 -// p_manifest.write[ofs + 15] = 0x03; // typedvalue_type (string) -// encode_uint32(version_value, &p_manifest.write[ofs + 16]); // typedvalue reference - -// ofs += 20; -// } - -// // end tag -// encode_uint16(0x103, &p_manifest.write[ofs]); // type -// encode_uint16(16, &p_manifest.write[ofs + 2]); // headersize -// encode_uint32(24, &p_manifest.write[ofs + 4]); // size -// encode_uint32(0, &p_manifest.write[ofs + 8]); // lineno -// encode_uint32(-1, &p_manifest.write[ofs + 12]); // comment -// encode_uint32(-1, &p_manifest.write[ofs + 16]); // ns -// encode_uint32(attr_uses_feature_string, &p_manifest.write[ofs + 20]); // name - -// ofs += 24; -// } -// memcpy(&p_manifest.write[ofs], manifest_end.ptr(), manifest_end.size()); -// ofs -= 24; // go back over back end -// } -// } -// if (tname == "manifest") { -// // save manifest ending so we can restore it -// Vector manifest_end; -// uint32_t manifest_cur_size = p_manifest.size(); - -// manifest_end.resize(p_manifest.size() - ofs); -// memcpy(manifest_end.ptrw(), &p_manifest[ofs], manifest_end.size()); - -// int32_t attr_name_string = string_table.find("name"); -// ERR_FAIL_COND_MSG(attr_name_string == -1, "Template does not have 'name' attribute."); - -// int32_t ns_android_string = string_table.find("android"); -// ERR_FAIL_COND_MSG(ns_android_string == -1, "Template does not have 'android' namespace."); - -// int32_t attr_uses_permission_string = string_table.find("uses-permission"); -// if (attr_uses_permission_string == -1) { -// string_table.push_back("uses-permission"); -// attr_uses_permission_string = string_table.size() - 1; -// } - -// for (int i = 0; i < perms.size(); ++i) { -// print_line("Adding permission " + perms[i]); - -// manifest_cur_size += 56 + 24; // node + end node -// p_manifest.resize(manifest_cur_size); - -// // Add permission to the string pool -// int32_t perm_string = string_table.find(perms[i]); -// if (perm_string == -1) { -// string_table.push_back(perms[i]); -// perm_string = string_table.size() - 1; -// } - -// // start tag -// encode_uint16(0x102, &p_manifest.write[ofs]); // type -// encode_uint16(16, &p_manifest.write[ofs + 2]); // headersize -// encode_uint32(56, &p_manifest.write[ofs + 4]); // size -// encode_uint32(0, &p_manifest.write[ofs + 8]); // lineno -// encode_uint32(-1, &p_manifest.write[ofs + 12]); // comment -// encode_uint32(-1, &p_manifest.write[ofs + 16]); // ns -// encode_uint32(attr_uses_permission_string, &p_manifest.write[ofs + 20]); // name -// encode_uint16(20, &p_manifest.write[ofs + 24]); // attr_start -// encode_uint16(20, &p_manifest.write[ofs + 26]); // attr_size -// encode_uint16(1, &p_manifest.write[ofs + 28]); // num_attrs -// encode_uint16(0, &p_manifest.write[ofs + 30]); // id_index -// encode_uint16(0, &p_manifest.write[ofs + 32]); // class_index -// encode_uint16(0, &p_manifest.write[ofs + 34]); // style_index - -// // attribute -// encode_uint32(ns_android_string, &p_manifest.write[ofs + 36]); // ns -// encode_uint32(attr_name_string, &p_manifest.write[ofs + 40]); // 'name' -// encode_uint32(perm_string, &p_manifest.write[ofs + 44]); // raw_value -// encode_uint16(8, &p_manifest.write[ofs + 48]); // typedvalue_size -// p_manifest.write[ofs + 50] = 0; // typedvalue_always0 -// p_manifest.write[ofs + 51] = 0x03; // typedvalue_type (string) -// encode_uint32(perm_string, &p_manifest.write[ofs + 52]); // typedvalue reference - -// ofs += 56; - -// // end tag -// encode_uint16(0x103, &p_manifest.write[ofs]); // type -// encode_uint16(16, &p_manifest.write[ofs + 2]); // headersize -// encode_uint32(24, &p_manifest.write[ofs + 4]); // size -// encode_uint32(0, &p_manifest.write[ofs + 8]); // lineno -// encode_uint32(-1, &p_manifest.write[ofs + 12]); // comment -// encode_uint32(-1, &p_manifest.write[ofs + 16]); // ns -// encode_uint32(attr_uses_permission_string, &p_manifest.write[ofs + 20]); // name - -// ofs += 24; -// } - -// // copy footer back in -// memcpy(&p_manifest.write[ofs], manifest_end.ptr(), manifest_end.size()); -// } -// } break; -// } - -// ofs += size; -// } - -// //create new andriodmanifest binary - -// Vector ret; -// ret.resize(string_table_begins + string_table.size() * 4); - -// for (uint32_t i = 0; i < string_table_begins; i++) { -// ret.write[i] = p_manifest[i]; -// } - -// ofs = 0; -// for (int i = 0; i < string_table.size(); i++) { -// encode_uint32(ofs, &ret.write[string_table_begins + i * 4]); -// ofs += string_table[i].length() * 2 + 2 + 2; -// } - -// ret.resize(ret.size() + ofs); -// string_data_offset = ret.size() - ofs; -// uint8_t *chars = &ret.write[string_data_offset]; -// for (int i = 0; i < string_table.size(); i++) { -// String s = string_table[i]; -// encode_uint16(s.length(), chars); -// chars += 2; -// for (int j = 0; j < s.length(); j++) { -// encode_uint16(s[j], chars); -// chars += 2; -// } -// encode_uint16(0, chars); -// chars += 2; -// } - -// for (int i = 0; i < stable_extra.size(); i++) { -// ret.push_back(stable_extra[i]); -// } - -// //pad -// while (ret.size() % 4) { -// ret.push_back(0); -// } - -// uint32_t new_stable_end = ret.size(); - -// uint32_t extra = (p_manifest.size() - string_table_ends); -// ret.resize(new_stable_end + extra); -// for (uint32_t i = 0; i < extra; i++) { -// ret.write[new_stable_end + i] = p_manifest[string_table_ends + i]; -// } - -// while (ret.size() % 4) { -// ret.push_back(0); -// } -// encode_uint32(ret.size(), &ret.write[4]); //update new file size - -// encode_uint32(new_stable_end - 8, &ret.write[12]); //update new string table size -// encode_uint32(string_table.size(), &ret.write[16]); //update new number of strings -// encode_uint32(string_data_offset - 8, &ret.write[28]); //update new string data offset - -// p_manifest = ret; -// } - -// static String _parse_string(const uint8_t *p_bytes, bool p_utf8) { -// uint32_t offset = 0; -// uint32_t len = 0; - -// if (p_utf8) { -// uint8_t byte = p_bytes[offset]; -// if (byte & 0x80) { -// offset += 2; -// } else { -// offset += 1; -// } -// byte = p_bytes[offset]; -// offset++; -// if (byte & 0x80) { -// len = byte & 0x7F; -// len = (len << 8) + p_bytes[offset]; -// offset++; -// } else { -// len = byte; -// } -// } else { -// len = decode_uint16(&p_bytes[offset]); -// offset += 2; -// if (len & 0x8000) { -// len &= 0x7FFF; -// len = (len << 16) + decode_uint16(&p_bytes[offset]); -// offset += 2; -// } -// } - -// if (p_utf8) { -// Vector str8; -// str8.resize(len + 1); -// for (uint32_t i = 0; i < len; i++) { -// str8.write[i] = p_bytes[offset + i]; -// } -// str8.write[len] = 0; -// String str; -// str.parse_utf8((const char *)str8.ptr()); -// return str; -// } else { -// String str; -// for (uint32_t i = 0; i < len; i++) { -// char32_t c = decode_uint16(&p_bytes[offset + i * 2]); -// if (c == 0) { -// break; -// } -// str += String::chr(c); -// } -// return str; -// } -// } - -// void _fix_resources(const Ref &p_preset, Vector &r_manifest) { -// const int UTF8_FLAG = 0x00000100; - -// uint32_t string_block_len = decode_uint32(&r_manifest[16]); -// uint32_t string_count = decode_uint32(&r_manifest[20]); -// uint32_t string_flags = decode_uint32(&r_manifest[28]); -// const uint32_t string_table_begins = 40; - -// Vector string_table; - -// String package_name = p_preset->get("package/name"); - -// for (uint32_t i = 0; i < string_count; i++) { -// uint32_t offset = decode_uint32(&r_manifest[string_table_begins + i * 4]); -// offset += string_table_begins + string_count * 4; - -// String str = _parse_string(&r_manifest[offset], string_flags & UTF8_FLAG); - -// if (str.begins_with("godot-project-name")) { -// if (str == "godot-project-name") { -// //project name -// str = get_project_name(package_name); - -// } else { -// String lang = str.substr(str.rfind("-") + 1, str.length()).replace("-", "_"); -// String prop = "application/config/name_" + lang; -// if (ProjectSettings::get_singleton()->has_setting(prop)) { -// str = ProjectSettings::get_singleton()->get(prop); -// } else { -// str = get_project_name(package_name); -// } -// } -// } - -// string_table.push_back(str); -// } - -// //write a new string table, but use 16 bits -// Vector ret; -// ret.resize(string_table_begins + string_table.size() * 4); - -// for (uint32_t i = 0; i < string_table_begins; i++) { -// ret.write[i] = r_manifest[i]; -// } - -// int ofs = 0; -// for (int i = 0; i < string_table.size(); i++) { -// encode_uint32(ofs, &ret.write[string_table_begins + i * 4]); -// ofs += string_table[i].length() * 2 + 2 + 2; -// } - -// ret.resize(ret.size() + ofs); -// uint8_t *chars = &ret.write[ret.size() - ofs]; -// for (int i = 0; i < string_table.size(); i++) { -// String s = string_table[i]; -// encode_uint16(s.length(), chars); -// chars += 2; -// for (int j = 0; j < s.length(); j++) { -// encode_uint16(s[j], chars); -// chars += 2; -// } -// encode_uint16(0, chars); -// chars += 2; -// } - -// //pad -// while (ret.size() % 4) { -// ret.push_back(0); -// } - -// //change flags to not use utf8 -// encode_uint32(string_flags & ~0x100, &ret.write[28]); -// //change length -// encode_uint32(ret.size() - 12, &ret.write[16]); -// //append the rest... -// int rest_from = 12 + string_block_len; -// int rest_to = ret.size(); -// int rest_len = (r_manifest.size() - rest_from); -// ret.resize(ret.size() + (r_manifest.size() - rest_from)); -// for (int i = 0; i < rest_len; i++) { -// ret.write[rest_to + i] = r_manifest[rest_from + i]; -// } -// //finally update the size -// encode_uint32(ret.size(), &ret.write[4]); - -// r_manifest = ret; -// //printf("end\n"); -// } - -// void _load_image_data(const Ref &p_splash_image, Vector &p_data) { -// Vector png_buffer; -// Error err = PNGDriverCommon::image_to_png(p_splash_image, png_buffer); -// if (err == OK) { -// p_data.resize(png_buffer.size()); -// memcpy(p_data.ptrw(), png_buffer.ptr(), p_data.size()); -// } else { -// String err_str = String("Failed to convert splash image to png."); -// WARN_PRINT(err_str.utf8().get_data()); -// } -// } - -// void _process_launcher_icons(const String &p_file_name, const Ref &p_source_image, int dimension, Vector &p_data) { -// Ref working_image = p_source_image; - -// if (p_source_image->get_width() != dimension || p_source_image->get_height() != dimension) { -// working_image = p_source_image->duplicate(); -// working_image->resize(dimension, dimension, Image::Interpolation::INTERPOLATE_LANCZOS); -// } - -// Vector png_buffer; -// Error err = PNGDriverCommon::image_to_png(working_image, png_buffer); -// if (err == OK) { -// p_data.resize(png_buffer.size()); -// memcpy(p_data.ptrw(), png_buffer.ptr(), p_data.size()); -// } else { -// String err_str = String("Failed to convert resized icon (") + p_file_name + ") to png."; -// WARN_PRINT(err_str.utf8().get_data()); -// } -// } - -// void load_splash_refs(Ref &splash_image, Ref &splash_bg_color_image) { -// // TODO: Figure out how to handle remaining boot splash parameters (e.g: fullsize, filter) -// String project_splash_path = ProjectSettings::get_singleton()->get("application/boot_splash/image"); - -// if (!project_splash_path.is_empty()) { -// splash_image.instance(); -// const Error err = ImageLoader::load_image(project_splash_path, splash_image); -// if (err) { -// splash_image.unref(); -// } -// } - -// if (splash_image.is_null()) { -// // Use the default -// splash_image = Ref(memnew(Image(boot_splash_png))); -// } - -// // Setup the splash bg color -// bool bg_color_valid; -// Color bg_color = ProjectSettings::get_singleton()->get("application/boot_splash/bg_color", &bg_color_valid); -// if (!bg_color_valid) { -// bg_color = boot_splash_bg_color; -// } - -// splash_bg_color_image.instance(); -// splash_bg_color_image->create(splash_image->get_width(), splash_image->get_height(), false, splash_image->get_format()); -// splash_bg_color_image->fill(bg_color); -// } - -// void load_icon_refs(const Ref &p_preset, Ref &icon, Ref &foreground, Ref &background) { -// String project_icon_path = ProjectSettings::get_singleton()->get("application/config/icon"); - -// icon.instance(); -// foreground.instance(); -// background.instance(); - -// // Regular icon: user selection -> project icon -> default. -// String path = static_cast(p_preset->get(launcher_icon_option)).strip_edges(); -// if (path.is_empty() || ImageLoader::load_image(path, icon) != OK) { -// ImageLoader::load_image(project_icon_path, icon); -// } - -// // Adaptive foreground: user selection -> regular icon (user selection -> project icon -> default). -// path = static_cast(p_preset->get(launcher_adaptive_icon_foreground_option)).strip_edges(); -// if (path.is_empty() || ImageLoader::load_image(path, foreground) != OK) { -// foreground = icon; -// } - -// // Adaptive background: user selection -> default. -// path = static_cast(p_preset->get(launcher_adaptive_icon_background_option)).strip_edges(); -// if (!path.is_empty()) { -// ImageLoader::load_image(path, background); -// } -// } - -// void store_image(const LauncherIcon launcher_icon, const Vector &data) { -// store_image(launcher_icon.export_path, data); -// } - -// void store_image(const String &export_path, const Vector &data) { -// String img_path = export_path.insert(0, "res://android/build/"); -// store_file_at_path(img_path, data); -// } - -// void _copy_icons_to_gradle_project(const Ref &p_preset, -// const Ref &splash_image, -// const Ref &splash_bg_color_image, -// const Ref &main_image, -// const Ref &foreground, -// const Ref &background) { -// // Store the splash image -// if (splash_image.is_valid() && !splash_image->is_empty()) { -// Vector data; -// _load_image_data(splash_image, data); -// store_image(SPLASH_IMAGE_EXPORT_PATH, data); -// } - -// // Store the splash bg color image -// if (splash_bg_color_image.is_valid() && !splash_bg_color_image->is_empty()) { -// Vector data; -// _load_image_data(splash_bg_color_image, data); -// store_image(SPLASH_BG_COLOR_PATH, data); -// } - -// // Prepare images to be resized for the icons. If some image ends up being uninitialized, -// // the default image from the export template will be used. - -// for (int i = 0; i < icon_densities_count; ++i) { -// if (main_image.is_valid() && !main_image->is_empty()) { -// Vector data; -// _process_launcher_icons(launcher_icons[i].export_path, main_image, launcher_icons[i].dimensions, data); -// store_image(launcher_icons[i], data); -// } - -// if (foreground.is_valid() && !foreground->is_empty()) { -// Vector data; -// _process_launcher_icons(launcher_adaptive_icon_foregrounds[i].export_path, foreground, -// launcher_adaptive_icon_foregrounds[i].dimensions, data); -// store_image(launcher_adaptive_icon_foregrounds[i], data); -// } - -// if (background.is_valid() && !background->is_empty()) { -// Vector data; -// _process_launcher_icons(launcher_adaptive_icon_backgrounds[i].export_path, background, -// launcher_adaptive_icon_backgrounds[i].dimensions, data); -// store_image(launcher_adaptive_icon_backgrounds[i], data); -// } -// } -// } - -// static Vector get_enabled_abis(const Ref &p_preset) { -// Vector abis = get_abis(); -// Vector enabled_abis; -// for (int i = 0; i < abis.size(); ++i) { -// bool is_enabled = p_preset->get("architectures/" + abis[i]); -// if (is_enabled) { -// enabled_abis.push_back(abis[i]); -// } -// } -// return enabled_abis; -// } - -//public: -// typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector &p_data, int p_file, int p_total, const Vector &p_enc_in_filters, const Vector &p_enc_ex_filters, const Vector &p_key); - -//public: -// virtual void get_preset_features(const Ref &p_preset, List *r_features) override { -// String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name"); -// if (driver == "OpenGL") { -// r_features->push_back("etc"); -// } -// // FIXME: Review what texture formats are used for Vulkan. -// if (driver == "Vulkan") { -// r_features->push_back("etc2"); -// } - -// Vector abis = get_enabled_abis(p_preset); -// for (int i = 0; i < abis.size(); ++i) { -// r_features->push_back(abis[i]); -// } -// } - -// virtual void get_export_options(List *r_options) override { -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "custom_template/use_custom_build"), false)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "custom_template/export_format", PROPERTY_HINT_ENUM, "Export APK,Export AAB"), EXPORT_FORMAT_APK)); - -// Vector plugins_configs = get_plugins(); -// for (int i = 0; i < plugins_configs.size(); i++) { -// print_verbose("Found Android plugin " + plugins_configs[i].name); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "plugins/" + plugins_configs[i].name), false)); -// } -// plugins_changed = false; - -// Vector abis = get_abis(); -// for (int i = 0; i < abis.size(); ++i) { -// String abi = abis[i]; -// bool is_default = (abi == "armeabi-v7a" || abi == "arm64-v8a"); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architectures/" + abi), is_default)); -// } - -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/debug", PROPERTY_HINT_GLOBAL_FILE, "*.keystore,*.jks"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/debug_user"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/debug_password"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release", PROPERTY_HINT_GLOBAL_FILE, "*.keystore,*.jks"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release_user"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release_password"), "")); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "one_click_deploy/clear_previous_install"), false)); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,4096,1,or_greater"), 1)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "version/name"), "1.0")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "ext.domain.name"), "org.godotengine.$genname")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name [default if blank]"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/signed"), true)); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_icon_option, PROPERTY_HINT_FILE, "*.png"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_foreground_option, PROPERTY_HINT_FILE, "*.png"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_background_option, PROPERTY_HINT_FILE, "*.png"), "")); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/32_bits_framebuffer"), true)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/opengl_debug"), false)); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/xr_mode", PROPERTY_HINT_ENUM, "Regular,Oculus Mobile VR"), 0)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/degrees_of_freedom", PROPERTY_HINT_ENUM, "None,3DOF and 6DOF,6DOF"), 0)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/hand_tracking", PROPERTY_HINT_ENUM, "None,Optional,Required"), 0)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "xr_features/focus_awareness"), false)); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/immersive_mode"), true)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_small"), true)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_normal"), true)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_large"), true)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_xlarge"), true)); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), "")); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "apk_expansion/enable"), false)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "apk_expansion/SALT"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "apk_expansion/public_key", PROPERTY_HINT_MULTILINE_TEXT), "")); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "permissions/custom_permissions"), PackedStringArray())); - -// const char **perms = android_perms; -// while (*perms) { -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "permissions/" + String(*perms).to_lower()), false)); -// perms++; -// } -// } - -// virtual String get_name() const override { -// return "Android"; -// } - -// virtual String get_os_name() const override { -// return "Android"; -// } - -// virtual Ref get_logo() const override { -// return logo; -// } - -// virtual bool should_update_export_options() override { -// bool export_options_changed = plugins_changed; -// if (export_options_changed) { -// // don't clear unless we're reporting true, to avoid race -// plugins_changed = false; -// } -// return export_options_changed; -// } - -// virtual bool poll_export() override { -// bool dc = devices_changed; -// if (dc) { -// // don't clear unless we're reporting true, to avoid race -// devices_changed = false; -// } -// return dc; -// } - -// virtual int get_options_count() const override { -// MutexLock lock(device_lock); -// return devices.size(); -// } - -// virtual String get_options_tooltip() const override { -// return TTR("Select device from the list"); -// } - -// virtual String get_option_label(int p_index) const override { -// ERR_FAIL_INDEX_V(p_index, devices.size(), ""); -// MutexLock lock(device_lock); -// return devices[p_index].name; -// } - -// virtual String get_option_tooltip(int p_index) const override { -// ERR_FAIL_INDEX_V(p_index, devices.size(), ""); -// MutexLock lock(device_lock); -// String s = devices[p_index].description; -// if (devices.size() == 1) { -// // Tooltip will be: -// // Name -// // Description -// s = devices[p_index].name + "\n\n" + s; -// } -// return s; -// } - -// virtual Error run(const Ref &p_preset, int p_device, int p_debug_flags) override { -// ERR_FAIL_INDEX_V(p_device, devices.size(), ERR_INVALID_PARAMETER); - -// String can_export_error; -// bool can_export_missing_templates; -// if (!can_export(p_preset, can_export_error, can_export_missing_templates)) { -// EditorNode::add_io_error(can_export_error); -// return ERR_UNCONFIGURED; -// } - -// MutexLock lock(device_lock); - -// EditorProgress ep("run", "Running on " + devices[p_device].name, 3); - -// String adb = get_adb_path(); - -// // Export_temp APK. -// if (ep.step("Exporting APK...", 0)) { -// return ERR_SKIP; -// } - -// const bool use_remote = (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) || (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT); -// const bool use_reverse = devices[p_device].api_level >= 21; - -// if (use_reverse) { -// p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST; -// } - -// String tmp_export_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport.apk"); - -//#define CLEANUP_AND_RETURN(m_err) -// { -// DirAccess::remove_file_or_error(tmp_export_path); -// return m_err; -// } - -// // Export to temporary APK before sending to device. -// Error err = export_project_helper(p_preset, true, tmp_export_path, EXPORT_FORMAT_APK, true, p_debug_flags); - -// if (err != OK) { -// CLEANUP_AND_RETURN(err); -// } - -// List args; -// int rv; - -// bool remove_prev = p_preset->get("one_click_deploy/clear_previous_install"); -// String version_name = p_preset->get("version/name"); -// String package_name = p_preset->get("package/unique_name"); - -// if (remove_prev) { -// if (ep.step("Uninstalling...", 1)) { -// CLEANUP_AND_RETURN(ERR_SKIP); -// } - -// print_line("Uninstalling previous version: " + devices[p_device].name); - -// args.push_back("-s"); -// args.push_back(devices[p_device].id); -// args.push_back("uninstall"); -// args.push_back(get_package_name(package_name)); - -// err = OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); -// } - -// print_line("Installing to device (please wait...): " + devices[p_device].name); -// if (ep.step("Installing to device, please wait...", 2)) { -// CLEANUP_AND_RETURN(ERR_SKIP); -// } - -// args.clear(); -// args.push_back("-s"); -// args.push_back(devices[p_device].id); -// args.push_back("install"); -// args.push_back("-r"); -// args.push_back(tmp_export_path); - -// err = OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); -// if (err || rv != 0) { -// EditorNode::add_io_error("Could not install to device."); -// CLEANUP_AND_RETURN(ERR_CANT_CREATE); -// } - -// if (use_remote) { -// if (use_reverse) { -// static const char *const msg = "--- Device API >= 21; debugging over USB ---"; -// EditorNode::get_singleton()->get_log()->add_message(msg, EditorLog::MSG_TYPE_EDITOR); -// print_line(String(msg).to_upper()); - -// args.clear(); -// args.push_back("-s"); -// args.push_back(devices[p_device].id); -// args.push_back("reverse"); -// args.push_back("--remove-all"); -// OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); - -// if (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) { -// int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port"); -// args.clear(); -// args.push_back("-s"); -// args.push_back(devices[p_device].id); -// args.push_back("reverse"); -// args.push_back("tcp:" + itos(dbg_port)); -// args.push_back("tcp:" + itos(dbg_port)); - -// OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); -// print_line("Reverse result: " + itos(rv)); -// } - -// if (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT) { -// int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port"); - -// args.clear(); -// args.push_back("-s"); -// args.push_back(devices[p_device].id); -// args.push_back("reverse"); -// args.push_back("tcp:" + itos(fs_port)); -// args.push_back("tcp:" + itos(fs_port)); - -// err = OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); -// print_line("Reverse result2: " + itos(rv)); -// } -// } else { -// static const char *const msg = "--- Device API < 21; debugging over Wi-Fi ---"; -// EditorNode::get_singleton()->get_log()->add_message(msg, EditorLog::MSG_TYPE_EDITOR); -// print_line(String(msg).to_upper()); -// } -// } - -// if (ep.step("Running on device...", 3)) { -// CLEANUP_AND_RETURN(ERR_SKIP); -// } -// args.clear(); -// args.push_back("-s"); -// args.push_back(devices[p_device].id); -// args.push_back("shell"); -// args.push_back("am"); -// args.push_back("start"); -// if ((bool)EditorSettings::get_singleton()->get("export/android/force_system_user") && devices[p_device].api_level >= 17) { // Multi-user introduced in Android 17 -// args.push_back("--user"); -// args.push_back("0"); -// } -// args.push_back("-a"); -// args.push_back("android.intent.action.MAIN"); -// args.push_back("-n"); -// args.push_back(get_package_name(package_name) + "/com.godot.game.GodotApp"); - -// err = OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); -// if (err || rv != 0) { -// EditorNode::add_io_error("Could not execute on device."); -// CLEANUP_AND_RETURN(ERR_CANT_CREATE); -// } - -// CLEANUP_AND_RETURN(OK); -//#undef CLEANUP_AND_RETURN -// } - -// virtual Ref get_run_icon() const override { -// return run_icon; -// } - -// static String get_adb_path() { -// String exe_ext = ""; -// if (OS::get_singleton()->get_name() == "Windows") { -// exe_ext = ".exe"; -// } -// String sdk_path = EditorSettings::get_singleton()->get("export/android/android_sdk_path"); -// return sdk_path.plus_file("platform-tools/adb" + exe_ext); -// } - -// static String get_apksigner_path() { -// String exe_ext = ""; -// if (OS::get_singleton()->get_name() == "Windows") { -// exe_ext = ".bat"; -// } -// String apksigner_command_name = "apksigner" + exe_ext; -// String sdk_path = EditorSettings::get_singleton()->get("export/android/android_sdk_path"); -// String apksigner_path = ""; - -// Error errn; -// String build_tools_dir = sdk_path.plus_file("build-tools"); -// DirAccessRef da = DirAccess::open(build_tools_dir, &errn); -// if (errn != OK) { -// print_error("Unable to open Android 'build-tools' directory."); -// return apksigner_path; -// } - -// // There are additional versions directories we need to go through. -// da->list_dir_begin(); -// String sub_dir = da->get_next(); -// while (!sub_dir.is_empty()) { -// if (!sub_dir.begins_with(".") && da->current_is_dir()) { -// // Check if the tool is here. -// String tool_path = build_tools_dir.plus_file(sub_dir).plus_file(apksigner_command_name); -// if (FileAccess::exists(tool_path)) { -// apksigner_path = tool_path; -// break; -// } -// } -// sub_dir = da->get_next(); -// } -// da->list_dir_end(); - -// if (apksigner_path.is_empty()) { -// EditorNode::get_singleton()->show_warning(TTR("Unable to find the 'apksigner' tool.")); -// } - -// return apksigner_path; -// } - -// virtual bool can_export(const Ref &p_preset, String &r_error, bool &r_missing_templates) const override { -// String err; -// bool valid = false; - -// // Look for export templates (first official, and if defined custom templates). - -// if (!bool(p_preset->get("custom_template/use_custom_build"))) { -// String template_err; -// bool dvalid = false; -// bool rvalid = false; - -// if (p_preset->get("custom_template/debug") != "") { -// dvalid = FileAccess::exists(p_preset->get("custom_template/debug")); -// if (!dvalid) { -// template_err += TTR("Custom debug template not found.") + "\n"; -// } -// } else { -// dvalid = exists_export_template("android_debug.apk", &template_err); -// } - -// if (p_preset->get("custom_template/release") != "") { -// rvalid = FileAccess::exists(p_preset->get("custom_template/release")); -// if (!rvalid) { -// template_err += TTR("Custom release template not found.") + "\n"; -// } -// } else { -// rvalid = exists_export_template("android_release.apk", &template_err); -// } - -// valid = dvalid || rvalid; -// if (!valid) { -// err += template_err; -// } -// } else { -// valid = exists_export_template("android_source.zip", &err); - -// if (!FileAccess::exists("res://android/build/build.gradle")) { -// err += TTR("Android build template not installed in the project. Install it from the Project menu.") + "\n"; -// valid = false; -// } -// } -// r_missing_templates = !valid; - -// // Validate the rest of the configuration. - -// String dk = p_preset->get("keystore/debug"); - -// if (!FileAccess::exists(dk)) { -// dk = EditorSettings::get_singleton()->get("export/android/debug_keystore"); -// if (!FileAccess::exists(dk)) { -// valid = false; -// err += TTR("Debug keystore not configured in the Editor Settings nor in the preset.") + "\n"; -// } -// } - -// String rk = p_preset->get("keystore/release"); - -// if (!rk.is_empty() && !FileAccess::exists(rk)) { -// valid = false; -// err += TTR("Release keystore incorrectly configured in the export preset.") + "\n"; -// } - -// String sdk_path = EditorSettings::get_singleton()->get("export/android/android_sdk_path"); -// if (sdk_path == "") { -// err += TTR("A valid Android SDK path is required in Editor Settings.") + "\n"; -// valid = false; -// } else { -// Error errn; -// // Check for the platform-tools directory. -// DirAccessRef da = DirAccess::open(sdk_path.plus_file("platform-tools"), &errn); -// if (errn != OK) { -// err += TTR("Invalid Android SDK path in Editor Settings."); -// err += TTR("Missing 'platform-tools' directory!"); -// err += "\n"; -// valid = false; -// } - -// // Validate that adb is available -// String adb_path = get_adb_path(); -// if (!FileAccess::exists(adb_path)) { -// err += TTR("Unable to find Android SDK platform-tools' adb command."); -// err += TTR("Please check in the Android SDK directory specified in Editor Settings."); -// err += "\n"; -// valid = false; -// } - -// // Check for the build-tools directory. -// DirAccessRef build_tools_da = DirAccess::open(sdk_path.plus_file("build-tools"), &errn); -// if (errn != OK) { -// err += TTR("Invalid Android SDK path in Editor Settings."); -// err += TTR("Missing 'build-tools' directory!"); -// err += "\n"; -// valid = false; -// } - -// // Validate that apksigner is available -// String apksigner_path = get_apksigner_path(); -// if (!FileAccess::exists(apksigner_path)) { -// err += TTR("Unable to find Android SDK build-tools' apksigner command."); -// err += TTR("Please check in the Android SDK directory specified in Editor Settings."); -// err += "\n"; -// valid = false; -// } -// } - -// bool apk_expansion = p_preset->get("apk_expansion/enable"); - -// if (apk_expansion) { -// String apk_expansion_pkey = p_preset->get("apk_expansion/public_key"); - -// if (apk_expansion_pkey == "") { -// valid = false; - -// err += TTR("Invalid public key for APK expansion.") + "\n"; -// } -// } - -// String pn = p_preset->get("package/unique_name"); -// String pn_err; - -// if (!is_package_name_valid(get_package_name(pn), &pn_err)) { -// valid = false; -// err += TTR("Invalid package name:") + " " + pn_err + "\n"; -// } - -// String etc_error = test_etc2(); -// if (etc_error != String()) { -// valid = false; -// err += etc_error; -// } - -// // Ensure that `Use Custom Build` is enabled if a plugin is selected. -// String enabled_plugins_names = get_plugins_names(get_enabled_plugins(p_preset)); -// bool custom_build_enabled = p_preset->get("custom_template/use_custom_build"); -// if (!enabled_plugins_names.is_empty() && !custom_build_enabled) { -// valid = false; -// err += TTR("\"Use Custom Build\" must be enabled to use the plugins."); -// err += "\n"; -// } - -// // Validate the Xr features are properly populated -// int xr_mode_index = p_preset->get("xr_features/xr_mode"); -// int degrees_of_freedom = p_preset->get("xr_features/degrees_of_freedom"); -// int hand_tracking = p_preset->get("xr_features/hand_tracking"); -// bool focus_awareness = p_preset->get("xr_features/focus_awareness"); -// if (xr_mode_index != /* XRMode.OVR*/ 1) { -// if (degrees_of_freedom > 0) { -// valid = false; -// err += TTR("\"Degrees Of Freedom\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."); -// err += "\n"; -// } - -// if (hand_tracking > 0) { -// valid = false; -// err += TTR("\"Hand Tracking\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."); -// err += "\n"; -// } - -// if (focus_awareness) { -// valid = false; -// err += TTR("\"Focus Awareness\" is only valid when \"Xr Mode\" is \"Oculus Mobile VR\"."); -// err += "\n"; -// } -// } - -// if (int(p_preset->get("custom_template/export_format")) == EXPORT_FORMAT_AAB && -// !bool(p_preset->get("custom_template/use_custom_build"))) { -// valid = false; -// err += TTR("\"Export AAB\" is only valid when \"Use Custom Build\" is enabled."); -// err += "\n"; -// } - -// r_error = err; -// return valid; -// } - -// virtual List get_binary_extensions(const Ref &p_preset) const override { -// List list; -// list.push_back("apk"); -// list.push_back("aab"); -// return list; -// } - -// inline bool is_clean_build_required(Vector enabled_plugins) { -// String plugin_names = get_plugins_names(enabled_plugins); -// bool first_build = last_custom_build_time == 0; -// bool have_plugins_changed = false; - -// if (!first_build) { -// have_plugins_changed = plugin_names != last_plugin_names; -// if (!have_plugins_changed) { -// for (int i = 0; i < enabled_plugins.size(); i++) { -// if (enabled_plugins.get(i).last_updated > last_custom_build_time) { -// have_plugins_changed = true; -// break; -// } -// } -// } -// } - -// last_custom_build_time = OS::get_singleton()->get_unix_time(); -// last_plugin_names = plugin_names; - -// return have_plugins_changed || first_build; -// } - -// String get_apk_expansion_fullpath(const Ref &p_preset, const String &p_path) { -// int version_code = p_preset->get("version/code"); -// String package_name = p_preset->get("package/unique_name"); -// String apk_file_name = "main." + itos(version_code) + "." + get_package_name(package_name) + ".obb"; -// String fullpath = p_path.get_base_dir().plus_file(apk_file_name); -// return fullpath; -// } - -// Error save_apk_expansion_file(const Ref &p_preset, const String &p_path) { -// String fullpath = get_apk_expansion_fullpath(p_preset, p_path); -// Error err = save_pack(p_preset, fullpath); -// return err; -// } - -// void get_command_line_flags(const Ref &p_preset, const String &p_path, int p_flags, Vector &r_command_line_flags) { -// String cmdline = p_preset->get("command_line/extra_args"); -// Vector command_line_strings = cmdline.strip_edges().split(" "); -// for (int i = 0; i < command_line_strings.size(); i++) { -// if (command_line_strings[i].strip_edges().length() == 0) { -// command_line_strings.remove(i); -// i--; -// } -// } - -// gen_export_flags(command_line_strings, p_flags); - -// bool apk_expansion = p_preset->get("apk_expansion/enable"); -// if (apk_expansion) { -// String fullpath = get_apk_expansion_fullpath(p_preset, p_path); -// String apk_expansion_public_key = p_preset->get("apk_expansion/public_key"); - -// command_line_strings.push_back("--use_apk_expansion"); -// command_line_strings.push_back("--apk_expansion_md5"); -// command_line_strings.push_back(FileAccess::get_md5(fullpath)); -// command_line_strings.push_back("--apk_expansion_key"); -// command_line_strings.push_back(apk_expansion_public_key.strip_edges()); -// } - -// int xr_mode_index = p_preset->get("xr_features/xr_mode"); -// if (xr_mode_index == 1) { -// command_line_strings.push_back("--xr_mode_ovr"); -// } else { // XRMode.REGULAR is the default. -// command_line_strings.push_back("--xr_mode_regular"); -// } - -// bool use_32_bit_framebuffer = p_preset->get("graphics/32_bits_framebuffer"); -// if (use_32_bit_framebuffer) { -// command_line_strings.push_back("--use_depth_32"); -// } - -// bool immersive = p_preset->get("screen/immersive_mode"); -// if (immersive) { -// command_line_strings.push_back("--use_immersive"); -// } - -// bool debug_opengl = p_preset->get("graphics/opengl_debug"); -// if (debug_opengl) { -// command_line_strings.push_back("--debug_opengl"); -// } - -// if (command_line_strings.size()) { -// r_command_line_flags.resize(4); -// encode_uint32(command_line_strings.size(), &r_command_line_flags.write[0]); -// for (int i = 0; i < command_line_strings.size(); i++) { -// print_line(itos(i) + " param: " + command_line_strings[i]); -// CharString command_line_argument = command_line_strings[i].utf8(); -// int base = r_command_line_flags.size(); -// int length = command_line_argument.length(); -// if (length == 0) -// continue; -// r_command_line_flags.resize(base + 4 + length); -// encode_uint32(length, &r_command_line_flags.write[base]); -// copymem(&r_command_line_flags.write[base + 4], command_line_argument.ptr(), length); -// } -// } -// } - -// Error sign_apk(const Ref &p_preset, bool p_debug, const String &export_path, EditorProgress &ep) { -// int export_format = int(p_preset->get("custom_template/export_format")); -// String export_label = export_format == EXPORT_FORMAT_AAB ? "AAB" : "APK"; -// String release_keystore = p_preset->get("keystore/release"); -// String release_username = p_preset->get("keystore/release_user"); -// String release_password = p_preset->get("keystore/release_password"); - -// String apksigner = get_apksigner_path(); -// if (!FileAccess::exists(apksigner)) { -// EditorNode::add_io_error("'apksigner' could not be found.\nPlease check the command is available in the Android SDK build-tools directory.\nThe resulting " + export_label + " is unsigned."); -// return OK; -// } - -// String keystore; -// String password; -// String user; -// if (p_debug) { -// keystore = p_preset->get("keystore/debug"); -// password = p_preset->get("keystore/debug_password"); -// user = p_preset->get("keystore/debug_user"); - -// if (keystore.is_empty()) { -// keystore = EditorSettings::get_singleton()->get("export/android/debug_keystore"); -// password = EditorSettings::get_singleton()->get("export/android/debug_keystore_pass"); -// user = EditorSettings::get_singleton()->get("export/android/debug_keystore_user"); -// } - -// if (ep.step("Signing debug " + export_label + "...", 104)) { -// return ERR_SKIP; -// } - -// } else { -// keystore = release_keystore; -// password = release_password; -// user = release_username; - -// if (ep.step("Signing release " + export_label + "...", 104)) { -// return ERR_SKIP; -// } -// } - -// if (!FileAccess::exists(keystore)) { -// EditorNode::add_io_error("Could not find keystore, unable to export."); -// return ERR_FILE_CANT_OPEN; -// } - -// List args; -// args.push_back("sign"); -// args.push_back("--verbose"); -// args.push_back("--ks"); -// args.push_back(keystore); -// args.push_back("--ks-pass"); -// args.push_back("pass:" + password); -// args.push_back("--ks-key-alias"); -// args.push_back(user); -// args.push_back(export_path); -// int retval; -// OS::get_singleton()->execute(apksigner, args, true, NULL, NULL, &retval); -// if (retval) { -// EditorNode::add_io_error("'apksigner' returned with error #" + itos(retval)); -// return ERR_CANT_CREATE; -// } - -// if (ep.step("Verifying " + export_label + "...", 105)) { -// return ERR_SKIP; -// } - -// args.clear(); -// args.push_back("verify"); -// args.push_back("--verbose"); -// args.push_back(export_path); - -// OS::get_singleton()->execute(apksigner, args, true, NULL, NULL, &retval); -// if (retval) { -// EditorNode::add_io_error("'apksigner' verification of " + export_label + " failed."); -// return ERR_CANT_CREATE; -// } -// return OK; -// } - -// void _clear_assets_directory() { -// DirAccessRef da_res = DirAccess::create(DirAccess::ACCESS_RESOURCES); -// if (da_res->dir_exists("res://android/build/assets")) { -// DirAccessRef da_assets = DirAccess::open("res://android/build/assets"); -// da_assets->erase_contents_recursive(); -// da_res->remove("res://android/build/assets"); -// } -// } - -// virtual Error export_project(const Ref &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override { -// int export_format = int(p_preset->get("custom_template/export_format")); -// bool should_sign = p_preset->get("package/signed"); -// return export_project_helper(p_preset, p_debug, p_path, export_format, should_sign, p_flags); -// } - -// Error export_project_helper(const Ref &p_preset, bool p_debug, const String &p_path, int export_format, bool should_sign, int p_flags) { -// ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); - -// String src_apk; -// Error err; - -// EditorProgress ep("export", "Exporting for Android", 105, true); - -// bool use_custom_build = bool(p_preset->get("custom_template/use_custom_build")); -// bool p_give_internet = p_flags & (DEBUG_FLAG_DUMB_CLIENT | DEBUG_FLAG_REMOTE_DEBUG); -// bool apk_expansion = p_preset->get("apk_expansion/enable"); -// Vector enabled_abis = get_enabled_abis(p_preset); - -// Ref splash_image; -// Ref splash_bg_color_image; -// load_splash_refs(splash_image, splash_bg_color_image); - -// Ref main_image; -// Ref foreground; -// Ref background; - -// load_icon_refs(p_preset, main_image, foreground, background); - -// Vector command_line_flags; -// // Write command line flags into the command_line_flags variable. -// get_command_line_flags(p_preset, p_path, p_flags, command_line_flags); - -// if (export_format == EXPORT_FORMAT_AAB) { -// if (!p_path.ends_with(".aab")) { -// EditorNode::get_singleton()->show_warning(TTR("Invalid filename! Android App Bundle requires the *.aab extension.")); -// return ERR_UNCONFIGURED; -// } -// if (apk_expansion) { -// EditorNode::get_singleton()->show_warning(TTR("APK Expansion not compatible with Android App Bundle.")); -// return ERR_UNCONFIGURED; -// } -// } -// if (export_format == EXPORT_FORMAT_APK && !p_path.ends_with(".apk")) { -// EditorNode::get_singleton()->show_warning( -// TTR("Invalid filename! Android APK requires the *.apk extension.")); -// return ERR_UNCONFIGURED; -// } -// if (export_format > EXPORT_FORMAT_AAB || export_format < EXPORT_FORMAT_APK) { -// EditorNode::add_io_error("Unsupported export format!\n"); -// return ERR_UNCONFIGURED; //TODO: is this the right error? -// } - -// if (use_custom_build) { -// //test that installed build version is alright -// { -// FileAccessRef f = FileAccess::open("res://android/.build_version", FileAccess::READ); -// if (!f) { -// EditorNode::get_singleton()->show_warning(TTR("Trying to build from a custom built template, but no version info for it exists. Please reinstall from the 'Project' menu.")); -// return ERR_UNCONFIGURED; -// } -// String version = f->get_line().strip_edges(); -// f->close(); -// if (version != VERSION_FULL_CONFIG) { -// EditorNode::get_singleton()->show_warning(vformat(TTR("Android build version mismatch:\n Template installed: %s\n Godot Version: %s\nPlease reinstall Android build template from 'Project' menu."), version, VERSION_FULL_CONFIG)); -// return ERR_UNCONFIGURED; -// } -// } -// String sdk_path = EDITOR_GET("export/android/android_sdk_path"); -// ERR_FAIL_COND_V_MSG(sdk_path == "", ERR_UNCONFIGURED, "Android SDK path must be configured in Editor Settings at 'export/android/android_sdk_path'."); - -// // TODO: should we use "package/name" or "application/config/name"? -// String project_name = get_project_name(p_preset->get("package/name")); -// err = _create_project_name_strings_files(p_preset, project_name); //project name localization. -// if (err != OK) { -// EditorNode::add_io_error("Unable to overwrite res://android/build/res/*.xml files with project name"); -// } -// // Copies the project icon files into the appropriate Gradle project directory. -// _copy_icons_to_gradle_project(p_preset, splash_image, splash_bg_color_image, main_image, foreground, background); -// // Write an AndroidManifest.xml file into the Gradle project directory. -// _write_tmp_manifest(p_preset, p_give_internet, p_debug); - -// //stores all the project files inside the Gradle project directory. Also includes all ABIs -// _clear_assets_directory(); -// if (!apk_expansion) { -// err = export_project_files(p_preset, rename_and_store_file_in_gradle_project, NULL, ignore_so_file); -// if (err != OK) { -// EditorNode::add_io_error("Could not export project files to gradle project\n"); -// return err; -// } -// } else { -// err = save_apk_expansion_file(p_preset, p_path); -// if (err != OK) { -// EditorNode::add_io_error("Could not write expansion package file!"); -// return err; -// } -// } -// store_file_at_path("res://android/build/assets/_cl_", command_line_flags); - -// OS::get_singleton()->set_environment("ANDROID_HOME", sdk_path); //set and overwrite if required -// String build_command; - -//#ifdef WINDOWS_ENABLED -// build_command = "gradlew.bat"; -//#else -// build_command = "gradlew"; -//#endif - -// String build_path = ProjectSettings::get_singleton()->get_resource_path().plus_file("android/build"); -// build_command = build_path.plus_file(build_command); - -// String package_name = get_package_name(p_preset->get("package/unique_name")); -// String version_code = itos(p_preset->get("version/code")); -// String version_name = p_preset->get("version/name"); -// String enabled_abi_string = String("|").join(enabled_abis); -// String sign_flag = should_sign ? "true" : "false"; -// String zipalign_flag = "true"; - -// Vector enabled_plugins = get_enabled_plugins(p_preset); -// String local_plugins_binaries = get_plugins_binaries(BINARY_TYPE_LOCAL, enabled_plugins); -// String remote_plugins_binaries = get_plugins_binaries(BINARY_TYPE_REMOTE, enabled_plugins); -// String custom_maven_repos = get_plugins_custom_maven_repos(enabled_plugins); -// bool clean_build_required = is_clean_build_required(enabled_plugins); - -// List cmdline; -// if (clean_build_required) { -// cmdline.push_back("clean"); -// } - -// String build_type = p_debug ? "Debug" : "Release"; -// if (export_format == EXPORT_FORMAT_AAB) { -// String bundle_build_command = vformat("bundle%s", build_type); -// cmdline.push_back(bundle_build_command); -// } else if (export_format == EXPORT_FORMAT_APK) { -// String apk_build_command = vformat("assemble%s", build_type); -// cmdline.push_back(apk_build_command); -// } - -// cmdline.push_back("-Pexport_package_name=" + package_name); // argument to specify the package name. -// cmdline.push_back("-Pexport_version_code=" + version_code); // argument to specify the version code. -// cmdline.push_back("-Pexport_version_name=" + version_name); // argument to specify the version name. -// cmdline.push_back("-Pexport_enabled_abis=" + enabled_abi_string); // argument to specify enabled ABIs. -// cmdline.push_back("-Pplugins_local_binaries=" + local_plugins_binaries); // argument to specify the list of plugins local dependencies. -// cmdline.push_back("-Pplugins_remote_binaries=" + remote_plugins_binaries); // argument to specify the list of plugins remote dependencies. -// cmdline.push_back("-Pplugins_maven_repos=" + custom_maven_repos); // argument to specify the list of custom maven repos for the plugins dependencies. -// cmdline.push_back("-Pperform_zipalign=" + zipalign_flag); // argument to specify whether the build should be zipaligned. -// cmdline.push_back("-Pperform_signing=" + sign_flag); // argument to specify whether the build should be signed. -// if (should_sign && !p_debug) { -// // Pass the release keystore info as well -// String release_keystore = p_preset->get("keystore/release"); -// String release_username = p_preset->get("keystore/release_user"); -// String release_password = p_preset->get("keystore/release_password"); -// if (!FileAccess::exists(release_keystore)) { -// EditorNode::add_io_error("Could not find keystore, unable to export."); -// return ERR_FILE_CANT_OPEN; -// } - -// cmdline.push_back("-Prelease_keystore_file=" + release_keystore); // argument to specify the release keystore file. -// cmdline.push_back("-Prelease_keystore_alias=" + release_username); // argument to specify the release keystore alias. -// cmdline.push_back("-Prelease_keystore_password=" + release_password); // argument to specity the release keystore password. -// } -// cmdline.push_back("-p"); // argument to specify the start directory. -// cmdline.push_back(build_path); // start directory. - -// int result = EditorNode::get_singleton()->execute_and_show_output(TTR("Building Android Project (gradle)"), build_command, cmdline); -// if (result != 0) { -// EditorNode::get_singleton()->show_warning(TTR("Building of Android project failed, check output for the error.\nAlternatively visit docs.godotengine.org for Android build documentation.")); -// return ERR_CANT_CREATE; -// } - -// List copy_args; -// String copy_command; -// if (export_format == EXPORT_FORMAT_AAB) { -// copy_command = vformat("copyAndRename%sAab", build_type); -// } else if (export_format == EXPORT_FORMAT_APK) { -// copy_command = vformat("copyAndRename%sApk", build_type); -// } - -// copy_args.push_back(copy_command); - -// copy_args.push_back("-p"); // argument to specify the start directory. -// copy_args.push_back(build_path); // start directory. - -// String export_filename = p_path.get_file(); -// String export_path = p_path.get_base_dir(); -// if (export_path.is_rel_path()) { -// export_path = OS::get_singleton()->get_resource_dir().plus_file(export_path); -// } -// export_path = ProjectSettings::get_singleton()->globalize_path(export_path).simplify_path(); - -// copy_args.push_back("-Pexport_path=file:" + export_path); -// copy_args.push_back("-Pexport_filename=" + export_filename); - -// int copy_result = EditorNode::get_singleton()->execute_and_show_output(TTR("Moving output"), build_command, copy_args); -// if (copy_result != 0) { -// EditorNode::get_singleton()->show_warning(TTR("Unable to copy and rename export file, check gradle project directory for outputs.")); -// return ERR_CANT_CREATE; -// } - -// return OK; -// } -// // This is the start of the Legacy build system -// if (p_debug) -// src_apk = p_preset->get("custom_template/debug"); -// else -// src_apk = p_preset->get("custom_template/release"); -// src_apk = src_apk.strip_edges(); -// if (src_apk == "") { -// if (p_debug) { -// src_apk = find_export_template("android_debug.apk"); -// } else { -// src_apk = find_export_template("android_release.apk"); -// } -// if (src_apk == "") { -// EditorNode::add_io_error("Package not found: " + src_apk); -// return ERR_FILE_NOT_FOUND; -// } -// } - -// if (!DirAccess::exists(p_path.get_base_dir())) { -// return ERR_FILE_BAD_PATH; -// } - -// FileAccess *src_f = nullptr; -// zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - -// if (ep.step("Creating APK...", 0)) { -// return ERR_SKIP; -// } - -// unzFile pkg = unzOpen2(src_apk.utf8().get_data(), &io); -// if (!pkg) { -// EditorNode::add_io_error("Could not find template APK to export:\n" + src_apk); -// return ERR_FILE_NOT_FOUND; -// } - -// int ret = unzGoToFirstFile(pkg); - -// zlib_filefunc_def io2 = io; -// FileAccess *dst_f = nullptr; -// io2.opaque = &dst_f; - -// String tmp_unaligned_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport-unaligned.apk"); - -//#define CLEANUP_AND_RETURN(m_err) -// { -// DirAccess::remove_file_or_error(tmp_unaligned_path); -// return m_err; -// } - -// zipFile unaligned_apk = zipOpen2(tmp_unaligned_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io2); - -// String cmdline = p_preset->get("command_line/extra_args"); - -// String version_name = p_preset->get("version/name"); -// String package_name = p_preset->get("package/unique_name"); - -// String apk_expansion_pkey = p_preset->get("apk_expansion/public_key"); - -// Vector invalid_abis(enabled_abis); -// while (ret == UNZ_OK) { -// //get filename -// unz_file_info info; -// char fname[16384]; -// ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - -// bool skip = false; - -// String file = fname; - -// Vector data; -// data.resize(info.uncompressed_size); - -// //read -// unzOpenCurrentFile(pkg); -// unzReadCurrentFile(pkg, data.ptrw(), data.size()); -// unzCloseCurrentFile(pkg); - -// //write -// if (file == "AndroidManifest.xml") { -// _fix_manifest(p_preset, data, p_give_internet); -// } -// if (file == "resources.arsc") { -// _fix_resources(p_preset, data); -// } - -// // Process the splash image -// if (file == SPLASH_IMAGE_EXPORT_PATH && splash_image.is_valid() && !splash_image->is_empty()) { -// _load_image_data(splash_image, data); -// } - -// // Process the splash bg color image -// if (file == SPLASH_BG_COLOR_PATH && splash_bg_color_image.is_valid() && !splash_bg_color_image->is_empty()) { -// _load_image_data(splash_bg_color_image, data); -// } - -// for (int i = 0; i < icon_densities_count; ++i) { -// if (main_image.is_valid() && !main_image->is_empty()) { -// if (file == launcher_icons[i].export_path) { -// _process_launcher_icons(file, main_image, launcher_icons[i].dimensions, data); -// } -// } -// if (foreground.is_valid() && !foreground->is_empty()) { -// if (file == launcher_adaptive_icon_foregrounds[i].export_path) { -// _process_launcher_icons(file, foreground, launcher_adaptive_icon_foregrounds[i].dimensions, data); -// } -// } -// if (background.is_valid() && !background->is_empty()) { -// if (file == launcher_adaptive_icon_backgrounds[i].export_path) { -// _process_launcher_icons(file, background, launcher_adaptive_icon_backgrounds[i].dimensions, data); -// } -// } -// } - -// if (file.ends_with(".so")) { -// bool enabled = false; -// for (int i = 0; i < enabled_abis.size(); ++i) { -// if (file.begins_with("lib/" + enabled_abis[i] + "/")) { -// invalid_abis.erase(enabled_abis[i]); -// enabled = true; -// break; -// } -// } -// if (!enabled) { -// skip = true; -// } -// } - -// if (file.begins_with("META-INF") && should_sign) { -// skip = true; -// } - -// if (!skip) { -// print_line("ADDING: " + file); - -// // Respect decision on compression made by AAPT for the export template -// const bool uncompressed = info.compression_method == 0; - -// zip_fileinfo zipfi = get_zip_fileinfo(); - -// zipOpenNewFileInZip(unaligned_apk, -// file.utf8().get_data(), -// &zipfi, -// nullptr, -// 0, -// nullptr, -// 0, -// nullptr, -// uncompressed ? 0 : Z_DEFLATED, -// Z_DEFAULT_COMPRESSION); - -// zipWriteInFileInZip(unaligned_apk, data.ptr(), data.size()); -// zipCloseFileInZip(unaligned_apk); -// } - -// ret = unzGoToNextFile(pkg); -// } - -// if (!invalid_abis.is_empty()) { -// String unsupported_arch = String(", ").join(invalid_abis); -// EditorNode::add_io_error("Missing libraries in the export template for the selected architectures: " + unsupported_arch + ".\n" + -// "Please build a template with all required libraries, or uncheck the missing architectures in the export preset."); -// CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND); -// } - -// if (ep.step("Adding files...", 1)) { -// CLEANUP_AND_RETURN(ERR_SKIP); -// } -// err = OK; - -// if (p_flags & DEBUG_FLAG_DUMB_CLIENT) { -// APKExportData ed; -// ed.ep = &ep; -// ed.apk = unaligned_apk; -// err = export_project_files(p_preset, ignore_apk_file, &ed, save_apk_so); -// } else { -// if (apk_expansion) { -// err = save_apk_expansion_file(p_preset, p_path); -// if (err != OK) { -// EditorNode::add_io_error("Could not write expansion package file!"); -// return err; -// } -// } else { -// APKExportData ed; -// ed.ep = &ep; -// ed.apk = unaligned_apk; -// err = export_project_files(p_preset, save_apk_file, &ed, save_apk_so); -// } -// } - -// if (err != OK) { -// unzClose(pkg); -// EditorNode::add_io_error("Could not export project files"); -// CLEANUP_AND_RETURN(ERR_SKIP); -// } - -// zip_fileinfo zipfi = get_zip_fileinfo(); -// zipOpenNewFileInZip(unaligned_apk, -// "assets/_cl_", -// &zipfi, -// NULL, -// 0, -// NULL, -// 0, -// NULL, -// 0, // No compress (little size gain and potentially slower startup) -// Z_DEFAULT_COMPRESSION); -// zipWriteInFileInZip(unaligned_apk, command_line_flags.ptr(), command_line_flags.size()); -// zipCloseFileInZip(unaligned_apk); -// zipClose(unaligned_apk, nullptr); -// unzClose(pkg); - -// if (err != OK) { -// CLEANUP_AND_RETURN(err); -// } - -// // Let's zip-align (must be done before signing) - -// static const int ZIP_ALIGNMENT = 4; - -// // If we're not signing the apk, then the next step should be the last. -// const int next_step = should_sign ? 103 : 105; -// if (ep.step("Aligning APK...", next_step)) { -// CLEANUP_AND_RETURN(ERR_SKIP); -// } - -// unzFile tmp_unaligned = unzOpen2(tmp_unaligned_path.utf8().get_data(), &io); -// if (!tmp_unaligned) { -// EditorNode::add_io_error("Could not unzip temporary unaligned APK."); -// CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND); -// } - -// ret = unzGoToFirstFile(tmp_unaligned); - -// io2 = io; -// dst_f = nullptr; -// io2.opaque = &dst_f; -// zipFile final_apk = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io2); - -// // Take files from the unaligned APK and write them out to the aligned one -// // in raw mode, i.e. not uncompressing and recompressing, aligning them as needed, -// // following what is done in https://github.com/android/platform_build/blob/master/tools/zipalign/ZipAlign.cpp -// int bias = 0; -// while (ret == UNZ_OK) { -// unz_file_info info; -// memset(&info, 0, sizeof(info)); - -// char fname[16384]; -// char extra[16384]; -// ret = unzGetCurrentFileInfo(tmp_unaligned, &info, fname, 16384, extra, 16384 - ZIP_ALIGNMENT, nullptr, 0); - -// String file = fname; - -// Vector data; -// data.resize(info.compressed_size); - -// // read -// int method, level; -// unzOpenCurrentFile2(tmp_unaligned, &method, &level, 1); // raw read -// long file_offset = unzGetCurrentFileZStreamPos64(tmp_unaligned); -// unzReadCurrentFile(tmp_unaligned, data.ptrw(), data.size()); -// unzCloseCurrentFile(tmp_unaligned); - -// // align -// int padding = 0; -// if (!info.compression_method) { -// // Uncompressed file => Align -// long new_offset = file_offset + bias; -// padding = (ZIP_ALIGNMENT - (new_offset % ZIP_ALIGNMENT)) % ZIP_ALIGNMENT; -// } - -// memset(extra + info.size_file_extra, 0, padding); - -// zip_fileinfo fileinfo = get_zip_fileinfo(); -// zipOpenNewFileInZip2(final_apk, -// file.utf8().get_data(), -// &fileinfo, -// extra, -// info.size_file_extra + padding, -// nullptr, -// 0, -// nullptr, -// method, -// level, -// 1); // raw write -// zipWriteInFileInZip(final_apk, data.ptr(), data.size()); -// zipCloseFileInZipRaw(final_apk, info.uncompressed_size, info.crc); - -// bias += padding; - -// ret = unzGoToNextFile(tmp_unaligned); -// } - -// zipClose(final_apk, nullptr); -// unzClose(tmp_unaligned); - -// if (should_sign) { -// // Signing must be done last as any additional modifications to the -// // file will invalidate the signature. -// err = sign_apk(p_preset, p_debug, p_path, ep); -// if (err != OK) { -// CLEANUP_AND_RETURN(err); -// } -// } - -// CLEANUP_AND_RETURN(OK); -// } - -// virtual void get_platform_features(List *r_features) override { -// r_features->push_back("mobile"); -// r_features->push_back("Android"); -// } - -// virtual void resolve_platform_feature_priorities(const Ref &p_preset, Set &p_features) override { -// } - -// EditorExportPlatformAndroid() { -// Ref img = memnew(Image(_android_logo)); -// logo.instance(); -// logo->create_from_image(img); - -// img = Ref(memnew(Image(_android_run_icon))); -// run_icon.instance(); -// run_icon->create_from_image(img); - -// devices_changed = true; -// plugins_changed = true; -// quit_request = false; -// check_for_changes_thread = Thread::create(_check_for_changes_poll_thread, this); -// } - -// ~EditorExportPlatformAndroid() { -// quit_request = true; -// Thread::wait_to_finish(check_for_changes_thread); -// memdelete(check_for_changes_thread); -// } -//}; void register_android_exporter() { String exe_ext; diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 50823884cde..e27274be21e 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1612,7 +1612,7 @@ Vector EditorExportPlatformAndroid::get_enabled_abis(const Ref &p_preset, List *r_features) { String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name"); - if (driver == "OpenGL") { + if (driver == "OpenGL3") { r_features->push_back("etc"); } // FIXME: Review what texture formats are used for Vulkan. diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h index 7c773309e86..744022f1f9f 100644 --- a/platform/android/export/gradle_export_util.h +++ b/platform/android/export/gradle_export_util.h @@ -74,51 +74,6 @@ Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_ // Creates strings.xml files inside the gradle project for different locales. Error _create_project_name_strings_files(const Ref &p_preset, const String &project_name); -//Error _create_project_name_strings_files(const Ref &p_preset, const String &project_name) { -// // Stores the string into the default values directory. -// String processed_default_xml_string = vformat(godot_project_name_xml_string, project_name.xml_escape(true)); -// store_string_at_path("res://android/build/res/values/godot_project_name_string.xml", processed_default_xml_string); - -// // Searches the Gradle project res/ directory to find all supported locales -// DirAccessRef da = DirAccess::open("res://android/build/res"); -// if (!da) { -// return ERR_CANT_OPEN; -// } -// da->list_dir_begin(); -// while (true) { -// String file = da->get_next(); -// if (file == "") { -// break; -// } -// if (!file.begins_with("values-")) { -// // NOTE: This assumes all directories that start with "values-" are for localization. -// continue; -// } -// String locale = file.replace("values-", "").replace("-r", "_"); -// String property_name = "application/config/name_" + locale; -// String locale_directory = "res://android/build/res/" + file + "/godot_project_name_string.xml"; -// if (ProjectSettings::get_singleton()->has_setting(property_name)) { -// String locale_project_name = ProjectSettings::get_singleton()->get(property_name); -// String processed_xml_string = vformat(godot_project_name_xml_string, locale_project_name.xml_escape(true)); -// store_string_at_path(locale_directory, processed_xml_string); -// } else { -// // TODO: Once the legacy build system is deprecated we don't need to have xml files for this else branch -// store_string_at_path(locale_directory, processed_default_xml_string); -// } -// } -// da->list_dir_end(); -// return OK; -//} - -//String bool_to_string(bool v) { -// return v ? "true" : "false"; -//} - -//String _get_gles_tag() { -// bool min_gles3 = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "GLES3" && -// !ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2"); -// return min_gles3 ? " \n" : ""; -//} String bool_to_string(bool v); diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 94ca51f75ab..1a4c5ec00f4 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -262,14 +262,14 @@ Size2i OS_Android::get_display_size() const { } void OS_Android::set_context_is_16_bits(bool p_is_16) { -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) //if (rasterizer) // rasterizer->set_force_16_bits_fbo(p_is_16); #endif } void OS_Android::set_opengl_extensions(const char *p_gl_extensions) { -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) ERR_FAIL_COND(!p_gl_extensions); gl_extensions = p_gl_extensions; #endif @@ -321,7 +321,7 @@ OS_Android::OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_god main_loop = nullptr; -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) gl_extensions = nullptr; use_gl2 = false; #endif diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 9bb37325cf2..d2e0e7d1e98 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -47,7 +47,7 @@ private: bool use_apk_expansion; -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) const char *gl_extensions; #endif diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h index 68cfde65085..76c28b22725 100644 --- a/platform/iphone/app_delegate.h +++ b/platform/iphone/app_delegate.h @@ -34,7 +34,7 @@ // FIXME: Add support for both OpenGL and Vulkan when OpenGL is implemented again, // so it can't be done with compilation time branching. -//#if defined(OPENGL_ENABLED) +//#if defined(GLES3_ENABLED) //@interface AppDelegate : NSObject { //#endif //#if defined(VULKAN_ENABLED) diff --git a/platform/iphone/display_layer.mm b/platform/iphone/display_layer.mm index afa75f53eda..afe612e1a58 100644 --- a/platform/iphone/display_layer.mm +++ b/platform/iphone/display_layer.mm @@ -89,7 +89,7 @@ // FIXME: Add Vulkan support via MoltenVK. Add fallback code back? // Create GL ES 2 context - if (GLOBAL_GET("rendering/driver/driver_name") == "opengl") { + if (GLOBAL_GET("rendering/driver/driver_name") == "opengl3") { context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; NSLog(@"Setting up an OpenGL ES 2.0 context."); if (!context) { diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm index 33601da1c80..7d13a08d39d 100644 --- a/platform/iphone/display_server_iphone.mm +++ b/platform/iphone/display_server_iphone.mm @@ -51,7 +51,7 @@ DisplayServerIPhone *DisplayServerIPhone::get_singleton() { DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { rendering_driver = p_rendering_driver; -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) // FIXME: Add support for both OpenGL and Vulkan when OpenGL is implemented // again, @@ -60,9 +60,9 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo // FIXME: Add Vulkan support via MoltenVK. Add fallback code back? - if (RasterizerOpenGLis_viable() == OK) { - RasterizerOpenGLregister_config(); - RasterizerOpenGLmake_current(); + if (RasterizerGLES3::is_viable() == OK) { + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); } else { gl_initialization_error = true; } @@ -83,7 +83,7 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo // reset this to what it should be, it will have been set to 0 after // rendering_server->init() is called - // RasterizerStorageOpenGLsystem_fbo = gl_view_base_fb; + // RasterizerStorageGLES3system_fbo = gl_view_base_fb; } #endif @@ -157,7 +157,7 @@ Vector DisplayServerIPhone::get_rendering_drivers_func() { #if defined(VULKAN_ENABLED) drivers.push_back("vulkan"); #endif -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) drivers.push_back("opengl_es"); #endif diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 6cec3658852..208626ae368 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -31,1929 +31,6 @@ #include "export.h" #include "export_plugin.h" -//#include "core/config/project_settings.h" -//#include "core/io/image_loader.h" -//#include "core/io/marshalls.h" -//#include "core/io/resource_saver.h" -//#include "core/io/zip_io.h" -//#include "core/os/file_access.h" -//#include "core/os/os.h" -//#include "core/version.h" -//#include "editor/editor_export.h" -//#include "editor/editor_node.h" -//#include "editor/editor_settings.h" -//#include "main/splash.gen.h" -//#include "platform/iphone/logo.gen.h" -//#include "platform/iphone/plugin/godot_plugin_config.h" -//#include "string.h" - -//#include - -//class EditorExportPlatformIOS : public EditorExportPlatform { -// GDCLASS(EditorExportPlatformIOS, EditorExportPlatform); - -// int version_code; - -// Ref logo; - -// // Plugins -// volatile bool plugins_changed; -// Thread *check_for_changes_thread; -// volatile bool quit_request; -// Mutex plugins_lock; -// Vector plugins; - -// typedef Error (*FileHandler)(String p_file, void *p_userdata); -// static Error _walk_dir_recursive(DirAccess *p_da, FileHandler p_handler, void *p_userdata); -// static Error _codesign(String p_file, void *p_userdata); -// void _blend_and_rotate(Ref &p_dst, Ref &p_src, bool p_rot); - -// struct IOSConfigData { -// String pkg_name; -// String binary_name; -// String plist_content; -// String architectures; -// String linker_flags; -// String cpp_code; -// String modules_buildfile; -// String modules_fileref; -// String modules_buildphase; -// String modules_buildgrp; -// Vector capabilities; -// }; -// struct ExportArchitecture { -// String name; -// bool is_default = false; - -// ExportArchitecture() {} - -// ExportArchitecture(String p_name, bool p_is_default) { -// name = p_name; -// is_default = p_is_default; -// } -// }; - -// struct IOSExportAsset { -// String exported_path; -// bool is_framework = false; // framework is anything linked to the binary, otherwise it's a resource -// bool should_embed = false; -// }; - -// String _get_additional_plist_content(); -// String _get_linker_flags(); -// String _get_cpp_code(); -// void _fix_config_file(const Ref &p_preset, Vector &pfile, const IOSConfigData &p_config, bool p_debug); -// Error _export_loading_screen_images(const Ref &p_preset, const String &p_dest_dir); -// Error _export_loading_screen_file(const Ref &p_preset, const String &p_dest_dir); -// Error _export_icons(const Ref &p_preset, const String &p_iconset_dir); - -// Vector _get_supported_architectures(); -// Vector _get_preset_architectures(const Ref &p_preset); - -// void _add_assets_to_project(const Ref &p_preset, Vector &p_project_data, const Vector &p_additional_assets); -// Error _export_additional_assets(const String &p_out_dir, const Vector &p_assets, bool p_is_framework, bool p_should_embed, Vector &r_exported_assets); -// Error _copy_asset(const String &p_out_dir, const String &p_asset, const String *p_custom_file_name, bool p_is_framework, bool p_should_embed, Vector &r_exported_assets); -// Error _export_additional_assets(const String &p_out_dir, const Vector &p_libraries, Vector &r_exported_assets); -// Error _export_ios_plugins(const Ref &p_preset, IOSConfigData &p_config_data, const String &dest_dir, Vector &r_exported_assets, bool p_debug); - -// bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const { -// String pname = p_package; - -// if (pname.length() == 0) { -// if (r_error) { -// *r_error = TTR("Identifier is missing."); -// } -// return false; -// } - -// for (int i = 0; i < pname.length(); i++) { -// char32_t c = pname[i]; -// if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '.')) { -// if (r_error) { -// *r_error = vformat(TTR("The character '%s' is not allowed in Identifier."), String::chr(c)); -// } -// return false; -// } -// } - -// return true; -// } - -// static void _check_for_changes_poll_thread(void *ud) { -// EditorExportPlatformIOS *ea = (EditorExportPlatformIOS *)ud; - -// while (!ea->quit_request) { -// // Nothing to do if we already know the plugins have changed. -// if (!ea->plugins_changed) { -// MutexLock lock(ea->plugins_lock); - -// Vector loaded_plugins = get_plugins(); - -// if (ea->plugins.size() != loaded_plugins.size()) { -// ea->plugins_changed = true; -// } else { -// for (int i = 0; i < ea->plugins.size(); i++) { -// if (ea->plugins[i].name != loaded_plugins[i].name || ea->plugins[i].last_updated != loaded_plugins[i].last_updated) { -// ea->plugins_changed = true; -// break; -// } -// } -// } -// } - -// uint64_t wait = 3000000; -// uint64_t time = OS::get_singleton()->get_ticks_usec(); -// while (OS::get_singleton()->get_ticks_usec() - time < wait) { -// OS::get_singleton()->delay_usec(300000); - -// if (ea->quit_request) { -// break; -// } -// } -// } -// } - -//protected: -// virtual void get_preset_features(const Ref &p_preset, List *r_features) override; -// virtual void get_export_options(List *r_options) override; - -//public: -// virtual String get_name() const override { return "iOS"; } -// virtual String get_os_name() const override { return "iOS"; } -// virtual Ref get_logo() const override { return logo; } - -// virtual bool should_update_export_options() override { -// bool export_options_changed = plugins_changed; -// if (export_options_changed) { -// // don't clear unless we're reporting true, to avoid race -// plugins_changed = false; -// } -// return export_options_changed; -// } - -// virtual List get_binary_extensions(const Ref &p_preset) const override { -// List list; -// list.push_back("ipa"); -// return list; -// } -// virtual Error export_project(const Ref &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override; - -// virtual bool can_export(const Ref &p_preset, String &r_error, bool &r_missing_templates) const override; - -// virtual void get_platform_features(List *r_features) override { -// r_features->push_back("mobile"); -// r_features->push_back("iOS"); -// } - -// virtual void resolve_platform_feature_priorities(const Ref &p_preset, Set &p_features) override { -// } - -// EditorExportPlatformIOS(); -// ~EditorExportPlatformIOS(); - -// /// List the gdip files in the directory specified by the p_path parameter. -// static Vector list_plugin_config_files(const String &p_path, bool p_check_directories) { -// Vector dir_files; -// DirAccessRef da = DirAccess::open(p_path); -// if (da) { -// da->list_dir_begin(); -// while (true) { -// String file = da->get_next(); -// if (file.is_empty()) { -// break; -// } - -// if (file == "." || file == "..") { -// continue; -// } - -// if (da->current_is_hidden()) { -// continue; -// } - -// if (da->current_is_dir()) { -// if (p_check_directories) { -// Vector directory_files = list_plugin_config_files(p_path.plus_file(file), false); -// for (int i = 0; i < directory_files.size(); ++i) { -// dir_files.push_back(file.plus_file(directory_files[i])); -// } -// } - -// continue; -// } - -// if (file.ends_with(PLUGIN_CONFIG_EXT)) { -// dir_files.push_back(file); -// } -// } -// da->list_dir_end(); -// } - -// return dir_files; -// } - -// static Vector get_plugins() { -// Vector loaded_plugins; - -// String plugins_dir = ProjectSettings::get_singleton()->get_resource_path().plus_file("ios/plugins"); - -// if (DirAccess::exists(plugins_dir)) { -// Vector plugins_filenames = list_plugin_config_files(plugins_dir, true); - -// if (!plugins_filenames.is_empty()) { -// Ref config_file = memnew(ConfigFile); -// for (int i = 0; i < plugins_filenames.size(); i++) { -// PluginConfig config = load_plugin_config(config_file, plugins_dir.plus_file(plugins_filenames[i])); -// if (config.valid_config) { -// loaded_plugins.push_back(config); -// } else { -// print_error("Invalid plugin config file " + plugins_filenames[i]); -// } -// } -// } -// } - -// return loaded_plugins; -// } - -// static Vector get_enabled_plugins(const Ref &p_presets) { -// Vector enabled_plugins; -// Vector all_plugins = get_plugins(); -// for (int i = 0; i < all_plugins.size(); i++) { -// PluginConfig plugin = all_plugins[i]; -// bool enabled = p_presets->get("plugins/" + plugin.name); -// if (enabled) { -// enabled_plugins.push_back(plugin); -// } -// } - -// return enabled_plugins; -// } -//}; - -//void EditorExportPlatformIOS::get_preset_features(const Ref &p_preset, List *r_features) { -// String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name"); -// r_features->push_back("pvrtc"); -// if (driver == "Vulkan") { -// // FIXME: Review if this is correct. -// r_features->push_back("etc2"); -// } - -// Vector architectures = _get_preset_architectures(p_preset); -// for (int i = 0; i < architectures.size(); ++i) { -// r_features->push_back(architectures[i]); -// } -//} - -//Vector EditorExportPlatformIOS::_get_supported_architectures() { -// Vector archs; -// archs.push_back(ExportArchitecture("armv7", false)); // Disabled by default, not included in official templates. -// archs.push_back(ExportArchitecture("arm64", true)); -// return archs; -//} - -//struct LoadingScreenInfo { -// const char *preset_key; -// const char *export_name; -// int width = 0; -// int height = 0; -// bool rotate = false; -//}; - -//static const LoadingScreenInfo loading_screen_infos[] = { -// { "landscape_launch_screens/iphone_2436x1125", "Default-Landscape-X.png", 2436, 1125, false }, -// { "landscape_launch_screens/iphone_2208x1242", "Default-Landscape-736h@3x.png", 2208, 1242, false }, -// { "landscape_launch_screens/ipad_1024x768", "Default-Landscape.png", 1024, 768, false }, -// { "landscape_launch_screens/ipad_2048x1536", "Default-Landscape@2x.png", 2048, 1536, false }, - -// { "portrait_launch_screens/iphone_640x960", "Default-480h@2x.png", 640, 960, true }, -// { "portrait_launch_screens/iphone_640x1136", "Default-568h@2x.png", 640, 1136, true }, -// { "portrait_launch_screens/iphone_750x1334", "Default-667h@2x.png", 750, 1334, true }, -// { "portrait_launch_screens/iphone_1125x2436", "Default-Portrait-X.png", 1125, 2436, true }, -// { "portrait_launch_screens/ipad_768x1024", "Default-Portrait.png", 768, 1024, true }, -// { "portrait_launch_screens/ipad_1536x2048", "Default-Portrait@2x.png", 1536, 2048, true }, -// { "portrait_launch_screens/iphone_1242x2208", "Default-Portrait-736h@3x.png", 1242, 2208, true } -//}; - -//void EditorExportPlatformIOS::get_export_options(List *r_options) { -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); - -// Vector architectures = _get_supported_architectures(); -// for (int i = 0; i < architectures.size(); ++i) { -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architectures/" + architectures[i].name), architectures[i].is_default)); -// } - -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/app_store_team_id"), "")); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/provisioning_profile_uuid_debug"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/code_sign_identity_debug", PROPERTY_HINT_PLACEHOLDER_TEXT, "iPhone Developer"), "iPhone Developer")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/export_method_debug", PROPERTY_HINT_ENUM, "App Store,Development,Ad-Hoc,Enterprise"), 1)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/provisioning_profile_uuid_release"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/code_sign_identity_release", PROPERTY_HINT_PLACEHOLDER_TEXT, "iPhone Distribution"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/export_method_release", PROPERTY_HINT_ENUM, "App Store,Development,Ad-Hoc,Enterprise"), 0)); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/info"), "Made with Godot Engine")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/bundle_identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version"), "1.0")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version"), "1.0")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), "")); - -// Vector found_plugins = get_plugins(); -// for (int i = 0; i < found_plugins.size(); i++) { -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "plugins/" + found_plugins[i].name), false)); -// } -// plugins_changed = false; -// plugins = found_plugins; - -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/access_wifi"), false)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/push_notifications"), false)); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "user_data/accessible_from_files_app"), false)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "user_data/accessible_from_itunes_sharing"), false)); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/camera_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the camera"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/microphone_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the microphone"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photolibrary_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need access to the photo library"), "")); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait"), true)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/landscape_left"), true)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/landscape_right"), true)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait_upside_down"), true)); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "icons/generate_missing"), false)); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/iphone_120x120", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPhone/iPod Touch with retina display -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/ipad_76x76", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPad -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/app_store_1024x1024", PROPERTY_HINT_FILE, "*.png"), "")); // App Store - -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/iphone_180x180", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPhone with retina HD display -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/ipad_152x152", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPad with retina display -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/ipad_167x167", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPad Pro -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_40x40", PROPERTY_HINT_FILE, "*.png"), "")); // Spotlight -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_80x80", PROPERTY_HINT_FILE, "*.png"), "")); // Spotlight on devices with retina display - -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "storyboard/use_launch_screen_storyboard"), false)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "storyboard/image_scale_mode", PROPERTY_HINT_ENUM, "Same as Logo,Center,Scale To Fit,Scale To Fill,Scale"), 0)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "storyboard/custom_image@2x", PROPERTY_HINT_FILE, "*.png"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "storyboard/custom_image@3x", PROPERTY_HINT_FILE, "*.png"), "")); -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "storyboard/use_custom_bg_color"), false)); -// r_options->push_back(ExportOption(PropertyInfo(Variant::COLOR, "storyboard/custom_bg_color"), Color())); - -// r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "launch_screens/generate_missing"), false)); - -// for (uint64_t i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) { -// r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, loading_screen_infos[i].preset_key, PROPERTY_HINT_FILE, "*.png"), "")); -// } -//} - -//void EditorExportPlatformIOS::_fix_config_file(const Ref &p_preset, Vector &pfile, const IOSConfigData &p_config, bool p_debug) { -// static const String export_method_string[] = { -// "app-store", -// "development", -// "ad-hoc", -// "enterprise" -// }; -// static const String storyboard_image_scale_mode[] = { -// "center", -// "scaleAspectFit", -// "scaleAspectFill", -// "scaleToFill" -// }; -// String str; -// String strnew; -// str.parse_utf8((const char *)pfile.ptr(), pfile.size()); -// Vector lines = str.split("\n"); -// for (int i = 0; i < lines.size(); i++) { -// if (lines[i].find("$binary") != -1) { -// strnew += lines[i].replace("$binary", p_config.binary_name) + "\n"; -// } else if (lines[i].find("$modules_buildfile") != -1) { -// strnew += lines[i].replace("$modules_buildfile", p_config.modules_buildfile) + "\n"; -// } else if (lines[i].find("$modules_fileref") != -1) { -// strnew += lines[i].replace("$modules_fileref", p_config.modules_fileref) + "\n"; -// } else if (lines[i].find("$modules_buildphase") != -1) { -// strnew += lines[i].replace("$modules_buildphase", p_config.modules_buildphase) + "\n"; -// } else if (lines[i].find("$modules_buildgrp") != -1) { -// strnew += lines[i].replace("$modules_buildgrp", p_config.modules_buildgrp) + "\n"; -// } else if (lines[i].find("$name") != -1) { -// strnew += lines[i].replace("$name", p_config.pkg_name) + "\n"; -// } else if (lines[i].find("$info") != -1) { -// strnew += lines[i].replace("$info", p_preset->get("application/info")) + "\n"; -// } else if (lines[i].find("$bundle_identifier") != -1) { -// strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n"; -// } else if (lines[i].find("$short_version") != -1) { -// strnew += lines[i].replace("$short_version", p_preset->get("application/short_version")) + "\n"; -// } else if (lines[i].find("$version") != -1) { -// strnew += lines[i].replace("$version", p_preset->get("application/version")) + "\n"; -// } else if (lines[i].find("$signature") != -1) { -// strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n"; -// } else if (lines[i].find("$copyright") != -1) { -// strnew += lines[i].replace("$copyright", p_preset->get("application/copyright")) + "\n"; -// } else if (lines[i].find("$team_id") != -1) { -// strnew += lines[i].replace("$team_id", p_preset->get("application/app_store_team_id")) + "\n"; -// } else if (lines[i].find("$export_method") != -1) { -// int export_method = p_preset->get(p_debug ? "application/export_method_debug" : "application/export_method_release"); -// strnew += lines[i].replace("$export_method", export_method_string[export_method]) + "\n"; -// } else if (lines[i].find("$provisioning_profile_uuid_release") != -1) { -// strnew += lines[i].replace("$provisioning_profile_uuid_release", p_preset->get("application/provisioning_profile_uuid_release")) + "\n"; -// } else if (lines[i].find("$provisioning_profile_uuid_debug") != -1) { -// strnew += lines[i].replace("$provisioning_profile_uuid_debug", p_preset->get("application/provisioning_profile_uuid_debug")) + "\n"; -// } else if (lines[i].find("$provisioning_profile_uuid") != -1) { -// String uuid = p_debug ? p_preset->get("application/provisioning_profile_uuid_debug") : p_preset->get("application/provisioning_profile_uuid_release"); -// strnew += lines[i].replace("$provisioning_profile_uuid", uuid) + "\n"; -// } else if (lines[i].find("$code_sign_identity_debug") != -1) { -// strnew += lines[i].replace("$code_sign_identity_debug", p_preset->get("application/code_sign_identity_debug")) + "\n"; -// } else if (lines[i].find("$code_sign_identity_release") != -1) { -// strnew += lines[i].replace("$code_sign_identity_release", p_preset->get("application/code_sign_identity_release")) + "\n"; -// } else if (lines[i].find("$additional_plist_content") != -1) { -// strnew += lines[i].replace("$additional_plist_content", p_config.plist_content) + "\n"; -// } else if (lines[i].find("$godot_archs") != -1) { -// strnew += lines[i].replace("$godot_archs", p_config.architectures) + "\n"; -// } else if (lines[i].find("$linker_flags") != -1) { -// strnew += lines[i].replace("$linker_flags", p_config.linker_flags) + "\n"; -// } else if (lines[i].find("$cpp_code") != -1) { -// strnew += lines[i].replace("$cpp_code", p_config.cpp_code) + "\n"; -// } else if (lines[i].find("$docs_in_place") != -1) { -// strnew += lines[i].replace("$docs_in_place", ((bool)p_preset->get("user_data/accessible_from_files_app")) ? "" : "") + "\n"; -// } else if (lines[i].find("$docs_sharing") != -1) { -// strnew += lines[i].replace("$docs_sharing", ((bool)p_preset->get("user_data/accessible_from_itunes_sharing")) ? "" : "") + "\n"; -// } else if (lines[i].find("$entitlements_push_notifications") != -1) { -// bool is_on = p_preset->get("capabilities/push_notifications"); -// strnew += lines[i].replace("$entitlements_push_notifications", is_on ? "aps-environmentdevelopment" : "") + "\n"; -// } else if (lines[i].find("$required_device_capabilities") != -1) { -// String capabilities; - -// // I've removed armv7 as we can run on 64bit only devices -// // Note that capabilities listed here are requirements for the app to be installed. -// // They don't enable anything. -// Vector capabilities_list = p_config.capabilities; - -// if ((bool)p_preset->get("capabilities/access_wifi") && !capabilities_list.has("wifi")) { -// capabilities_list.push_back("wifi"); -// } - -// for (int idx = 0; idx < capabilities_list.size(); idx++) { -// capabilities += "" + capabilities_list[idx] + "\n"; -// } - -// strnew += lines[i].replace("$required_device_capabilities", capabilities); -// } else if (lines[i].find("$interface_orientations") != -1) { -// String orientations; - -// if ((bool)p_preset->get("orientation/portrait")) { -// orientations += "UIInterfaceOrientationPortrait\n"; -// } -// if ((bool)p_preset->get("orientation/landscape_left")) { -// orientations += "UIInterfaceOrientationLandscapeLeft\n"; -// } -// if ((bool)p_preset->get("orientation/landscape_right")) { -// orientations += "UIInterfaceOrientationLandscapeRight\n"; -// } -// if ((bool)p_preset->get("orientation/portrait_upside_down")) { -// orientations += "UIInterfaceOrientationPortraitUpsideDown\n"; -// } - -// strnew += lines[i].replace("$interface_orientations", orientations); -// } else if (lines[i].find("$camera_usage_description") != -1) { -// String description = p_preset->get("privacy/camera_usage_description"); -// strnew += lines[i].replace("$camera_usage_description", description) + "\n"; -// } else if (lines[i].find("$microphone_usage_description") != -1) { -// String description = p_preset->get("privacy/microphone_usage_description"); -// strnew += lines[i].replace("$microphone_usage_description", description) + "\n"; -// } else if (lines[i].find("$photolibrary_usage_description") != -1) { -// String description = p_preset->get("privacy/photolibrary_usage_description"); -// strnew += lines[i].replace("$photolibrary_usage_description", description) + "\n"; -// } else if (lines[i].find("$plist_launch_screen_name") != -1) { -// bool is_on = p_preset->get("storyboard/use_launch_screen_storyboard"); -// String value = is_on ? "UILaunchStoryboardName\nLaunch Screen" : ""; -// strnew += lines[i].replace("$plist_launch_screen_name", value) + "\n"; -// } else if (lines[i].find("$pbx_launch_screen_file_reference") != -1) { -// bool is_on = p_preset->get("storyboard/use_launch_screen_storyboard"); -// String value = is_on ? "90DD2D9D24B36E8000717FE1 = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = \"Launch Screen.storyboard\"; sourceTree = \"\"; };" : ""; -// strnew += lines[i].replace("$pbx_launch_screen_file_reference", value) + "\n"; -// } else if (lines[i].find("$pbx_launch_screen_copy_files") != -1) { -// bool is_on = p_preset->get("storyboard/use_launch_screen_storyboard"); -// String value = is_on ? "90DD2D9D24B36E8000717FE1 /* Launch Screen.storyboard */," : ""; -// strnew += lines[i].replace("$pbx_launch_screen_copy_files", value) + "\n"; -// } else if (lines[i].find("$pbx_launch_screen_build_phase") != -1) { -// bool is_on = p_preset->get("storyboard/use_launch_screen_storyboard"); -// String value = is_on ? "90DD2D9E24B36E8000717FE1 /* Launch Screen.storyboard in Resources */," : ""; -// strnew += lines[i].replace("$pbx_launch_screen_build_phase", value) + "\n"; -// } else if (lines[i].find("$pbx_launch_screen_build_reference") != -1) { -// bool is_on = p_preset->get("storyboard/use_launch_screen_storyboard"); -// String value = is_on ? "90DD2D9E24B36E8000717FE1 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 90DD2D9D24B36E8000717FE1 /* Launch Screen.storyboard */; };" : ""; -// strnew += lines[i].replace("$pbx_launch_screen_build_reference", value) + "\n"; -// } else if (lines[i].find("$pbx_launch_image_usage_setting") != -1) { -// bool is_on = p_preset->get("storyboard/use_launch_screen_storyboard"); -// String value = is_on ? "" : "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;"; -// strnew += lines[i].replace("$pbx_launch_image_usage_setting", value) + "\n"; -// } else if (lines[i].find("$launch_screen_image_mode") != -1) { -// int image_scale_mode = p_preset->get("storyboard/image_scale_mode"); -// String value; - -// switch (image_scale_mode) { -// case 0: { -// String logo_path = ProjectSettings::get_singleton()->get("application/boot_splash/image"); -// bool is_on = ProjectSettings::get_singleton()->get("application/boot_splash/fullsize"); -// // If custom logo is not specified, Godot does not scale default one, so we should do the same. -// value = (is_on && logo_path.length() > 0) ? "scaleAspectFit" : "center"; -// } break; -// default: { -// value = storyboard_image_scale_mode[image_scale_mode - 1]; -// } -// } - -// strnew += lines[i].replace("$launch_screen_image_mode", value) + "\n"; -// } else if (lines[i].find("$launch_screen_background_color") != -1) { -// bool use_custom = p_preset->get("storyboard/use_custom_bg_color"); -// Color color = use_custom ? p_preset->get("storyboard/custom_bg_color") : ProjectSettings::get_singleton()->get("application/boot_splash/bg_color"); -// const String value_format = "red=\"$red\" green=\"$green\" blue=\"$blue\" alpha=\"$alpha\""; - -// Dictionary value_dictionary; -// value_dictionary["red"] = color.r; -// value_dictionary["green"] = color.g; -// value_dictionary["blue"] = color.b; -// value_dictionary["alpha"] = color.a; -// String value = value_format.format(value_dictionary, "$_"); - -// strnew += lines[i].replace("$launch_screen_background_color", value) + "\n"; -// } else { -// strnew += lines[i] + "\n"; -// } -// } - -// // !BAS! I'm assuming the 9 in the original code was a typo. I've added -1 or else it seems to also be adding our terminating zero... -// // should apply the same fix in our OSX export. -// CharString cs = strnew.utf8(); -// pfile.resize(cs.size() - 1); -// for (int i = 0; i < cs.size() - 1; i++) { -// pfile.write[i] = cs[i]; -// } -//} - -//String EditorExportPlatformIOS::_get_additional_plist_content() { -// Vector> export_plugins = EditorExport::get_singleton()->get_export_plugins(); -// String result; -// for (int i = 0; i < export_plugins.size(); ++i) { -// result += export_plugins[i]->get_ios_plist_content(); -// } -// return result; -//} - -//String EditorExportPlatformIOS::_get_linker_flags() { -// Vector> export_plugins = EditorExport::get_singleton()->get_export_plugins(); -// String result; -// for (int i = 0; i < export_plugins.size(); ++i) { -// String flags = export_plugins[i]->get_ios_linker_flags(); -// if (flags.length() == 0) { -// continue; -// } -// if (result.length() > 0) { -// result += ' '; -// } -// result += flags; -// } -// // the flags will be enclosed in quotes, so need to escape them -// return result.replace("\"", "\\\""); -//} - -//String EditorExportPlatformIOS::_get_cpp_code() { -// Vector> export_plugins = EditorExport::get_singleton()->get_export_plugins(); -// String result; -// for (int i = 0; i < export_plugins.size(); ++i) { -// result += export_plugins[i]->get_ios_cpp_code(); -// } -// return result; -//} - -//void EditorExportPlatformIOS::_blend_and_rotate(Ref &p_dst, Ref &p_src, bool p_rot) { -// ERR_FAIL_COND(p_dst.is_null()); -// ERR_FAIL_COND(p_src.is_null()); - -// int sw = p_rot ? p_src->get_height() : p_src->get_width(); -// int sh = p_rot ? p_src->get_width() : p_src->get_height(); - -// int x_pos = (p_dst->get_width() - sw) / 2; -// int y_pos = (p_dst->get_height() - sh) / 2; - -// int xs = (x_pos >= 0) ? 0 : -x_pos; -// int ys = (y_pos >= 0) ? 0 : -y_pos; - -// if (sw + x_pos > p_dst->get_width()) { -// sw = p_dst->get_width() - x_pos; -// } -// if (sh + y_pos > p_dst->get_height()) { -// sh = p_dst->get_height() - y_pos; -// } - -// for (int y = ys; y < sh; y++) { -// for (int x = xs; x < sw; x++) { -// Color sc = p_rot ? p_src->get_pixel(p_src->get_width() - y - 1, x) : p_src->get_pixel(x, y); -// Color dc = p_dst->get_pixel(x_pos + x, y_pos + y); -// dc.r = (double)(sc.a * sc.r + dc.a * (1.0 - sc.a) * dc.r); -// dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g); -// dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b); -// dc.a = (double)(sc.a + dc.a * (1.0 - sc.a)); -// p_dst->set_pixel(x_pos + x, y_pos + y, dc); -// } -// } -//} - -//struct IconInfo { -// const char *preset_key; -// const char *idiom; -// const char *export_name; -// const char *actual_size_side; -// const char *scale; -// const char *unscaled_size; -// bool is_required = false; -//}; - -//static const IconInfo icon_infos[] = { -// { "required_icons/iphone_120x120", "iphone", "Icon-120.png", "120", "2x", "60x60", true }, -// { "required_icons/iphone_120x120", "iphone", "Icon-120.png", "120", "3x", "40x40", true }, - -// { "required_icons/ipad_76x76", "ipad", "Icon-76.png", "76", "1x", "76x76", true }, -// { "required_icons/app_store_1024x1024", "ios-marketing", "Icon-1024.png", "1024", "1x", "1024x1024", true }, - -// { "optional_icons/iphone_180x180", "iphone", "Icon-180.png", "180", "3x", "60x60", false }, - -// { "optional_icons/ipad_152x152", "ipad", "Icon-152.png", "152", "2x", "76x76", false }, - -// { "optional_icons/ipad_167x167", "ipad", "Icon-167.png", "167", "2x", "83.5x83.5", false }, - -// { "optional_icons/spotlight_40x40", "ipad", "Icon-40.png", "40", "1x", "40x40", false }, - -// { "optional_icons/spotlight_80x80", "iphone", "Icon-80.png", "80", "2x", "40x40", false }, -// { "optional_icons/spotlight_80x80", "ipad", "Icon-80.png", "80", "2x", "40x40", false } -//}; - -//Error EditorExportPlatformIOS::_export_icons(const Ref &p_preset, const String &p_iconset_dir) { -// String json_description = "{\"images\":["; -// String sizes; - -// DirAccess *da = DirAccess::open(p_iconset_dir); -// ERR_FAIL_COND_V_MSG(!da, ERR_CANT_OPEN, "Cannot open directory '" + p_iconset_dir + "'."); - -// for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) { -// IconInfo info = icon_infos[i]; -// int side_size = String(info.actual_size_side).to_int(); -// String icon_path = p_preset->get(info.preset_key); -// if (icon_path.length() == 0) { -// if ((bool)p_preset->get("icons/generate_missing")) { -// // Resize main app icon -// icon_path = ProjectSettings::get_singleton()->get("application/config/icon"); -// Ref img = memnew(Image); -// Error err = ImageLoader::load_image(icon_path, img); -// if (err != OK) { -// ERR_PRINT("Invalid icon (" + String(info.preset_key) + "): '" + icon_path + "'."); -// return ERR_UNCONFIGURED; -// } -// img->resize(side_size, side_size); -// err = img->save_png(p_iconset_dir + info.export_name); -// if (err) { -// String err_str = String("Failed to export icon(" + String(info.preset_key) + "): '" + icon_path + "'."); -// ERR_PRINT(err_str.utf8().get_data()); -// return err; -// } -// } else { -// if (info.is_required) { -// String err_str = String("Required icon (") + info.preset_key + ") is not specified in the preset."; -// ERR_PRINT(err_str); -// return ERR_UNCONFIGURED; -// } else { -// String err_str = String("Icon (") + info.preset_key + ") is not specified in the preset."; -// WARN_PRINT(err_str); -// } -// continue; -// } -// } else { -// // Load custom icon -// Ref img = memnew(Image); -// Error err = ImageLoader::load_image(icon_path, img); -// if (err != OK) { -// ERR_PRINT("Invalid icon (" + String(info.preset_key) + "): '" + icon_path + "'."); -// return ERR_UNCONFIGURED; -// } -// if (img->get_width() != side_size || img->get_height() != side_size) { -// ERR_PRINT("Invalid icon size (" + String(info.preset_key) + "): '" + icon_path + "'."); -// return ERR_UNCONFIGURED; -// } - -// err = da->copy(icon_path, p_iconset_dir + info.export_name); -// if (err) { -// memdelete(da); -// String err_str = String("Failed to export icon(" + String(info.preset_key) + "): '" + icon_path + "'."); -// ERR_PRINT(err_str.utf8().get_data()); -// return err; -// } -// } -// sizes += String(info.actual_size_side) + "\n"; -// if (i > 0) { -// json_description += ","; -// } -// json_description += String("{"); -// json_description += String("\"idiom\":") + "\"" + info.idiom + "\","; -// json_description += String("\"size\":") + "\"" + info.unscaled_size + "\","; -// json_description += String("\"scale\":") + "\"" + info.scale + "\","; -// json_description += String("\"filename\":") + "\"" + info.export_name + "\""; -// json_description += String("}"); -// } -// json_description += "]}"; -// memdelete(da); - -// FileAccess *json_file = FileAccess::open(p_iconset_dir + "Contents.json", FileAccess::WRITE); -// ERR_FAIL_COND_V(!json_file, ERR_CANT_CREATE); -// CharString json_utf8 = json_description.utf8(); -// json_file->store_buffer((const uint8_t *)json_utf8.get_data(), json_utf8.length()); -// memdelete(json_file); - -// FileAccess *sizes_file = FileAccess::open(p_iconset_dir + "sizes", FileAccess::WRITE); -// ERR_FAIL_COND_V(!sizes_file, ERR_CANT_CREATE); -// CharString sizes_utf8 = sizes.utf8(); -// sizes_file->store_buffer((const uint8_t *)sizes_utf8.get_data(), sizes_utf8.length()); -// memdelete(sizes_file); - -// return OK; -//} - -//Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref &p_preset, const String &p_dest_dir) { -// const String custom_launch_image_2x = p_preset->get("storyboard/custom_image@2x"); -// const String custom_launch_image_3x = p_preset->get("storyboard/custom_image@3x"); - -// if (custom_launch_image_2x.length() > 0 && custom_launch_image_3x.length() > 0) { -// Ref image; -// String image_path = p_dest_dir.plus_file("splash@2x.png"); -// image.instance(); -// Error err = image->load(custom_launch_image_2x); - -// if (err) { -// image.unref(); -// return err; -// } - -// if (image->save_png(image_path) != OK) { -// return ERR_FILE_CANT_WRITE; -// } - -// image.unref(); -// image_path = p_dest_dir.plus_file("splash@3x.png"); -// image.instance(); -// err = image->load(custom_launch_image_3x); - -// if (err) { -// image.unref(); -// return err; -// } - -// if (image->save_png(image_path) != OK) { -// return ERR_FILE_CANT_WRITE; -// } -// } else { -// Ref splash; - -// const String splash_path = ProjectSettings::get_singleton()->get("application/boot_splash/image"); - -// if (!splash_path.is_empty()) { -// splash.instance(); -// const Error err = splash->load(splash_path); -// if (err) { -// splash.unref(); -// } -// } - -// if (splash.is_null()) { -// splash = Ref(memnew(Image(boot_splash_png))); -// } - -// // Using same image for both @2x and @3x -// // because Godot's own boot logo uses single image for all resolutions. -// // Also not using @1x image, because devices using this image variant -// // are not supported by iOS 9, which is minimal target. -// const String splash_png_path_2x = p_dest_dir.plus_file("splash@2x.png"); -// const String splash_png_path_3x = p_dest_dir.plus_file("splash@3x.png"); - -// if (splash->save_png(splash_png_path_2x) != OK) { -// return ERR_FILE_CANT_WRITE; -// } - -// if (splash->save_png(splash_png_path_3x) != OK) { -// return ERR_FILE_CANT_WRITE; -// } -// } - -// return OK; -//} - -//Error EditorExportPlatformIOS::_export_loading_screen_images(const Ref &p_preset, const String &p_dest_dir) { -// DirAccess *da = DirAccess::open(p_dest_dir); -// ERR_FAIL_COND_V_MSG(!da, ERR_CANT_OPEN, "Cannot open directory '" + p_dest_dir + "'."); - -// for (uint64_t i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) { -// LoadingScreenInfo info = loading_screen_infos[i]; -// String loading_screen_file = p_preset->get(info.preset_key); -// if (loading_screen_file.size() > 0) { -// // Load custom loading screens -// Ref img = memnew(Image); -// Error err = ImageLoader::load_image(loading_screen_file, img); -// if (err != OK) { -// ERR_PRINT("Invalid loading screen (" + String(info.preset_key) + "): '" + loading_screen_file + "'."); -// return ERR_UNCONFIGURED; -// } -// if (img->get_width() != info.width || img->get_height() != info.height) { -// ERR_PRINT("Invalid loading screen size (" + String(info.preset_key) + "): '" + loading_screen_file + "'."); -// return ERR_UNCONFIGURED; -// } -// err = da->copy(loading_screen_file, p_dest_dir + info.export_name); -// if (err) { -// memdelete(da); -// String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path '" + loading_screen_file + "'."; -// ERR_PRINT(err_str.utf8().get_data()); -// return err; -// } -// } else if ((bool)p_preset->get("launch_screens/generate_missing")) { -// // Generate loading screen from the splash screen -// Color boot_bg_color = ProjectSettings::get_singleton()->get("application/boot_splash/bg_color"); -// String boot_logo_path = ProjectSettings::get_singleton()->get("application/boot_splash/image"); -// bool boot_logo_scale = ProjectSettings::get_singleton()->get("application/boot_splash/fullsize"); - -// Ref img = memnew(Image); -// img->create(info.width, info.height, false, Image::FORMAT_RGBA8); -// img->fill(boot_bg_color); - -// Ref img_bs; - -// if (boot_logo_path.length() > 0) { -// img_bs = Ref(memnew(Image)); -// ImageLoader::load_image(boot_logo_path, img_bs); -// } -// if (!img_bs.is_valid()) { -// img_bs = Ref(memnew(Image(boot_splash_png))); -// } -// if (img_bs.is_valid()) { -// float aspect_ratio = (float)img_bs->get_width() / (float)img_bs->get_height(); -// if (info.rotate) { -// if (boot_logo_scale) { -// if (info.width * aspect_ratio <= info.height) { -// img_bs->resize(info.width * aspect_ratio, info.width); -// } else { -// img_bs->resize(info.height, info.height / aspect_ratio); -// } -// } -// } else { -// if (boot_logo_scale) { -// if (info.height * aspect_ratio <= info.width) { -// img_bs->resize(info.height * aspect_ratio, info.height); -// } else { -// img_bs->resize(info.width, info.width / aspect_ratio); -// } -// } -// } -// _blend_and_rotate(img, img_bs, info.rotate); -// } -// Error err = img->save_png(p_dest_dir + info.export_name); -// if (err) { -// String err_str = String("Failed to export loading screen (") + info.preset_key + ") from splash screen."; -// WARN_PRINT(err_str.utf8().get_data()); -// } -// } else { -// String err_str = String("No loading screen (") + info.preset_key + ") specified."; -// WARN_PRINT(err_str.utf8().get_data()); -// } -// } -// memdelete(da); - -// return OK; -//} - -//Error EditorExportPlatformIOS::_walk_dir_recursive(DirAccess *p_da, FileHandler p_handler, void *p_userdata) { -// Vector dirs; -// String path; -// String current_dir = p_da->get_current_dir(); -// p_da->list_dir_begin(); -// while ((path = p_da->get_next()).length() != 0) { -// if (p_da->current_is_dir()) { -// if (path != "." && path != "..") { -// dirs.push_back(path); -// } -// } else { -// Error err = p_handler(current_dir.plus_file(path), p_userdata); -// if (err) { -// p_da->list_dir_end(); -// return err; -// } -// } -// } -// p_da->list_dir_end(); - -// for (int i = 0; i < dirs.size(); ++i) { -// String dir = dirs[i]; -// p_da->change_dir(dir); -// Error err = _walk_dir_recursive(p_da, p_handler, p_userdata); -// p_da->change_dir(".."); -// if (err) { -// return err; -// } -// } - -// return OK; -//} - -//struct CodesignData { -// const Ref &preset; -// bool debug = false; - -// CodesignData(const Ref &p_preset, bool p_debug) : -// preset(p_preset), -// debug(p_debug) { -// } -//}; - -//Error EditorExportPlatformIOS::_codesign(String p_file, void *p_userdata) { -// if (p_file.ends_with(".dylib")) { -// CodesignData *data = (CodesignData *)p_userdata; -// print_line(String("Signing ") + p_file); -// List codesign_args; -// codesign_args.push_back("-f"); -// codesign_args.push_back("-s"); -// codesign_args.push_back(data->preset->get(data->debug ? "application/code_sign_identity_debug" : "application/code_sign_identity_release")); -// codesign_args.push_back(p_file); -// return OS::get_singleton()->execute("codesign", codesign_args, true); -// } -// return OK; -//} - -//struct PbxId { -//private: -// static char _hex_char(uint8_t four_bits) { -// if (four_bits < 10) { -// return ('0' + four_bits); -// } -// return 'A' + (four_bits - 10); -// } - -// static String _hex_pad(uint32_t num) { -// Vector ret; -// ret.resize(sizeof(num) * 2); -// for (uint64_t i = 0; i < sizeof(num) * 2; ++i) { -// uint8_t four_bits = (num >> (sizeof(num) * 8 - (i + 1) * 4)) & 0xF; -// ret.write[i] = _hex_char(four_bits); -// } -// return String::utf8(ret.ptr(), ret.size()); -// } - -//public: -// uint32_t high_bits; -// uint32_t mid_bits; -// uint32_t low_bits; - -// String str() const { -// return _hex_pad(high_bits) + _hex_pad(mid_bits) + _hex_pad(low_bits); -// } - -// PbxId &operator++() { -// low_bits++; -// if (!low_bits) { -// mid_bits++; -// if (!mid_bits) { -// high_bits++; -// } -// } - -// return *this; -// } -//}; - -//struct ExportLibsData { -// Vector lib_paths; -// String dest_dir; -//}; - -//void EditorExportPlatformIOS::_add_assets_to_project(const Ref &p_preset, Vector &p_project_data, const Vector &p_additional_assets) { -// // that is just a random number, we just need Godot IDs not to clash with -// // existing IDs in the project. -// PbxId current_id = { 0x58938401, 0, 0 }; -// String pbx_files; -// String pbx_frameworks_build; -// String pbx_frameworks_refs; -// String pbx_resources_build; -// String pbx_resources_refs; -// String pbx_embeded_frameworks; - -// const String file_info_format = String("$build_id = {isa = PBXBuildFile; fileRef = $ref_id; };\n") + -// "$ref_id = {isa = PBXFileReference; lastKnownFileType = $file_type; name = \"$name\"; path = \"$file_path\"; sourceTree = \"\"; };\n"; - -// for (int i = 0; i < p_additional_assets.size(); ++i) { -// String additional_asset_info_format = file_info_format; - -// String build_id = (++current_id).str(); -// String ref_id = (++current_id).str(); -// String framework_id = ""; - -// const IOSExportAsset &asset = p_additional_assets[i]; - -// String type; -// if (asset.exported_path.ends_with(".framework")) { -// if (asset.should_embed) { -// additional_asset_info_format += "$framework_id = {isa = PBXBuildFile; fileRef = $ref_id; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };\n"; -// framework_id = (++current_id).str(); -// pbx_embeded_frameworks += framework_id + ",\n"; -// } - -// type = "wrapper.framework"; -// } else if (asset.exported_path.ends_with(".xcframework")) { -// if (asset.should_embed) { -// additional_asset_info_format += "$framework_id = {isa = PBXBuildFile; fileRef = $ref_id; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };\n"; -// framework_id = (++current_id).str(); -// pbx_embeded_frameworks += framework_id + ",\n"; -// } - -// type = "wrapper.xcframework"; -// } else if (asset.exported_path.ends_with(".dylib")) { -// type = "compiled.mach-o.dylib"; -// } else if (asset.exported_path.ends_with(".a")) { -// type = "archive.ar"; -// } else { -// type = "file"; -// } - -// String &pbx_build = asset.is_framework ? pbx_frameworks_build : pbx_resources_build; -// String &pbx_refs = asset.is_framework ? pbx_frameworks_refs : pbx_resources_refs; - -// if (pbx_build.length() > 0) { -// pbx_build += ",\n"; -// pbx_refs += ",\n"; -// } -// pbx_build += build_id; -// pbx_refs += ref_id; - -// Dictionary format_dict; -// format_dict["build_id"] = build_id; -// format_dict["ref_id"] = ref_id; -// format_dict["name"] = asset.exported_path.get_file(); -// format_dict["file_path"] = asset.exported_path; -// format_dict["file_type"] = type; -// if (framework_id.length() > 0) { -// format_dict["framework_id"] = framework_id; -// } -// pbx_files += additional_asset_info_format.format(format_dict, "$_"); -// } - -// // Note, frameworks like gamekit are always included in our project.pbxprof file -// // even if turned off in capabilities. - -// String str = String::utf8((const char *)p_project_data.ptr(), p_project_data.size()); -// str = str.replace("$additional_pbx_files", pbx_files); -// str = str.replace("$additional_pbx_frameworks_build", pbx_frameworks_build); -// str = str.replace("$additional_pbx_frameworks_refs", pbx_frameworks_refs); -// str = str.replace("$additional_pbx_resources_build", pbx_resources_build); -// str = str.replace("$additional_pbx_resources_refs", pbx_resources_refs); -// str = str.replace("$pbx_embeded_frameworks", pbx_embeded_frameworks); - -// CharString cs = str.utf8(); -// p_project_data.resize(cs.size() - 1); -// for (int i = 0; i < cs.size() - 1; i++) { -// p_project_data.write[i] = cs[i]; -// } -//} - -//Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String &p_asset, const String *p_custom_file_name, bool p_is_framework, bool p_should_embed, Vector &r_exported_assets) { -// DirAccess *filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); -// ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_out_dir + "'."); - -// String binary_name = p_out_dir.get_file().get_basename(); - -// DirAccess *da = DirAccess::create_for_path(p_asset); -// if (!da) { -// memdelete(filesystem_da); -// ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Can't create directory: " + p_asset + "."); -// } -// bool file_exists = da->file_exists(p_asset); -// bool dir_exists = da->dir_exists(p_asset); -// if (!file_exists && !dir_exists) { -// memdelete(da); -// memdelete(filesystem_da); -// return ERR_FILE_NOT_FOUND; -// } - -// String base_dir = p_asset.get_base_dir().replace("res://", ""); -// String destination_dir; -// String destination; -// String asset_path; - -// bool create_framework = false; - -// if (p_is_framework && p_asset.ends_with(".dylib")) { -// // For iOS we need to turn .dylib into .framework -// // to be able to send application to AppStore -// asset_path = String("dylibs").plus_file(base_dir); - -// String file_name; - -// if (!p_custom_file_name) { -// file_name = p_asset.get_basename().get_file(); -// } else { -// file_name = *p_custom_file_name; -// } - -// String framework_name = file_name + ".framework"; - -// asset_path = asset_path.plus_file(framework_name); -// destination_dir = p_out_dir.plus_file(asset_path); -// destination = destination_dir.plus_file(file_name); -// create_framework = true; -// } else if (p_is_framework && (p_asset.ends_with(".framework") || p_asset.ends_with(".xcframework"))) { -// asset_path = String("dylibs").plus_file(base_dir); - -// String file_name; - -// if (!p_custom_file_name) { -// file_name = p_asset.get_file(); -// } else { -// file_name = *p_custom_file_name; -// } - -// asset_path = asset_path.plus_file(file_name); -// destination_dir = p_out_dir.plus_file(asset_path); -// destination = destination_dir; -// } else { -// asset_path = base_dir; - -// String file_name; - -// if (!p_custom_file_name) { -// file_name = p_asset.get_file(); -// } else { -// file_name = *p_custom_file_name; -// } - -// destination_dir = p_out_dir.plus_file(asset_path); -// asset_path = asset_path.plus_file(file_name); -// destination = p_out_dir.plus_file(asset_path); -// } - -// if (!filesystem_da->dir_exists(destination_dir)) { -// Error make_dir_err = filesystem_da->make_dir_recursive(destination_dir); -// if (make_dir_err) { -// memdelete(da); -// memdelete(filesystem_da); -// return make_dir_err; -// } -// } - -// Error err = dir_exists ? da->copy_dir(p_asset, destination) : da->copy(p_asset, destination); -// memdelete(da); -// if (err) { -// memdelete(filesystem_da); -// return err; -// } -// IOSExportAsset exported_asset = { binary_name.plus_file(asset_path), p_is_framework, p_should_embed }; -// r_exported_assets.push_back(exported_asset); - -// if (create_framework) { -// String file_name; - -// if (!p_custom_file_name) { -// file_name = p_asset.get_basename().get_file(); -// } else { -// file_name = *p_custom_file_name; -// } - -// String framework_name = file_name + ".framework"; - -// // Performing `install_name_tool -id @rpath/{name}.framework/{name} ./{name}` on dylib -// { -// List install_name_args; -// install_name_args.push_back("-id"); -// install_name_args.push_back(String("@rpath").plus_file(framework_name).plus_file(file_name)); -// install_name_args.push_back(destination); - -// OS::get_singleton()->execute("install_name_tool", install_name_args, true); -// } - -// // Creating Info.plist -// { -// String info_plist_format = "\n" -// "\n" -// "\n" -// "\n" -// "CFBundleShortVersionString\n" -// "1.0\n" -// "CFBundleIdentifier\n" -// "com.gdnative.framework.$name\n" -// "CFBundleName\n" -// "$name\n" -// "CFBundleExecutable\n" -// "$name\n" -// "DTPlatformName\n" -// "iphoneos\n" -// "CFBundleInfoDictionaryVersion\n" -// "6.0\n" -// "CFBundleVersion\n" -// "1\n" -// "CFBundlePackageType\n" -// "FMWK\n" -// "MinimumOSVersion\n" -// "10.0\n" -// "\n" -// ""; - -// String info_plist = info_plist_format.replace("$name", file_name); - -// FileAccess *f = FileAccess::open(destination_dir.plus_file("Info.plist"), FileAccess::WRITE); -// if (f) { -// f->store_string(info_plist); -// f->close(); -// memdelete(f); -// } -// } -// } - -// memdelete(filesystem_da); - -// return OK; -//} - -//Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector &p_assets, bool p_is_framework, bool p_should_embed, Vector &r_exported_assets) { -// for (int f_idx = 0; f_idx < p_assets.size(); ++f_idx) { -// String asset = p_assets[f_idx]; -// if (!asset.begins_with("res://")) { -// // either SDK-builtin or already a part of the export template -// IOSExportAsset exported_asset = { asset, p_is_framework, p_should_embed }; -// r_exported_assets.push_back(exported_asset); -// } else { -// Error err = _copy_asset(p_out_dir, asset, nullptr, p_is_framework, p_should_embed, r_exported_assets); -// ERR_FAIL_COND_V(err, err); -// } -// } - -// return OK; -//} - -//Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector &p_libraries, Vector &r_exported_assets) { -// Vector> export_plugins = EditorExport::get_singleton()->get_export_plugins(); -// for (int i = 0; i < export_plugins.size(); i++) { -// Vector linked_frameworks = export_plugins[i]->get_ios_frameworks(); -// Error err = _export_additional_assets(p_out_dir, linked_frameworks, true, false, r_exported_assets); -// ERR_FAIL_COND_V(err, err); - -// Vector embedded_frameworks = export_plugins[i]->get_ios_embedded_frameworks(); -// err = _export_additional_assets(p_out_dir, embedded_frameworks, true, true, r_exported_assets); -// ERR_FAIL_COND_V(err, err); - -// Vector project_static_libs = export_plugins[i]->get_ios_project_static_libs(); -// for (int j = 0; j < project_static_libs.size(); j++) { -// project_static_libs.write[j] = project_static_libs[j].get_file(); // Only the file name as it's copied to the project -// } -// err = _export_additional_assets(p_out_dir, project_static_libs, true, true, r_exported_assets); -// ERR_FAIL_COND_V(err, err); - -// Vector ios_bundle_files = export_plugins[i]->get_ios_bundle_files(); -// err = _export_additional_assets(p_out_dir, ios_bundle_files, false, false, r_exported_assets); -// ERR_FAIL_COND_V(err, err); -// } - -// Vector library_paths; -// for (int i = 0; i < p_libraries.size(); ++i) { -// library_paths.push_back(p_libraries[i].path); -// } -// Error err = _export_additional_assets(p_out_dir, library_paths, true, true, r_exported_assets); -// ERR_FAIL_COND_V(err, err); - -// return OK; -//} - -//Vector EditorExportPlatformIOS::_get_preset_architectures(const Ref &p_preset) { -// Vector all_archs = _get_supported_architectures(); -// Vector enabled_archs; -// for (int i = 0; i < all_archs.size(); ++i) { -// bool is_enabled = p_preset->get("architectures/" + all_archs[i].name); -// if (is_enabled) { -// enabled_archs.push_back(all_archs[i].name); -// } -// } -// return enabled_archs; -//} - -//Error EditorExportPlatformIOS::_export_ios_plugins(const Ref &p_preset, IOSConfigData &p_config_data, const String &dest_dir, Vector &r_exported_assets, bool p_debug) { -// String plugin_definition_cpp_code; -// String plugin_initialization_cpp_code; -// String plugin_deinitialization_cpp_code; - -// Vector plugin_linked_dependencies; -// Vector plugin_embedded_dependencies; -// Vector plugin_files; - -// Vector enabled_plugins = get_enabled_plugins(p_preset); - -// Vector added_linked_dependenciy_names; -// Vector added_embedded_dependenciy_names; -// HashMap plist_values; - -// Error err; - -// for (int i = 0; i < enabled_plugins.size(); i++) { -// PluginConfig plugin = enabled_plugins[i]; - -// // Export plugin binary. -// if (!plugin.supports_targets) { -// err = _copy_asset(dest_dir, plugin.binary, nullptr, true, true, r_exported_assets); -// } else { -// String plugin_binary_dir = plugin.binary.get_base_dir(); -// String plugin_name_prefix = plugin.binary.get_basename().get_file(); -// String plugin_file = plugin_name_prefix + "." + (p_debug ? "debug" : "release") + ".a"; -// String result_file_name = plugin.binary.get_file(); - -// err = _copy_asset(dest_dir, plugin_binary_dir.plus_file(plugin_file), &result_file_name, true, true, r_exported_assets); -// } - -// ERR_FAIL_COND_V(err, err); - -// // Adding dependencies. -// // Use separate container for names to check for duplicates. -// for (int j = 0; j < plugin.linked_dependencies.size(); j++) { -// String dependency = plugin.linked_dependencies[j]; -// String name = dependency.get_file(); - -// if (added_linked_dependenciy_names.has(name)) { -// continue; -// } - -// added_linked_dependenciy_names.push_back(name); -// plugin_linked_dependencies.push_back(dependency); -// } - -// for (int j = 0; j < plugin.system_dependencies.size(); j++) { -// String dependency = plugin.system_dependencies[j]; -// String name = dependency.get_file(); - -// if (added_linked_dependenciy_names.has(name)) { -// continue; -// } - -// added_linked_dependenciy_names.push_back(name); -// plugin_linked_dependencies.push_back(dependency); -// } - -// for (int j = 0; j < plugin.embedded_dependencies.size(); j++) { -// String dependency = plugin.embedded_dependencies[j]; -// String name = dependency.get_file(); - -// if (added_embedded_dependenciy_names.has(name)) { -// continue; -// } - -// added_embedded_dependenciy_names.push_back(name); -// plugin_embedded_dependencies.push_back(dependency); -// } - -// plugin_files.append_array(plugin.files_to_copy); - -// // Capabilities -// // Also checking for duplicates. -// for (int j = 0; j < plugin.capabilities.size(); j++) { -// String capability = plugin.capabilities[j]; - -// if (p_config_data.capabilities.has(capability)) { -// continue; -// } - -// p_config_data.capabilities.push_back(capability); -// } - -// // Plist -// // Using hash map container to remove duplicates -// const String *K = nullptr; - -// while ((K = plugin.plist.next(K))) { -// String key = *K; -// String value = plugin.plist[key]; - -// if (key.is_empty() || value.is_empty()) { -// continue; -// } - -// plist_values[key] = value; -// } - -// // CPP Code -// String definition_comment = "// Plugin: " + plugin.name + "\n"; -// String initialization_method = plugin.initialization_method + "();\n"; -// String deinitialization_method = plugin.deinitialization_method + "();\n"; - -// plugin_definition_cpp_code += definition_comment + -// "extern void " + initialization_method + -// "extern void " + deinitialization_method + "\n"; - -// plugin_initialization_cpp_code += "\t" + initialization_method; -// plugin_deinitialization_cpp_code += "\t" + deinitialization_method; -// } - -// // Updating `Info.plist` -// { -// const String *K = nullptr; -// while ((K = plist_values.next(K))) { -// String key = *K; -// String value = plist_values[key]; - -// if (key.is_empty() || value.is_empty()) { -// continue; -// } - -// p_config_data.plist_content += "" + key + "" + value + "\n"; -// } -// } - -// // Export files -// { -// // Export linked plugin dependency -// err = _export_additional_assets(dest_dir, plugin_linked_dependencies, true, false, r_exported_assets); -// ERR_FAIL_COND_V(err, err); - -// // Export embedded plugin dependency -// err = _export_additional_assets(dest_dir, plugin_embedded_dependencies, true, true, r_exported_assets); -// ERR_FAIL_COND_V(err, err); - -// // Export plugin files -// err = _export_additional_assets(dest_dir, plugin_files, false, false, r_exported_assets); -// ERR_FAIL_COND_V(err, err); -// } - -// // Update CPP -// { -// Dictionary plugin_format; -// plugin_format["definition"] = plugin_definition_cpp_code; -// plugin_format["initialization"] = plugin_initialization_cpp_code; -// plugin_format["deinitialization"] = plugin_deinitialization_cpp_code; - -// String plugin_cpp_code = "\n// Godot Plugins\n" -// "void godot_ios_plugins_initialize();\n" -// "void godot_ios_plugins_deinitialize();\n" -// "// Exported Plugins\n\n" -// "$definition" -// "// Use Plugins\n" -// "void godot_ios_plugins_initialize() {\n" -// "$initialization" -// "}\n\n" -// "void godot_ios_plugins_deinitialize() {\n" -// "$deinitialization" -// "}\n"; - -// p_config_data.cpp_code += plugin_cpp_code.format(plugin_format, "$_"); -// } -// return OK; -//} - -//Error EditorExportPlatformIOS::export_project(const Ref &p_preset, bool p_debug, const String &p_path, int p_flags) { -// ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); - -// String src_pkg_name; -// String dest_dir = p_path.get_base_dir() + "/"; -// String binary_name = p_path.get_file().get_basename(); - -// EditorProgress ep("export", "Exporting for iOS", 5, true); - -// String team_id = p_preset->get("application/app_store_team_id"); -// ERR_FAIL_COND_V_MSG(team_id.length() == 0, ERR_CANT_OPEN, "App Store Team ID not specified - cannot configure the project."); - -// if (p_debug) { -// src_pkg_name = p_preset->get("custom_template/debug"); -// } else { -// src_pkg_name = p_preset->get("custom_template/release"); -// } - -// if (src_pkg_name == "") { -// String err; -// src_pkg_name = find_export_template("iphone.zip", &err); -// if (src_pkg_name == "") { -// EditorNode::add_io_error(err); -// return ERR_FILE_NOT_FOUND; -// } -// } - -// if (!DirAccess::exists(dest_dir)) { -// return ERR_FILE_BAD_PATH; -// } - -// DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); -// if (da) { -// String current_dir = da->get_current_dir(); - -// // remove leftovers from last export so they don't interfere -// // in case some files are no longer needed -// if (da->change_dir(dest_dir + binary_name + ".xcodeproj") == OK) { -// da->erase_contents_recursive(); -// } -// if (da->change_dir(dest_dir + binary_name) == OK) { -// da->erase_contents_recursive(); -// } - -// da->change_dir(current_dir); - -// if (!da->dir_exists(dest_dir + binary_name)) { -// Error err = da->make_dir(dest_dir + binary_name); -// if (err) { -// memdelete(da); -// return err; -// } -// } -// memdelete(da); -// } - -// if (ep.step("Making .pck", 0)) { -// return ERR_SKIP; -// } -// String pack_path = dest_dir + binary_name + ".pck"; -// Vector libraries; -// Error err = save_pack(p_preset, pack_path, &libraries); -// if (err) { -// return err; -// } - -// if (ep.step("Extracting and configuring Xcode project", 1)) { -// return ERR_SKIP; -// } - -// String library_to_use = "libgodot.iphone." + String(p_debug ? "debug" : "release") + ".fat.a"; - -// print_line("Static library: " + library_to_use); -// String pkg_name; -// if (p_preset->get("application/name") != "") { -// pkg_name = p_preset->get("application/name"); // app_name -// } else if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") { -// pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name")); -// } else { -// pkg_name = "Unnamed"; -// } - -// bool found_library = false; -// int total_size = 0; - -// const String project_file = "godot_ios.xcodeproj/project.pbxproj"; -// Set files_to_parse; -// files_to_parse.insert("godot_ios/godot_ios-Info.plist"); -// files_to_parse.insert(project_file); -// files_to_parse.insert("godot_ios/export_options.plist"); -// files_to_parse.insert("godot_ios/dummy.cpp"); -// files_to_parse.insert("godot_ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata"); -// files_to_parse.insert("godot_ios.xcodeproj/xcshareddata/xcschemes/godot_ios.xcscheme"); -// files_to_parse.insert("godot_ios/godot_ios.entitlements"); -// files_to_parse.insert("godot_ios/Launch Screen.storyboard"); - -// IOSConfigData config_data = { -// pkg_name, -// binary_name, -// _get_additional_plist_content(), -// String(" ").join(_get_preset_architectures(p_preset)), -// _get_linker_flags(), -// _get_cpp_code(), -// "", -// "", -// "", -// "", -// Vector() -// }; - -// Vector assets; - -// DirAccess *tmp_app_path = DirAccess::create_for_path(dest_dir); -// ERR_FAIL_COND_V(!tmp_app_path, ERR_CANT_CREATE); - -// print_line("Unzipping..."); -// FileAccess *src_f = nullptr; -// zlib_filefunc_def io = zipio_create_io_from_file(&src_f); -// unzFile src_pkg_zip = unzOpen2(src_pkg_name.utf8().get_data(), &io); -// if (!src_pkg_zip) { -// EditorNode::add_io_error("Could not open export template (not a zip file?):\n" + src_pkg_name); -// return ERR_CANT_OPEN; -// } - -// err = _export_ios_plugins(p_preset, config_data, dest_dir + binary_name, assets, p_debug); -// ERR_FAIL_COND_V(err, err); - -// //export rest of the files -// int ret = unzGoToFirstFile(src_pkg_zip); -// Vector project_file_data; -// while (ret == UNZ_OK) { -//#if defined(OSX_ENABLED) || defined(X11_ENABLED) -// bool is_execute = false; -//#endif - -// //get filename -// unz_file_info info; -// char fname[16384]; -// ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, nullptr, 0, nullptr, 0); - -// String file = fname; - -// print_line("READ: " + file); -// Vector data; -// data.resize(info.uncompressed_size); - -// //read -// unzOpenCurrentFile(src_pkg_zip); -// unzReadCurrentFile(src_pkg_zip, data.ptrw(), data.size()); -// unzCloseCurrentFile(src_pkg_zip); - -// //write - -// file = file.replace_first("iphone/", ""); - -// if (files_to_parse.has(file)) { -// _fix_config_file(p_preset, data, config_data, p_debug); -// } else if (file.begins_with("libgodot.iphone")) { -// if (file != library_to_use) { -// ret = unzGoToNextFile(src_pkg_zip); -// continue; //ignore! -// } -// found_library = true; -//#if defined(OSX_ENABLED) || defined(X11_ENABLED) -// is_execute = true; -//#endif -// file = "godot_ios.a"; -// } - -// if (file == project_file) { -// project_file_data = data; -// } - -// ///@TODO need to parse logo files - -// if (data.size() > 0) { -// file = file.replace("godot_ios", binary_name); - -// print_line("ADDING: " + file + " size: " + itos(data.size())); -// total_size += data.size(); - -// /* write it into our folder structure */ -// file = dest_dir + file; - -// /* make sure this folder exists */ -// String dir_name = file.get_base_dir(); -// if (!tmp_app_path->dir_exists(dir_name)) { -// print_line("Creating " + dir_name); -// Error dir_err = tmp_app_path->make_dir_recursive(dir_name); -// if (dir_err) { -// ERR_PRINT("Can't create '" + dir_name + "'."); -// unzClose(src_pkg_zip); -// memdelete(tmp_app_path); -// return ERR_CANT_CREATE; -// } -// } - -// /* write the file */ -// FileAccess *f = FileAccess::open(file, FileAccess::WRITE); -// if (!f) { -// ERR_PRINT("Can't write '" + file + "'."); -// unzClose(src_pkg_zip); -// memdelete(tmp_app_path); -// return ERR_CANT_CREATE; -// }; -// f->store_buffer(data.ptr(), data.size()); -// f->close(); -// memdelete(f); - -//#if defined(OSX_ENABLED) || defined(X11_ENABLED) -// if (is_execute) { -// // we need execute rights on this file -// chmod(file.utf8().get_data(), 0755); -// } -//#endif -// } - -// ret = unzGoToNextFile(src_pkg_zip); -// } - -// /* we're done with our source zip */ -// unzClose(src_pkg_zip); - -// if (!found_library) { -// ERR_PRINT("Requested template library '" + library_to_use + "' not found. It might be missing from your template archive."); -// memdelete(tmp_app_path); -// return ERR_FILE_NOT_FOUND; -// } - -// // Copy project static libs to the project -// Vector> export_plugins = EditorExport::get_singleton()->get_export_plugins(); -// for (int i = 0; i < export_plugins.size(); i++) { -// Vector project_static_libs = export_plugins[i]->get_ios_project_static_libs(); -// for (int j = 0; j < project_static_libs.size(); j++) { -// const String &static_lib_path = project_static_libs[j]; -// String dest_lib_file_path = dest_dir + static_lib_path.get_file(); -// Error lib_copy_err = tmp_app_path->copy(static_lib_path, dest_lib_file_path); -// if (lib_copy_err != OK) { -// ERR_PRINT("Can't copy '" + static_lib_path + "'."); -// memdelete(tmp_app_path); -// return lib_copy_err; -// } -// } -// } - -// String iconset_dir = dest_dir + binary_name + "/Images.xcassets/AppIcon.appiconset/"; -// err = OK; -// if (!tmp_app_path->dir_exists(iconset_dir)) { -// err = tmp_app_path->make_dir_recursive(iconset_dir); -// } -// memdelete(tmp_app_path); -// if (err) { -// return err; -// } - -// err = _export_icons(p_preset, iconset_dir); -// if (err) { -// return err; -// } - -// bool use_storyboard = p_preset->get("storyboard/use_launch_screen_storyboard"); - -// String launch_image_path = dest_dir + binary_name + "/Images.xcassets/LaunchImage.launchimage/"; -// String splash_image_path = dest_dir + binary_name + "/Images.xcassets/SplashImage.imageset/"; - -// DirAccess *launch_screen_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - -// if (!launch_screen_da) { -// return ERR_CANT_CREATE; -// } - -// if (use_storyboard) { -// print_line("Using Launch Storyboard"); - -// if (launch_screen_da->change_dir(launch_image_path) == OK) { -// launch_screen_da->erase_contents_recursive(); -// launch_screen_da->remove(launch_image_path); -// } - -// err = _export_loading_screen_file(p_preset, splash_image_path); -// } else { -// print_line("Using Launch Images"); - -// const String launch_screen_path = dest_dir + binary_name + "/Launch Screen.storyboard"; - -// launch_screen_da->remove(launch_screen_path); - -// if (launch_screen_da->change_dir(splash_image_path) == OK) { -// launch_screen_da->erase_contents_recursive(); -// launch_screen_da->remove(splash_image_path); -// } - -// err = _export_loading_screen_images(p_preset, launch_image_path); -// } - -// memdelete(launch_screen_da); - -// if (err) { -// return err; -// } - -// print_line("Exporting additional assets"); -// _export_additional_assets(dest_dir + binary_name, libraries, assets); -// _add_assets_to_project(p_preset, project_file_data, assets); -// String project_file_name = dest_dir + binary_name + ".xcodeproj/project.pbxproj"; -// FileAccess *f = FileAccess::open(project_file_name, FileAccess::WRITE); -// if (!f) { -// ERR_PRINT("Can't write '" + project_file_name + "'."); -// return ERR_CANT_CREATE; -// }; -// f->store_buffer(project_file_data.ptr(), project_file_data.size()); -// f->close(); -// memdelete(f); - -//#ifdef OSX_ENABLED -// if (ep.step("Code-signing dylibs", 2)) { -// return ERR_SKIP; -// } -// DirAccess *dylibs_dir = DirAccess::open(dest_dir + binary_name + "/dylibs"); -// ERR_FAIL_COND_V(!dylibs_dir, ERR_CANT_OPEN); -// CodesignData codesign_data(p_preset, p_debug); -// err = _walk_dir_recursive(dylibs_dir, _codesign, &codesign_data); -// memdelete(dylibs_dir); -// ERR_FAIL_COND_V(err, err); - -// if (ep.step("Making .xcarchive", 3)) { -// return ERR_SKIP; -// } -// String archive_path = p_path.get_basename() + ".xcarchive"; -// List archive_args; -// archive_args.push_back("-project"); -// archive_args.push_back(dest_dir + binary_name + ".xcodeproj"); -// archive_args.push_back("-scheme"); -// archive_args.push_back(binary_name); -// archive_args.push_back("-sdk"); -// archive_args.push_back("iphoneos"); -// archive_args.push_back("-configuration"); -// archive_args.push_back(p_debug ? "Debug" : "Release"); -// archive_args.push_back("-destination"); -// archive_args.push_back("generic/platform=iOS"); -// archive_args.push_back("archive"); -// archive_args.push_back("-archivePath"); -// archive_args.push_back(archive_path); -// err = OS::get_singleton()->execute("xcodebuild", archive_args, true); -// ERR_FAIL_COND_V(err, err); - -// if (ep.step("Making .ipa", 4)) { -// return ERR_SKIP; -// } -// List export_args; -// export_args.push_back("-exportArchive"); -// export_args.push_back("-archivePath"); -// export_args.push_back(archive_path); -// export_args.push_back("-exportOptionsPlist"); -// export_args.push_back(dest_dir + binary_name + "/export_options.plist"); -// export_args.push_back("-allowProvisioningUpdates"); -// export_args.push_back("-exportPath"); -// export_args.push_back(dest_dir); -// err = OS::get_singleton()->execute("xcodebuild", export_args, true); -// ERR_FAIL_COND_V(err, err); -//#else -// print_line(".ipa can only be built on macOS. Leaving Xcode project without building the package."); -//#endif - -// return OK; -//} - -//bool EditorExportPlatformIOS::can_export(const Ref &p_preset, String &r_error, bool &r_missing_templates) const { -// String err; -// bool valid = false; - -// // Look for export templates (first official, and if defined custom templates). - -// bool dvalid = exists_export_template("iphone.zip", &err); -// bool rvalid = dvalid; // Both in the same ZIP. - -// if (p_preset->get("custom_template/debug") != "") { -// dvalid = FileAccess::exists(p_preset->get("custom_template/debug")); -// if (!dvalid) { -// err += TTR("Custom debug template not found.") + "\n"; -// } -// } -// if (p_preset->get("custom_template/release") != "") { -// rvalid = FileAccess::exists(p_preset->get("custom_template/release")); -// if (!rvalid) { -// err += TTR("Custom release template not found.") + "\n"; -// } -// } - -// valid = dvalid || rvalid; -// r_missing_templates = !valid; - -// // Validate the rest of the configuration. - -// String team_id = p_preset->get("application/app_store_team_id"); -// if (team_id.length() == 0) { -// err += TTR("App Store Team ID not specified - cannot configure the project.") + "\n"; -// valid = false; -// } - -// String identifier = p_preset->get("application/bundle_identifier"); -// String pn_err; -// if (!is_package_name_valid(identifier, &pn_err)) { -// err += TTR("Invalid Identifier:") + " " + pn_err + "\n"; -// valid = false; -// } - -// for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) { -// IconInfo info = icon_infos[i]; -// String icon_path = p_preset->get(info.preset_key); -// if (icon_path.length() == 0) { -// if (info.is_required) { -// err += TTR("Required icon is not specified in the preset.") + "\n"; -// valid = false; -// } -// break; -// } -// } - -// String etc_error = test_etc2_or_pvrtc(); -// if (etc_error != String()) { -// valid = false; -// err += etc_error; -// } - -// if (!err.is_empty()) { -// r_error = err; -// } - -// return valid; -//} - -//EditorExportPlatformIOS::EditorExportPlatformIOS() { -// Ref img = memnew(Image(_iphone_logo)); -// logo.instance(); -// logo->create_from_image(img); - -// plugins_changed = true; -// quit_request = false; - -// check_for_changes_thread = Thread::create(_check_for_changes_poll_thread, this); -//} - -//EditorExportPlatformIOS::~EditorExportPlatformIOS() { -// quit_request = true; -// Thread::wait_to_finish(check_for_changes_thread); -// memdelete(check_for_changes_thread); -//} void register_iphone_exporter() { Ref platform; diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index dacae912b5b..c7d68019a10 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -691,10 +691,10 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive bool gl_initialization_error = false; - if (RasterizerOpenGLis_viable() == OK) { + if (RasterizerGLES3::is_viable() == OK) { attributes.majorVersion = 1; - RasterizerOpenGLregister_config(); - RasterizerOpenGLmake_current(); + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); } else { gl_initialization_error = true; } diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 5130630c183..889b0bbd027 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -32,678 +32,6 @@ #include "export_plugin.h" -/* - -class EditorHTTPServer : public Reference { -private: - Ref server; - Ref connection; - uint64_t time = 0; - uint8_t req_buf[4096]; - int req_pos = 0; - - void _clear_client() { - connection = Ref(); - memset(req_buf, 0, sizeof(req_buf)); - time = 0; - req_pos = 0; - } - -public: - EditorHTTPServer() { - server.instance(); - stop(); - } - - void stop() { - server->stop(); - _clear_client(); - } - - Error listen(int p_port, IP_Address p_address) { - return server->listen(p_port, p_address); - } - - bool is_listening() const { - return server->is_listening(); - } - - void _send_response() { - Vector psa = String((char *)req_buf).split("\r\n"); - int len = psa.size(); - ERR_FAIL_COND_MSG(len < 4, "Not enough response headers, got: " + itos(len) + ", expected >= 4."); - - Vector req = psa[0].split(" ", false); - ERR_FAIL_COND_MSG(req.size() < 2, "Invalid protocol or status code."); - - // Wrong protocol - ERR_FAIL_COND_MSG(req[0] != "GET" || req[2] != "HTTP/1.1", "Invalid method or HTTP version."); - - const String cache_path = EditorSettings::get_singleton()->get_cache_dir(); - const String basereq = "/tmp_js_export"; - String filepath; - String ctype; - if (req[1] == basereq + ".html") { - filepath = cache_path.plus_file(req[1].get_file()); - ctype = "text/html"; - } else if (req[1] == basereq + ".js") { - filepath = cache_path.plus_file(req[1].get_file()); - ctype = "application/javascript"; - } else if (req[1] == basereq + ".audio.worklet.js") { - filepath = cache_path.plus_file(req[1].get_file()); - ctype = "application/javascript"; - } else if (req[1] == basereq + ".worker.js") { - filepath = cache_path.plus_file(req[1].get_file()); - ctype = "application/javascript"; - } else if (req[1] == basereq + ".pck") { - filepath = cache_path.plus_file(req[1].get_file()); - ctype = "application/octet-stream"; - } else if (req[1] == basereq + ".png" || req[1] == "/favicon.png") { - // Also allow serving the generated favicon for a smoother loading experience. - if (req[1] == "/favicon.png") { - filepath = EditorSettings::get_singleton()->get_cache_dir().plus_file("favicon.png"); - } else { - filepath = basereq + ".png"; - } - ctype = "image/png"; - } else if (req[1] == basereq + ".side.wasm") { - filepath = cache_path.plus_file(req[1].get_file()); - ctype = "application/wasm"; - } else if (req[1] == basereq + ".wasm") { - filepath = cache_path.plus_file(req[1].get_file()); - ctype = "application/wasm"; - } else if (req[1].ends_with(".wasm")) { - filepath = cache_path.plus_file(req[1].get_file()); // TODO dangerous? - ctype = "application/wasm"; - } - if (filepath.is_empty() || !FileAccess::exists(filepath)) { - String s = "HTTP/1.1 404 Not Found\r\n"; - s += "Connection: Close\r\n"; - s += "\r\n"; - CharString cs = s.utf8(); - connection->put_data((const uint8_t *)cs.get_data(), cs.size() - 1); - return; - } - FileAccess *f = FileAccess::open(filepath, FileAccess::READ); - ERR_FAIL_COND(!f); - String s = "HTTP/1.1 200 OK\r\n"; - s += "Connection: Close\r\n"; - s += "Content-Type: " + ctype + "\r\n"; - s += "Access-Control-Allow-Origin: *\r\n"; - s += "Cross-Origin-Opener-Policy: same-origin\r\n"; - s += "Cross-Origin-Embedder-Policy: require-corp\r\n"; - s += "\r\n"; - CharString cs = s.utf8(); - Error err = connection->put_data((const uint8_t *)cs.get_data(), cs.size() - 1); - if (err != OK) { - memdelete(f); - ERR_FAIL(); - } - - while (true) { - uint8_t bytes[4096]; - int read = f->get_buffer(bytes, 4096); - if (read < 1) { - break; - } - err = connection->put_data(bytes, read); - if (err != OK) { - memdelete(f); - ERR_FAIL(); - } - } - memdelete(f); - } - - void poll() { - if (!server->is_listening()) { - return; - } - if (connection.is_null()) { - if (!server->is_connection_available()) { - return; - } - connection = server->take_connection(); - time = OS::get_singleton()->get_ticks_usec(); - } - if (OS::get_singleton()->get_ticks_usec() - time > 1000000) { - _clear_client(); - return; - } - if (connection->get_status() != StreamPeerTCP::STATUS_CONNECTED) { - return; - } - - while (true) { - char *r = (char *)req_buf; - int l = req_pos - 1; - if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') { - _send_response(); - _clear_client(); - return; - } - - int read = 0; - ERR_FAIL_COND(req_pos >= 4096); - Error err = connection->get_partial_data(&req_buf[req_pos], 1, read); - if (err != OK) { - // Got an error - _clear_client(); - return; - } else if (read != 1) { - // Busy, wait next poll - return; - } - req_pos += read; - } - } -}; - -class EditorExportPlatformJavaScript : public EditorExportPlatform { - GDCLASS(EditorExportPlatformJavaScript, EditorExportPlatform); - - Ref logo; - Ref run_icon; - Ref stop_icon; - int menu_options = 0; - - Ref server; - bool server_quit = false; - Mutex server_lock; - Thread *server_thread = nullptr; - - enum ExportMode { - EXPORT_MODE_NORMAL = 0, - EXPORT_MODE_THREADS = 1, - EXPORT_MODE_GDNATIVE = 2, - }; - - String _get_template_name(ExportMode p_mode, bool p_debug) const { - String name = "webassembly"; - switch (p_mode) { - case EXPORT_MODE_THREADS: - name += "_threads"; - break; - case EXPORT_MODE_GDNATIVE: - name += "_gdnative"; - break; - default: - break; - } - if (p_debug) { - name += "_debug.zip"; - } else { - name += "_release.zip"; - } - return name; - } - - void _fix_html(Vector &p_html, const Ref &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector p_shared_objects); - - static void _server_thread_poll(void *data); - -public: - virtual void get_preset_features(const Ref &p_preset, List *r_features) override; - - virtual void get_export_options(List *r_options) override; - - virtual String get_name() const override; - virtual String get_os_name() const override; - virtual Ref get_logo() const override; - - virtual bool can_export(const Ref &p_preset, String &r_error, bool &r_missing_templates) const override; - virtual List get_binary_extensions(const Ref &p_preset) const override; - virtual Error export_project(const Ref &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override; - - virtual bool poll_export() override; - virtual int get_options_count() const override; - virtual String get_option_label(int p_index) const override { return p_index ? TTR("Stop HTTP Server") : TTR("Run in Browser"); } - virtual String get_option_tooltip(int p_index) const override { return p_index ? TTR("Stop HTTP Server") : TTR("Run exported HTML in the system's default browser."); } - virtual Ref get_option_icon(int p_index) const override; - virtual Error run(const Ref &p_preset, int p_option, int p_debug_flags) override; - virtual Ref get_run_icon() const override; - - virtual void get_platform_features(List *r_features) override { - r_features->push_back("web"); - r_features->push_back(get_os_name()); - } - - virtual void resolve_platform_feature_priorities(const Ref &p_preset, Set &p_features) override { - } - - String get_debug_protocol() const override { return "ws://"; } - - EditorExportPlatformJavaScript(); - ~EditorExportPlatformJavaScript(); -}; - -void EditorExportPlatformJavaScript::_fix_html(Vector &p_html, const Ref &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector p_shared_objects) { - String str_template = String::utf8(reinterpret_cast(p_html.ptr()), p_html.size()); - String str_export; - Vector lines = str_template.split("\n"); - Vector flags; - String flags_json; - gen_export_flags(flags, p_flags); - flags_json = JSON::print(flags); - String libs; - for (int i = 0; i < p_shared_objects.size(); i++) { - libs += "\"" + p_shared_objects[i].path.get_file() + "\","; - } - - for (int i = 0; i < lines.size(); i++) { - String current_line = lines[i]; - current_line = current_line.replace("$GODOT_BASENAME", p_name); - current_line = current_line.replace("$GODOT_PROJECT_NAME", ProjectSettings::get_singleton()->get_setting("application/config/name")); - current_line = current_line.replace("$GODOT_HEAD_INCLUDE", p_preset->get("html/head_include")); - current_line = current_line.replace("$GODOT_FULL_WINDOW", p_preset->get("html/full_window_size") ? "true" : "false"); - current_line = current_line.replace("$GODOT_GDNATIVE_LIBS", libs); - current_line = current_line.replace("$GODOT_DEBUG_ENABLED", p_debug ? "true" : "false"); - current_line = current_line.replace("$GODOT_ARGS", flags_json); - str_export += current_line + "\n"; - } - - CharString cs = str_export.utf8(); - p_html.resize(cs.length()); - for (int i = 0; i < cs.length(); i++) { - p_html.write[i] = cs[i]; - } -} - -void EditorExportPlatformJavaScript::get_preset_features(const Ref &p_preset, List *r_features) { - if (p_preset->get("vram_texture_compression/for_desktop")) { - r_features->push_back("s3tc"); - } - - if (p_preset->get("vram_texture_compression/for_mobile")) { - String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name"); - if (driver == "OpenGL") { - r_features->push_back("etc"); - } else if (driver == "Vulkan") { - // FIXME: Review if this is correct. - r_features->push_back("etc2"); - } - } - ExportMode mode = (ExportMode)(int)p_preset->get("variant/export_type"); - if (mode == EXPORT_MODE_THREADS) { - r_features->push_back("threads"); - } else if (mode == EXPORT_MODE_GDNATIVE) { - r_features->push_back("wasm32"); - } -} - -void EditorExportPlatformJavaScript::get_export_options(List *r_options) { - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); - - r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "variant/export_type", PROPERTY_HINT_ENUM, "Regular,Threads,GDNative"), 0)); // Export type. - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_desktop"), true)); // S3TC - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_mobile"), false)); // ETC or ETC2, depending on renderer - - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_FILE, "*.html"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/head_include", PROPERTY_HINT_MULTILINE_TEXT), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "html/full_window_size"), true)); -} - -String EditorExportPlatformJavaScript::get_name() const { - return "HTML5"; -} - -String EditorExportPlatformJavaScript::get_os_name() const { - return "HTML5"; -} - -Ref EditorExportPlatformJavaScript::get_logo() const { - return logo; -} - -bool EditorExportPlatformJavaScript::can_export(const Ref &p_preset, String &r_error, bool &r_missing_templates) const { - String err; - bool valid = false; - ExportMode mode = (ExportMode)(int)p_preset->get("variant/export_type"); - - // Look for export templates (first official, and if defined custom templates). - bool dvalid = exists_export_template(_get_template_name(mode, true), &err); - bool rvalid = exists_export_template(_get_template_name(mode, false), &err); - - if (p_preset->get("custom_template/debug") != "") { - dvalid = FileAccess::exists(p_preset->get("custom_template/debug")); - if (!dvalid) { - err += TTR("Custom debug template not found.") + "\n"; - } - } - if (p_preset->get("custom_template/release") != "") { - rvalid = FileAccess::exists(p_preset->get("custom_template/release")); - if (!rvalid) { - err += TTR("Custom release template not found.") + "\n"; - } - } - - valid = dvalid || rvalid; - r_missing_templates = !valid; - - // Validate the rest of the configuration. - - if (p_preset->get("vram_texture_compression/for_mobile")) { - String etc_error = test_etc2(); - if (etc_error != String()) { - valid = false; - err += etc_error; - } - } - - if (!err.is_empty()) { - r_error = err; - } - - return valid; -} - -List EditorExportPlatformJavaScript::get_binary_extensions(const Ref &p_preset) const { - List list; - list.push_back("html"); - return list; -} - -Error EditorExportPlatformJavaScript::export_project(const Ref &p_preset, bool p_debug, const String &p_path, int p_flags) { - ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); - - String custom_debug = p_preset->get("custom_template/debug"); - String custom_release = p_preset->get("custom_template/release"); - String custom_html = p_preset->get("html/custom_html_shell"); - - String template_path = p_debug ? custom_debug : custom_release; - - template_path = template_path.strip_edges(); - - if (template_path == String()) { - ExportMode mode = (ExportMode)(int)p_preset->get("variant/export_type"); - template_path = find_export_template(_get_template_name(mode, p_debug)); - } - - if (!DirAccess::exists(p_path.get_base_dir())) { - return ERR_FILE_BAD_PATH; - } - - if (template_path != String() && !FileAccess::exists(template_path)) { - EditorNode::get_singleton()->show_warning(TTR("Template file not found:") + "\n" + template_path); - return ERR_FILE_NOT_FOUND; - } - - Vector shared_objects; - String pck_path = p_path.get_basename() + ".pck"; - Error error = save_pack(p_preset, pck_path, &shared_objects); - if (error != OK) { - EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + pck_path); - return error; - } - DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - for (int i = 0; i < shared_objects.size(); i++) { - String dst = p_path.get_base_dir().plus_file(shared_objects[i].path.get_file()); - error = da->copy(shared_objects[i].path, dst); - if (error != OK) { - EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + shared_objects[i].path.get_file()); - memdelete(da); - return error; - } - } - memdelete(da); - - FileAccess *src_f = nullptr; - zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - unzFile pkg = unzOpen2(template_path.utf8().get_data(), &io); - - if (!pkg) { - EditorNode::get_singleton()->show_warning(TTR("Could not open template for export:") + "\n" + template_path); - return ERR_FILE_NOT_FOUND; - } - - if (unzGoToFirstFile(pkg) != UNZ_OK) { - EditorNode::get_singleton()->show_warning(TTR("Invalid export template:") + "\n" + template_path); - unzClose(pkg); - return ERR_FILE_CORRUPT; - } - - do { - //get filename - unz_file_info info; - char fname[16384]; - unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); - - String file = fname; - - Vector data; - data.resize(info.uncompressed_size); - - //read - unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptrw(), data.size()); - unzCloseCurrentFile(pkg); - - //write - - if (file == "godot.html") { - if (!custom_html.is_empty()) { - continue; - } - _fix_html(data, p_preset, p_path.get_file().get_basename(), p_debug, p_flags, shared_objects); - file = p_path.get_file(); - - } else if (file == "godot.js") { - file = p_path.get_file().get_basename() + ".js"; - - } else if (file == "godot.worker.js") { - file = p_path.get_file().get_basename() + ".worker.js"; - - } else if (file == "godot.side.wasm") { - file = p_path.get_file().get_basename() + ".side.wasm"; - - } else if (file == "godot.audio.worklet.js") { - file = p_path.get_file().get_basename() + ".audio.worklet.js"; - - } else if (file == "godot.wasm") { - file = p_path.get_file().get_basename() + ".wasm"; - } - - String dst = p_path.get_base_dir().plus_file(file); - FileAccess *f = FileAccess::open(dst, FileAccess::WRITE); - if (!f) { - EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + dst); - unzClose(pkg); - return ERR_FILE_CANT_WRITE; - } - f->store_buffer(data.ptr(), data.size()); - memdelete(f); - - } while (unzGoToNextFile(pkg) == UNZ_OK); - unzClose(pkg); - - if (!custom_html.is_empty()) { - FileAccess *f = FileAccess::open(custom_html, FileAccess::READ); - if (!f) { - EditorNode::get_singleton()->show_warning(TTR("Could not read custom HTML shell:") + "\n" + custom_html); - return ERR_FILE_CANT_READ; - } - Vector buf; - buf.resize(f->get_len()); - f->get_buffer(buf.ptrw(), buf.size()); - memdelete(f); - _fix_html(buf, p_preset, p_path.get_file().get_basename(), p_debug, p_flags, shared_objects); - - f = FileAccess::open(p_path, FileAccess::WRITE); - if (!f) { - EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + p_path); - return ERR_FILE_CANT_WRITE; - } - f->store_buffer(buf.ptr(), buf.size()); - memdelete(f); - } - - Ref splash; - const String splash_path = String(GLOBAL_GET("application/boot_splash/image")).strip_edges(); - if (!splash_path.is_empty()) { - splash.instance(); - const Error err = splash->load(splash_path); - if (err) { - EditorNode::get_singleton()->show_warning(TTR("Could not read boot splash image file:") + "\n" + splash_path + "\n" + TTR("Using default boot splash image.")); - splash.unref(); - } - } - if (splash.is_null()) { - splash = Ref(memnew(Image(boot_splash_png))); - } - const String splash_png_path = p_path.get_base_dir().plus_file(p_path.get_file().get_basename() + ".png"); - if (splash->save_png(splash_png_path) != OK) { - EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + splash_png_path); - return ERR_FILE_CANT_WRITE; - } - - // Save a favicon that can be accessed without waiting for the project to finish loading. - // This way, the favicon can be displayed immediately when loading the page. - Ref favicon; - const String favicon_path = String(GLOBAL_GET("application/config/icon")).strip_edges(); - if (!favicon_path.is_empty()) { - favicon.instance(); - const Error err = favicon->load(favicon_path); - if (err) { - favicon.unref(); - } - } - - if (favicon.is_valid()) { - const String favicon_png_path = p_path.get_base_dir().plus_file("favicon.png"); - if (favicon->save_png(favicon_png_path) != OK) { - EditorNode::get_singleton()->show_warning(TTR("Could not write file:") + "\n" + favicon_png_path); - return ERR_FILE_CANT_WRITE; - } - } - - return OK; -} - -bool EditorExportPlatformJavaScript::poll_export() { - Ref preset; - - for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { - Ref ep = EditorExport::get_singleton()->get_export_preset(i); - if (ep->is_runnable() && ep->get_platform() == this) { - preset = ep; - break; - } - } - - int prev = menu_options; - menu_options = preset.is_valid(); - if (server->is_listening()) { - if (menu_options == 0) { - MutexLock lock(server_lock); - server->stop(); - } else { - menu_options += 1; - } - } - return menu_options != prev; -} - -Ref EditorExportPlatformJavaScript::get_option_icon(int p_index) const { - return p_index == 1 ? stop_icon : EditorExportPlatform::get_option_icon(p_index); -} - -int EditorExportPlatformJavaScript::get_options_count() const { - return menu_options; -} - -Error EditorExportPlatformJavaScript::run(const Ref &p_preset, int p_option, int p_debug_flags) { - if (p_option == 1) { - MutexLock lock(server_lock); - server->stop(); - return OK; - } - - const String basepath = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_js_export"); - Error err = export_project(p_preset, true, basepath + ".html", p_debug_flags); - if (err != OK) { - // Export generates several files, clean them up on failure. - DirAccess::remove_file_or_error(basepath + ".html"); - DirAccess::remove_file_or_error(basepath + ".js"); - DirAccess::remove_file_or_error(basepath + ".worker.js"); - DirAccess::remove_file_or_error(basepath + ".audio.worklet.js"); - DirAccess::remove_file_or_error(basepath + ".pck"); - DirAccess::remove_file_or_error(basepath + ".png"); - DirAccess::remove_file_or_error(basepath + ".side.wasm"); - DirAccess::remove_file_or_error(basepath + ".wasm"); - DirAccess::remove_file_or_error(EditorSettings::get_singleton()->get_cache_dir().plus_file("favicon.png")); - return err; - } - - const uint16_t bind_port = EDITOR_GET("export/web/http_port"); - // Resolve host if needed. - const String bind_host = EDITOR_GET("export/web/http_host"); - IP_Address bind_ip; - if (bind_host.is_valid_ip_address()) { - bind_ip = bind_host; - } else { - bind_ip = IP::get_singleton()->resolve_hostname(bind_host); - } - ERR_FAIL_COND_V_MSG(!bind_ip.is_valid(), ERR_INVALID_PARAMETER, "Invalid editor setting 'export/web/http_host': '" + bind_host + "'. Try using '127.0.0.1'."); - - // Restart server. - { - MutexLock lock(server_lock); - - server->stop(); - err = server->listen(bind_port, bind_ip); - } - ERR_FAIL_COND_V_MSG(err != OK, err, "Unable to start HTTP server."); - - OS::get_singleton()->shell_open(String("http://" + bind_host + ":" + itos(bind_port) + "/tmp_js_export.html")); - // FIXME: Find out how to clean up export files after running the successfully - // exported game. Might not be trivial. - return OK; -} - -Ref EditorExportPlatformJavaScript::get_run_icon() const { - return run_icon; -} - -void EditorExportPlatformJavaScript::_server_thread_poll(void *data) { - EditorExportPlatformJavaScript *ej = (EditorExportPlatformJavaScript *)data; - while (!ej->server_quit) { - OS::get_singleton()->delay_usec(1000); - { - MutexLock lock(ej->server_lock); - ej->server->poll(); - } - } -} - -EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() { - server.instance(); - server_thread = Thread::create(_server_thread_poll, this); - - Ref img = memnew(Image(_javascript_logo)); - logo.instance(); - logo->create_from_image(img); - - img = Ref(memnew(Image(_javascript_run_icon))); - run_icon.instance(); - run_icon->create_from_image(img); - - Ref theme = EditorNode::get_singleton()->get_editor_theme(); - if (theme.is_valid()) { - stop_icon = theme->get_icon("Stop", "EditorIcons"); - } else { - stop_icon.instance(); - } -} - -EditorExportPlatformJavaScript::~EditorExportPlatformJavaScript() { - server->stop(); - server_quit = true; - Thread::wait_to_finish(server_thread); - memdelete(server_thread); -} - -*/ void register_javascript_exporter() { EDITOR_DEF("export/web/http_host", "localhost"); EDITOR_DEF("export/web/http_port", 8060); diff --git a/platform/javascript/export/export_plugin.cpp b/platform/javascript/export/export_plugin.cpp index b98e87e7893..b4f93b9b44c 100644 --- a/platform/javascript/export/export_plugin.cpp +++ b/platform/javascript/export/export_plugin.cpp @@ -300,7 +300,7 @@ void EditorExportPlatformJavaScript::get_preset_features(const Refget("vram_texture_compression/for_mobile")) { String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name"); - if (driver == "OpenGL") { + if (driver == "OpenGL3") { r_features->push_back("etc"); } else if (driver == "Vulkan") { // FIXME: Review if this is correct. diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index 04da082b16c..a9e8fb64c37 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -381,7 +381,7 @@ def configure(env): # No pkgconfig file for glslang so far env.Append(LIBS=["glslang", "SPIRV"]) - env.Append(CPPDEFINES=["OPENGL_ENABLED"]) + env.Append(CPPDEFINES=["GLES3_ENABLED"]) env.Append(LIBS=["GL"]) env.Append(LIBS=["pthread"]) diff --git a/platform/linuxbsd/detect_prime_x11.cpp b/platform/linuxbsd/detect_prime_x11.cpp index f074c9e9d89..c775546f15c 100644 --- a/platform/linuxbsd/detect_prime_x11.cpp +++ b/platform/linuxbsd/detect_prime_x11.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #ifdef X11_ENABLED -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) #include "detect_prime_x11.h" diff --git a/platform/linuxbsd/detect_prime_x11.h b/platform/linuxbsd/detect_prime_x11.h index 0b548b849e7..88d00b3acdf 100644 --- a/platform/linuxbsd/detect_prime_x11.h +++ b/platform/linuxbsd/detect_prime_x11.h @@ -29,7 +29,7 @@ /*************************************************************************/ #ifdef X11_ENABLED -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) int detect_prime(); diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 4421c868d8f..d00a5794ca7 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -44,8 +44,8 @@ #include "servers/rendering/renderer_rd/renderer_compositor_rd.h" #endif -#if defined(OPENGL_ENABLED) -#include "drivers/opengl/rasterizer_opengl.h" +#if defined(GLES3_ENABLED) +#include "drivers/gles3/rasterizer_gles3.h" #endif #include @@ -889,7 +889,7 @@ void DisplayServerX11::delete_sub_window(WindowID p_id) { context_vulkan->window_destroy(p_id); } #endif -#ifdef OPENGL_ENABLED +#ifdef GLES3_ENABLED if (gl_manager) { gl_manager->window_destroy(p_id); } @@ -1064,7 +1064,7 @@ int DisplayServerX11::window_get_current_screen(WindowID p_window) const { } void DisplayServerX11::gl_window_make_current(DisplayServer::WindowID p_window_id) { -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (gl_manager) gl_manager->window_make_current(p_window_id); #endif @@ -2666,7 +2666,7 @@ void DisplayServerX11::_window_changed(XEvent *event) { context_vulkan->window_resize(window_id, wd.size.width, wd.size.height); } #endif -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (gl_manager) { gl_manager->window_resize(window_id, wd.size.width, wd.size.height); } @@ -3547,19 +3547,19 @@ void DisplayServerX11::process_events() { } void DisplayServerX11::release_rendering_thread() { -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) // gl_manager->release_current(); #endif } void DisplayServerX11::make_rendering_thread() { -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) // gl_manager->make_current(); #endif } void DisplayServerX11::swap_buffers() { -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (gl_manager) { gl_manager->swap_buffers(); } @@ -3710,7 +3710,7 @@ void DisplayServerX11::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mo } #endif -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (gl_manager) { gl_manager->set_use_vsync(p_vsync_mode == DisplayServer::VSYNC_ENABLED); } @@ -3724,7 +3724,7 @@ DisplayServer::VSyncMode DisplayServerX11::window_get_vsync_mode(WindowID p_wind return context_vulkan->get_vsync_mode(p_window); } #endif -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (gl_manager) { return gl_manager->is_using_vsync() ? DisplayServer::VSYNC_ENABLED : DisplayServer::VSYNC_DISABLED; } @@ -3738,8 +3738,8 @@ Vector DisplayServerX11::get_rendering_drivers_func() { #ifdef VULKAN_ENABLED drivers.push_back("vulkan"); #endif -#ifdef OPENGL_ENABLED - drivers.push_back("opengl"); +#ifdef GLES3_ENABLED + drivers.push_back("opengl3"); #endif return drivers; @@ -3924,8 +3924,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan window"); } #endif -#ifdef OPENGL_ENABLED - print_line("rendering_driver " + rendering_driver); +#ifdef GLES3_ENABLED if (gl_manager) { Error err = gl_manager->window_create(id, wd.x11_window, x11_display, p_rect.size.width, p_rect.size.height); ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create an OpenGL window"); @@ -4115,11 +4114,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode //TODO - do Vulkan and OpenGL support checks, driver selection and fallback rendering_driver = p_rendering_driver; -#ifndef _MSC_VER -//#warning Forcing vulkan rendering driver because OpenGL not implemented yet -//#warning Forcing opengl rendering driver because selecting properly is too much effort -#endif - bool driver_found = false; #if defined(VULKAN_ENABLED) if (rendering_driver == "vulkan") { @@ -4133,10 +4127,9 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode driver_found = true; } #endif - // Init context and rendering device -#if defined(OPENGL_ENABLED) - print_line("rendering_driver " + rendering_driver); - if (rendering_driver == "opengl") { + // Initialize context and rendering device. +#if defined(GLES3_ENABLED) + if (rendering_driver == "opengl3") { if (getenv("DRI_PRIME") == nullptr) { int use_prime = -1; @@ -4193,9 +4186,9 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode // gl_manager->set_use_vsync(current_videomode.use_vsync); if (true) { - // if (RasterizerOpenGL::is_viable() == OK) { - // RasterizerOpenGL::register_config(); - RasterizerOpenGL::make_current(); + // if (RasterizerGLES3::is_viable() == OK) { + // RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); } else { memdelete(gl_manager); gl_manager = nullptr; @@ -4411,8 +4404,8 @@ DisplayServerX11::~DisplayServerX11() { context_vulkan->window_destroy(E.key); } #endif -#ifdef OPENGL_ENABLED - if (rendering_driver == "opengl") { +#ifdef GLES3_ENABLED + if (rendering_driver == "opengl3") { gl_manager->window_destroy(E.key); } #endif @@ -4440,7 +4433,7 @@ DisplayServerX11::~DisplayServerX11() { } #endif -#ifdef OPENGL_ENABLED +#ifdef GLES3_ENABLED if (gl_manager) { memdelete(gl_manager); gl_manager = nullptr; diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index ba258299746..869ff386c5b 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -31,7 +31,7 @@ #ifndef DISPLAY_SERVER_X11_H #define DISPLAY_SERVER_X11_H -#include "drivers/opengl/rasterizer_platforms.h" +#include "drivers/gles3/rasterizer_platforms.h" #ifdef X11_ENABLED @@ -48,7 +48,7 @@ #include "servers/rendering/renderer_compositor.h" #include "servers/rendering_server.h" -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) #include "gl_manager_x11.h" #endif @@ -101,7 +101,7 @@ class DisplayServerX11 : public DisplayServer { Atom requested; int xdnd_version; -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) GLManager_X11 *gl_manager = nullptr; #endif #if defined(VULKAN_ENABLED) diff --git a/platform/linuxbsd/gl_manager_x11.cpp b/platform/linuxbsd/gl_manager_x11.cpp index 5928ff31472..e069e92ee66 100644 --- a/platform/linuxbsd/gl_manager_x11.cpp +++ b/platform/linuxbsd/gl_manager_x11.cpp @@ -31,7 +31,7 @@ #include "gl_manager_x11.h" #ifdef X11_ENABLED -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) #include #include @@ -175,12 +175,10 @@ Error GLManager_X11::_create_context(GLDisplay &gl_display) { switch (context_type) { case GLES_3_0_COMPATIBLE: { - // FIXME: Use `GLX_CONTEXT_CORE_PROFILE_BIT_ARB` instead of compatibility profile - // once deprecated API usages are fixed. static int context_attribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 3, - GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*|GLX_CONTEXT_DEBUG_BIT_ARB*/, None }; @@ -207,8 +205,6 @@ Error GLManager_X11::_create_context(GLDisplay &gl_display) { } Error GLManager_X11::window_create(DisplayServer::WindowID p_window_id, ::Window p_window, Display *p_display, int p_width, int p_height) { - print_line("window_create window id " + itos(p_window_id)); - // make sure vector is big enough... // we can mirror the external vector, it is simpler // to keep the IDs identical for fast lookup diff --git a/platform/linuxbsd/gl_manager_x11.h b/platform/linuxbsd/gl_manager_x11.h index e2e2545f3e7..fa2c8a9c842 100644 --- a/platform/linuxbsd/gl_manager_x11.h +++ b/platform/linuxbsd/gl_manager_x11.h @@ -33,9 +33,9 @@ #ifdef X11_ENABLED -#include "drivers/opengl/rasterizer_platforms.h" +#include "drivers/gles3/rasterizer_platforms.h" -#ifdef OPENGL_ENABLED +#ifdef GLES3_ENABLED #include "core/os/os.h" #include "core/templates/local_vector.h" @@ -124,7 +124,7 @@ public: ~GLManager_X11(); }; -#endif // OPENGL_ENABLED +#endif // GLES3_ENABLED #endif // X11_ENABLED #endif // GL_MANAGER_X11_H diff --git a/platform/osx/context_gl_osx.h b/platform/osx/context_gl_osx.h index ac455592171..77bae3247d1 100644 --- a/platform/osx/context_gl_osx.h +++ b/platform/osx/context_gl_osx.h @@ -31,7 +31,7 @@ #ifndef CONTEXT_GL_OSX_H #define CONTEXT_GL_OSX_H -#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) +#if defined(GLES3_ENABLED) || defined(GLES_ENABLED) #include "core/error/error_list.h" #include "core/os/os.h" @@ -41,7 +41,7 @@ #include class ContextGL_OSX { - bool opengl_3_context; + bool gles3_context; bool use_vsync; void *framework; @@ -66,7 +66,7 @@ public: void set_use_vsync(bool p_use); bool is_using_vsync() const; - ContextGL_OSX(id p_view, bool p_opengl_3_context); + ContextGL_OSX(id p_view, bool p_gles3_context); ~ContextGL_OSX(); }; diff --git a/platform/osx/context_gl_osx.mm b/platform/osx/context_gl_osx.mm index 88db1a296e0..eab9d8dc0c3 100644 --- a/platform/osx/context_gl_osx.mm +++ b/platform/osx/context_gl_osx.mm @@ -30,7 +30,7 @@ #include "context_gl_osx.h" -#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) +#if defined(GLES3_ENABLED) || defined(GLES_ENABLED) void ContextGL_OSX::release_current() { [NSOpenGLContext clearCurrentContext]; @@ -98,7 +98,7 @@ Error ContextGL_OSX::initialize() { ADD_ATTR(NSOpenGLPFADoubleBuffer); ADD_ATTR(NSOpenGLPFAClosestPolicy); - if (!opengl_3_context) { + if (!gles3_context) { ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy); } else { //we now need OpenGL 3 or better, maybe even change this to 3_3Core ? @@ -150,8 +150,8 @@ Error ContextGL_OSX::initialize() { return OK; } -ContextGL_OSX::ContextGL_OSX(id p_view, bool p_opengl_3_context) { - opengl_3_context = p_opengl_3_context; +ContextGL_OSX::ContextGL_OSX(id p_view, bool p_gles3_context) { + gles3_context = p_gles3_context; window_view = p_view; use_vsync = false; } diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 6c07c2416ee..d9b55631cdf 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -189,4 +189,4 @@ def configure(env): if not env["use_volk"]: env.Append(LINKFLAGS=["-L$VULKAN_SDK_PATH/MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/", "-lMoltenVK"]) - # env.Append(CPPDEFINES=['GLES_ENABLED', 'OPENGL_ENABLED']) + # env.Append(CPPDEFINES=['GLES_ENABLED', 'GLES3_ENABLED']) diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h index e8f28584892..96baeb4decd 100644 --- a/platform/osx/display_server_osx.h +++ b/platform/osx/display_server_osx.h @@ -36,7 +36,7 @@ #include "core/input/input.h" #include "servers/display_server.h" -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) #include "context_gl_osx.h" //TODO - reimplement OpenGLES #endif @@ -64,7 +64,7 @@ public: NSMenu *_get_dock_menu() const; void _menu_callback(id p_sender); -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) ContextGL_OSX *context_gles2; #endif #if defined(VULKAN_ENABLED) @@ -109,7 +109,7 @@ public: Vector mpath; -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) ContextGL_OSX *context_gles2 = nullptr; #endif Point2i mouse_pos; diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index b9d47a757c3..d89e64cd7da 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -45,7 +45,7 @@ #include #include -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) //TODO - reimplement OpenGLES #import @@ -166,7 +166,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) { [pwd.window_object makeKeyAndOrderFront:nil]; // Move focus back to main window if there is no parent or other windows left. } -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (DS_OSX->rendering_driver == "opengl_es") { //TODO - reimplement OpenGLES } @@ -271,7 +271,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) { layer.contentsScale = scale; } -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (DS_OSX->rendering_driver == "opengl_es") { //TODO - reimplement OpenGLES } @@ -405,7 +405,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) { } - (CALayer *)makeBackingLayer { -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (DS_OSX->rendering_driver == "opengl_es") { CALayer *layer = [[NSOpenGLLayer class] layer]; return layer; @@ -421,7 +421,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) { } - (void)updateLayer { -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (DS_OSX->rendering_driver == "opengl_es") { [super updateLayer]; //TODO - reimplement OpenGLES @@ -2586,7 +2586,7 @@ void DisplayServerOSX::_set_window_per_pixel_transparency_enabled(bool p_enabled //TODO - implement transparency for Vulkan } #endif -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (rendering_driver == "opengl_es") { //TODO - reimplement OpenGLES } @@ -2605,14 +2605,14 @@ void DisplayServerOSX::_set_window_per_pixel_transparency_enabled(bool p_enabled //TODO - implement transparency for Vulkan } #endif -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (rendering_driver == "opengl_es") { //TODO - reimplement OpenGLES } #endif wd.layered_window = false; } -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (rendering_driver == "opengl_es") { //TODO - reimplement OpenGLES } @@ -3475,7 +3475,7 @@ Vector DisplayServerOSX::get_rendering_drivers_func() { #if defined(VULKAN_ENABLED) drivers.push_back("vulkan"); #endif -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) drivers.push_back("opengl_es"); #endif @@ -3579,7 +3579,7 @@ DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, V } } #endif -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (rendering_driver == "opengl_es") { //TODO - reimplement OpenGLES } @@ -3600,7 +3600,7 @@ DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, V layer.contentsScale = scale; } -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (rendering_driver == "opengl_es") { //TODO - reimplement OpenGLES } @@ -3758,7 +3758,7 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode #endif rendering_driver = "vulkan"; -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (rendering_driver == "opengl_es") { //TODO - reimplement OpenGLES } @@ -3787,7 +3787,7 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode } show_window(MAIN_WINDOW_ID); -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (rendering_driver == "opengl_es") { //TODO - reimplement OpenGLES } @@ -3820,7 +3820,7 @@ DisplayServerOSX::~DisplayServerOSX() { } //destroy drivers -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) if (rendering_driver == "opengl_es") { //TODO - reimplement OpenGLES } diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 2d355f5f421..1114f5359a9 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -175,9 +175,9 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a } if (opengl_api_type == ContextEGL_UWP::GLES_2_0) { - if (RasterizerOpenGLis_viable() == OK) { - RasterizerOpenGLregister_config(); - RasterizerOpenGLmake_current(); + if (RasterizerGLES3::is_viable() == OK) { + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); } else { gl_initialization_error = true; } @@ -319,7 +319,7 @@ void OS_UWP::finalize() { rendering_server->finish(); memdelete(rendering_server); -#ifdef OPENGL_ENABLED +#ifdef GLES3_ENABLED if (gl_context) memdelete(gl_context); #endif diff --git a/platform/windows/context_gl_windows.cpp b/platform/windows/context_gl_windows.cpp deleted file mode 100644 index 74b12cbb3ba..00000000000 --- a/platform/windows/context_gl_windows.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/*************************************************************************/ -/* context_gl_windows.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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. */ -/*************************************************************************/ - -#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) - -// Author: Juan Linietsky , (C) 2008 - -#include "context_gl_windows.h" - -#include - -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 - -#if defined(__GNUC__) -// Workaround GCC warning from -Wcast-function-type. -#define wglGetProcAddress (void *)wglGetProcAddress -#endif - -typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int *); - -void ContextGL_Windows::release_current() { - wglMakeCurrent(hDC, nullptr); -} - -void ContextGL_Windows::make_current() { - wglMakeCurrent(hDC, hRC); -} - -int ContextGL_Windows::get_window_width() { - return OS::get_singleton()->get_video_mode().width; -} - -int ContextGL_Windows::get_window_height() { - return OS::get_singleton()->get_video_mode().height; -} - -void ContextGL_Windows::swap_buffers() { - SwapBuffers(hDC); -} - -void ContextGL_Windows::set_use_vsync(bool p_use) { - if (wglSwapIntervalEXT) { - int swap_interval = p_use ? 1 : 0; - wglSwapIntervalEXT(swap_interval); - } - - use_vsync = p_use; -} - -bool ContextGL_Windows::is_using_vsync() const { - return use_vsync; -} - -#define _WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 - -Error ContextGL_Windows::initialize() { - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor - 1, - PFD_DRAW_TO_WINDOW | // Format Must Support Window - PFD_SUPPORT_OPENGL | // Format Must Support OpenGL - PFD_DOUBLEBUFFER, - (BYTE)PFD_TYPE_RGBA, - (BYTE)(OS::get_singleton()->is_layered_allowed() ? 32 : 24), - (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Color Bits Ignored - (BYTE)(OS::get_singleton()->is_layered_allowed() ? 8 : 0), // Alpha Buffer - (BYTE)0, // Shift Bit Ignored - (BYTE)0, // No Accumulation Buffer - (BYTE)0, (BYTE)0, (BYTE)0, (BYTE)0, // Accumulation Bits Ignored - (BYTE)24, // 24Bit Z-Buffer (Depth Buffer) - (BYTE)0, // No Stencil Buffer - (BYTE)0, // No Auxiliary Buffer - (BYTE)PFD_MAIN_PLANE, // Main Drawing Layer - (BYTE)0, // Reserved - 0, 0, 0 // Layer Masks Ignored - }; - - hDC = GetDC(hWnd); - if (!hDC) { - return ERR_CANT_CREATE; // Return FALSE - } - - pixel_format = ChoosePixelFormat(hDC, &pfd); - if (!pixel_format) // Did Windows Find A Matching Pixel Format? - { - return ERR_CANT_CREATE; // Return FALSE - } - - BOOL ret = SetPixelFormat(hDC, pixel_format, &pfd); - if (!ret) // Are We Able To Set The Pixel Format? - { - return ERR_CANT_CREATE; // Return FALSE - } - - hRC = wglCreateContext(hDC); - if (!hRC) // Are We Able To Get A Rendering Context? - { - return ERR_CANT_CREATE; // Return FALSE - } - - wglMakeCurrent(hDC, hRC); - - if (opengl_3_context) { - int attribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - //and it shall be forward compatible so that we can only use up to date functionality - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/, - 0 - }; //zero indicates the end of the array - - PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method - wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); - - if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported - { - wglDeleteContext(hRC); - return ERR_CANT_CREATE; - } - - HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs); - if (!new_hRC) { - wglDeleteContext(hRC); - return ERR_CANT_CREATE; // Return false - } - wglMakeCurrent(hDC, nullptr); - wglDeleteContext(hRC); - hRC = new_hRC; - - if (!wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context - { - return ERR_CANT_CREATE; // Return FALSE - } - } - - wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); - wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT"); - //glWrapperInit(wrapper_get_proc_address); - - return OK; -} - -ContextGL_Windows::ContextGL_Windows(HWND hwnd, bool p_opengl_3_context) { - opengl_3_context = p_opengl_3_context; - hWnd = hwnd; - use_vsync = false; - pixel_format = 0; -} - -ContextGL_Windows::~ContextGL_Windows() { -} - -#endif diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 4740181df00..22fbbeb74f4 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -279,7 +279,7 @@ def configure_msvc(env, manual_msvc_config): if not env["use_volk"]: LIBS += ["vulkan"] - env.AppendUnique(CPPDEFINES=["OPENGL_ENABLED"]) + env.AppendUnique(CPPDEFINES=["GLES3_ENABLED"]) LIBS += ["opengl32"] env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS]) @@ -453,7 +453,7 @@ def configure_mingw(env): if not env["use_volk"]: env.Append(LIBS=["vulkan"]) - env.Append(CPPDEFINES=["OPENGL_ENABLED"]) + env.Append(CPPDEFINES=["GLES3_ENABLED"]) env.Append(LIBS=["opengl32"]) env.Append(CPPDEFINES=["MINGW_ENABLED", ("MINGW_HAS_SECURE_API", 1)]) diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index fda0bb16273..e2c99516921 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -38,8 +38,8 @@ #include -#if defined(OPENGL_ENABLED) -#include "drivers/opengl/rasterizer_opengl.h" +#if defined(GLES3_ENABLED) +#include "drivers/gles3/rasterizer_gles3.h" #endif static String format_error_message(DWORD id) { @@ -537,8 +537,8 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) { context_vulkan->window_destroy(p_window); } #endif -#ifdef OPENGL_ENABLED - if (rendering_driver == "opengl") { +#ifdef GLES3_ENABLED + if (rendering_driver == "opengl3") { gl_manager->window_destroy(p_window); } #endif @@ -552,7 +552,7 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) { } void DisplayServerWindows::gl_window_make_current(DisplayServer::WindowID p_window_id) { -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) gl_manager->window_make_current(p_window_id); #endif } @@ -827,8 +827,8 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo context_vulkan->window_resize(p_window, w, h); } #endif -#if defined(OPENGL_ENABLED) - if (rendering_driver == "opengl") { +#if defined(GLES3_ENABLED) + if (rendering_driver == "opengl3") { gl_manager->window_resize(p_window, w, h); } #endif @@ -1611,7 +1611,7 @@ void DisplayServerWindows::make_rendering_thread() { } void DisplayServerWindows::swap_buffers() { -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) gl_manager->swap_buffers(); #endif } @@ -3110,9 +3110,8 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, } #endif -#ifdef OPENGL_ENABLED - print_line("rendering_driver " + rendering_driver); - if (rendering_driver == "opengl") { +#ifdef GLES3_ENABLED + if (rendering_driver == "opengl3") { Error err = gl_manager->window_create(id, wd.hWnd, hInstance, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top); ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Failed to create an OpenGL window."); } @@ -3326,8 +3325,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win use_raw_input = false; } - print_line("rendering_driver " + rendering_driver); - #if defined(VULKAN_ENABLED) if (rendering_driver == "vulkan") { context_vulkan = memnew(VulkanContextWindows); @@ -3340,9 +3337,9 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } #endif // Init context and rendering device -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) - if (rendering_driver == "opengl") { + if (rendering_driver == "opengl3") { GLManager_Windows::ContextType opengl_api_type = GLManager_Windows::GLES_3_0_COMPATIBLE; gl_manager = memnew(GLManager_Windows(opengl_api_type)); @@ -3355,42 +3352,10 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } // gl_manager->set_use_vsync(current_videomode.use_vsync); - - if (true) { - RasterizerOpenGL::make_current(); - } else { - memdelete(gl_manager); - gl_manager = nullptr; - r_error = ERR_UNAVAILABLE; - return; - } + RasterizerGLES3::make_current(); } #endif - /* -#if defined(OPENGL_ENABLED) - if (rendering_driver_index == VIDEO_DRIVER_GLES2) { - context_gles2 = memnew(ContextGL_Windows(hWnd, false)); - - if (context_gles2->initialize() != OK) { - memdelete(context_gles2); - context_gles2 = nullptr; - ERR_FAIL_V(ERR_UNAVAILABLE); - } - - context_gles2->set_use_vsync(video_mode.use_vsync); - - if (RasterizerOpenGL::is_viable() == OK) { - RasterizerOpenGL::register_config(); - RasterizerOpenGL::make_current(); - } else { - memdelete(context_gles2); - context_gles2 = nullptr; - ERR_FAIL_V(ERR_UNAVAILABLE); - } - } -#endif - */ Point2i window_position( (screen_get_size(0).width - p_resolution.width) / 2, (screen_get_size(0).height - p_resolution.height) / 2); @@ -3448,8 +3413,8 @@ Vector DisplayServerWindows::get_rendering_drivers_func() { #ifdef VULKAN_ENABLED drivers.push_back("vulkan"); #endif -#ifdef OPENGL_ENABLED - drivers.push_back("opengl"); +#ifdef GLES3_ENABLED + drivers.push_back("opengl3"); #endif return drivers; @@ -3479,7 +3444,7 @@ DisplayServerWindows::~DisplayServerWindows() { SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc); }; -#ifdef OPENGL_ENABLED +#ifdef GLES3_ENABLED // destroy windows .. NYI? #endif @@ -3511,7 +3476,7 @@ DisplayServerWindows::~DisplayServerWindows() { if (restore_mouse_trails > 1) { SystemParametersInfoA(SPI_SETMOUSETRAILS, restore_mouse_trails, 0, 0); } -#ifdef OPENGL_ENABLED +#ifdef GLES3_ENABLED if (gl_manager) { memdelete(gl_manager); gl_manager = nullptr; diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 86f47eabc81..8e2c346d5bd 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -56,7 +56,7 @@ #include "platform/windows/vulkan_context_win.h" #endif -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) #include "gl_manager_windows.h" #endif @@ -304,7 +304,7 @@ class DisplayServerWindows : public DisplayServer { int old_x, old_y; Point2i center; -#if defined(OPENGL_ENABLED) +#if defined(GLES3_ENABLED) GLManager_Windows *gl_manager; #endif diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp index 8a79da987bc..98205d62829 100644 --- a/platform/windows/gl_manager_windows.cpp +++ b/platform/windows/gl_manager_windows.cpp @@ -31,7 +31,7 @@ #include "gl_manager_windows.h" #ifdef WINDOWS_ENABLED -#ifdef OPENGL_ENABLED +#ifdef GLES3_ENABLED #include #include @@ -129,50 +129,46 @@ Error GLManager_Windows::_create_context(GLWindow &win, GLDisplay &gl_display) { wglMakeCurrent(hDC, gl_display.hRC); - if (opengl_3_context) { - int attribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - //and it shall be forward compatible so that we can only use up to date functionality - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/, - 0 - }; //zero indicates the end of the array + int attribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + //and it shall be forward compatible so that we can only use up to date functionality + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/, + 0 + }; //zero indicates the end of the array - PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method - wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method + wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); - if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported - { - wglDeleteContext(gl_display.hRC); - gl_display.hRC = 0; - return ERR_CANT_CREATE; - } - - HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs); - if (!new_hRC) { - wglDeleteContext(gl_display.hRC); - gl_display.hRC = 0; - return ERR_CANT_CREATE; // Return false - } - wglMakeCurrent(hDC, nullptr); + if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported + { wglDeleteContext(gl_display.hRC); - gl_display.hRC = new_hRC; + gl_display.hRC = 0; + return ERR_CANT_CREATE; + } - if (!wglMakeCurrent(hDC, gl_display.hRC)) // Try To Activate The Rendering Context - { - wglDeleteContext(gl_display.hRC); - gl_display.hRC = 0; - return ERR_CANT_CREATE; // Return FALSE - } + HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs); + if (!new_hRC) { + wglDeleteContext(gl_display.hRC); + gl_display.hRC = 0; + return ERR_CANT_CREATE; // Return false + } + wglMakeCurrent(hDC, nullptr); + wglDeleteContext(gl_display.hRC); + gl_display.hRC = new_hRC; + + if (!wglMakeCurrent(hDC, gl_display.hRC)) // Try To Activate The Rendering Context + { + wglDeleteContext(gl_display.hRC); + gl_display.hRC = 0; + return ERR_CANT_CREATE; // Return FALSE } return OK; } Error GLManager_Windows::window_create(DisplayServer::WindowID p_window_id, HWND p_hwnd, HINSTANCE p_hinstance, int p_width, int p_height) { - print_line("window_create window id " + itos(p_window_id)); - HDC hdc = GetDC(p_hwnd); if (!hdc) { return ERR_CANT_CREATE; // Return FALSE @@ -349,5 +345,5 @@ GLManager_Windows::~GLManager_Windows() { release_current(); } -#endif // OPENGL_ENABLED +#endif // GLES3_ENABLED #endif // WINDOWS diff --git a/platform/windows/gl_manager_windows.h b/platform/windows/gl_manager_windows.h index 53557cf68e4..9733a57420a 100644 --- a/platform/windows/gl_manager_windows.h +++ b/platform/windows/gl_manager_windows.h @@ -31,7 +31,7 @@ #ifndef GL_MANAGER_WINDOWS_H #define GL_MANAGER_WINDOWS_H -#if defined(WINDOWS_ENABLED) && defined(OPENGL_ENABLED) +#if defined(WINDOWS_ENABLED) && defined(GLES3_ENABLED) #include "core/error/error_list.h" #include "core/os/os.h" @@ -76,7 +76,6 @@ private: LocalVector _displays; GLWindow *_current_window; - bool opengl_3_context = false; PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT; @@ -123,6 +122,6 @@ public: ~GLManager_Windows(); }; -#endif // defined(WINDOWS_ENABLED) && defined(OPENGL_ENABLED) +#endif // defined(WINDOWS_ENABLED) && defined(GLES3_ENABLED) #endif // GL_MANAGER_WINDOWS_H diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index ce3620b2d06..0f5af964173 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -2722,7 +2722,7 @@ void RenderForwardClustered::_geometry_instance_update(GeometryInstance *p_geome } break; #if 0 case RS::INSTANCE_IMMEDIATE: { - RasterizerStorageOpenGL::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base); + RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base); ERR_CONTINUE(!immediate); _add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass); diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp index 7716705666a..95f5b468317 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp @@ -2440,7 +2440,7 @@ void RenderForwardMobile::_geometry_instance_update(GeometryInstance *p_geometry } break; #if 0 case RS::INSTANCE_IMMEDIATE: { - RasterizerStorageOpenGL::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base); + RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base); ERR_CONTINUE(!immediate); _add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass); diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 723c5ada3f5..c3d57a13adf 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -129,7 +129,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { timestamp_vp_map[rt_id] = p_viewport->self; } - if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl") { + if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl3") { // This is currently needed for GLES to keep the current window being rendered to up to date DisplayServer::get_singleton()->gl_window_make_current(p_viewport->viewport_to_screen); } diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index f43b9352b4b..1b169497688 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -2957,6 +2957,43 @@ RenderingServer::RenderingServer() { ProjectSettings::get_singleton()->set_custom_property_info("rendering/limits/cluster_builder/max_clustered_elements", PropertyInfo(Variant::FLOAT, "rendering/limits/cluster_builder/max_clustered_elements", PROPERTY_HINT_RANGE, "32,8192,1")); GLOBAL_DEF_RST("rendering/xr/enabled", false); + + GLOBAL_DEF_RST("rendering/2d/options/use_software_skinning", true); + GLOBAL_DEF_RST("rendering/2d/options/ninepatch_mode", 1); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/options/ninepatch_mode", PropertyInfo(Variant::INT, "rendering/2d/options/ninepatch_mode", PROPERTY_HINT_ENUM, "Fixed,Scaling")); + + GLOBAL_DEF_RST("rendering/2d/opengl/batching_send_null", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/batching_send_null", PropertyInfo(Variant::INT, "rendering/2d/opengl/batching_send_null", PROPERTY_HINT_ENUM, "Default (On),Off,On")); + GLOBAL_DEF_RST("rendering/2d/opengl/batching_stream", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/batching_stream", PropertyInfo(Variant::INT, "rendering/2d/opengl/batching_stream", PROPERTY_HINT_ENUM, "Default (Off),Off,On")); + GLOBAL_DEF_RST("rendering/2d/opengl/legacy_orphan_buffers", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/legacy_orphan_buffers", PropertyInfo(Variant::INT, "rendering/2d/opengl/legacy_orphan_buffers", PROPERTY_HINT_ENUM, "Default (On),Off,On")); + GLOBAL_DEF_RST("rendering/2d/opengl/legacy_stream", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/legacy_stream", PropertyInfo(Variant::INT, "rendering/2d/opengl/legacy_stream", PROPERTY_HINT_ENUM, "Default (On),Off,On")); + + GLOBAL_DEF("rendering/batching/options/use_batching", false); + GLOBAL_DEF_RST("rendering/batching/options/use_batching_in_editor", false); + GLOBAL_DEF("rendering/batching/options/single_rect_fallback", false); + GLOBAL_DEF("rendering/batching/parameters/max_join_item_commands", 16); + GLOBAL_DEF("rendering/batching/parameters/colored_vertex_format_threshold", 0.25f); + GLOBAL_DEF("rendering/batching/lights/scissor_area_threshold", 1.0f); + GLOBAL_DEF("rendering/batching/lights/max_join_items", 32); + GLOBAL_DEF("rendering/batching/parameters/batch_buffer_size", 16384); + GLOBAL_DEF("rendering/batching/parameters/item_reordering_lookahead", 4); + GLOBAL_DEF("rendering/batching/debug/flash_batching", false); + GLOBAL_DEF("rendering/batching/debug/diagnose_frame", false); + GLOBAL_DEF("rendering/gles2/compatibility/disable_half_float", false); + GLOBAL_DEF("rendering/gles2/compatibility/enable_high_float.Android", false); + GLOBAL_DEF("rendering/batching/precision/uv_contract", false); + GLOBAL_DEF("rendering/batching/precision/uv_contract_amount", 100); + + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/max_join_item_commands", PropertyInfo(Variant::INT, "rendering/batching/parameters/max_join_item_commands", PROPERTY_HINT_RANGE, "0,65535")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/colored_vertex_format_threshold", PropertyInfo(Variant::FLOAT, "rendering/batching/parameters/colored_vertex_format_threshold", PROPERTY_HINT_RANGE, "0.0,1.0,0.01")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/batch_buffer_size", PropertyInfo(Variant::INT, "rendering/batching/parameters/batch_buffer_size", PROPERTY_HINT_RANGE, "1024,65535,1024")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/lights/scissor_area_threshold", PropertyInfo(Variant::FLOAT, "rendering/batching/lights/scissor_area_threshold", PROPERTY_HINT_RANGE, "0.0,1.0")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/lights/max_join_items", PropertyInfo(Variant::INT, "rendering/batching/lights/max_join_items", PROPERTY_HINT_RANGE, "0,512")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/item_reordering_lookahead", PropertyInfo(Variant::INT, "rendering/batching/parameters/item_reordering_lookahead", PROPERTY_HINT_RANGE, "0,256")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/precision/uv_contract_amount", PropertyInfo(Variant::INT, "rendering/batching/precision/uv_contract_amount", PROPERTY_HINT_RANGE, "0,10000")); } RenderingServer::~RenderingServer() {