diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 8 | ||||
-rw-r--r-- | modules/gdscript/gdscript.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 26 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.h | 1 | ||||
-rw-r--r-- | modules/mobile_vr/mobile_vr_interface.cpp | 105 | ||||
-rw-r--r-- | modules/mobile_vr/mobile_vr_interface.h | 2 |
6 files changed, 98 insertions, 46 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 42ec05e6ce..b987d2897f 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1811,7 +1811,7 @@ bool GDScriptLanguage::handles_global_class_type(const String &p_type) const { return p_type == "GDScript"; } -String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type) const { +String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const { PoolVector<uint8_t> sourcef; Error err; @@ -1876,6 +1876,12 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b } } } + if (r_icon_path) { + if (c->icon_path.empty() || c->icon_path.is_abs_path()) + *r_icon_path = c->icon_path; + else if (c->icon_path.is_rel_path()) + *r_icon_path = p_path.get_base_dir().plus_file(c->icon_path).simplify_path(); + } return c->name; } diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 68e89887b0..d400230f43 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -492,7 +492,7 @@ public: /* GLOBAL CLASSES */ virtual bool handles_global_class_type(const String &p_type) const; - virtual String get_global_class_name(const String &p_path, String *r_base_type = NULL) const; + virtual String get_global_class_name(const String &p_path, String *r_base_type = NULL, String *r_icon_path = NULL) const; GDScriptLanguage(); ~GDScriptLanguage(); diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index e0ed2b332b..bec314866d 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3429,6 +3429,32 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { tokenizer->advance(2); + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { + tokenizer->advance(); + + if ((tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING)) { + Variant constant = tokenizer->get_token_constant(); + String icon_path = constant.operator String(); + + String abs_icon_path = icon_path.is_rel_path() ? self_path.get_base_dir().plus_file(icon_path).simplify_path() : icon_path; + if (!FileAccess::exists(abs_icon_path)) { + _set_error("No class icon found at: " + abs_icon_path); + return; + } + + p_class->icon_path = icon_path; + + tokenizer->advance(); + } else { + _set_error("Optional parameter after 'class_name' must be a string constant file path to an icon."); + return; + } + + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT) { + _set_error("Class icon must be separated by a comma."); + return; + } + } break; case GDScriptTokenizer::TK_PR_TOOL: { diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index d8ee4e8159..dbe523a0b9 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -149,6 +149,7 @@ public: StringName extends_file; Vector<StringName> extends_class; DataType base_type; + String icon_path; struct Member { PropertyInfo _export; diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp index 2ec00aa72d..e2c630565f 100644 --- a/modules/mobile_vr/mobile_vr_interface.cpp +++ b/modules/mobile_vr/mobile_vr_interface.cpp @@ -297,6 +297,47 @@ bool MobileVRInterface::initialize() { mag_current_min = Vector3(0, 0, 0); mag_current_max = Vector3(0, 0, 0); + // build our shader + if (lens_shader == NULL) { + ///@TODO need to switch between GLES2 and GLES3 version, Reduz suggested moving this into our drivers and making this a core shader + // create a shader + lens_shader = new LensDistortedShaderGLES3(); + + // create our shader stuff + lens_shader->init(); + + glGenBuffers(1, &half_screen_quad); + glBindBuffer(GL_ARRAY_BUFFER, half_screen_quad); + { + /* clang-format off */ + const float qv[16] = { + 0, -1, + -1, -1, + 0, 1, + -1, 1, + 1, 1, + 1, 1, + 1, -1, + 1, -1, + }; + /* clang-format on */ + + glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 16, qv, GL_STATIC_DRAW); + } + + glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind + + glGenVertexArrays(1, &half_screen_array); + glBindVertexArray(half_screen_array); + glBindBuffer(GL_ARRAY_BUFFER, half_screen_quad); + glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, 0); + glEnableVertexAttribArray(0); + glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, ((uint8_t *)NULL) + 8); + glEnableVertexAttribArray(4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind + } + // reset our orientation orientation = Basis(); @@ -304,7 +345,7 @@ bool MobileVRInterface::initialize() { arvr_server->set_primary_interface(this); last_ticks = OS::get_singleton()->get_ticks_usec(); - ; + initialized = true; }; @@ -319,6 +360,15 @@ void MobileVRInterface::uninitialize() { arvr_server->clear_primary_interface_if(this); } + // cleanup our shader and buffers + if (lens_shader != NULL) { + glDeleteVertexArrays(1, &half_screen_array); + glDeleteBuffers(1, &half_screen_quad); + + delete lens_shader; + lens_shader = NULL; + } + initialized = false; }; }; @@ -394,6 +444,9 @@ void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_t // We must have a valid render target ERR_FAIL_COND(!p_render_target.is_valid()); + // We must have an initialised shader + ERR_FAIL_COND(lens_shader != NULL); + // Because we are rendering to our device we must use our main viewport! ERR_FAIL_COND(p_screen_rect == Rect2()); @@ -420,13 +473,13 @@ void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_t glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texid); - lens_shader.bind(); - lens_shader.set_uniform(LensDistortedShaderGLES3::OFFSET_X, offset_x); - lens_shader.set_uniform(LensDistortedShaderGLES3::K1, k1); - lens_shader.set_uniform(LensDistortedShaderGLES3::K2, k2); - lens_shader.set_uniform(LensDistortedShaderGLES3::EYE_CENTER, eye_center); - lens_shader.set_uniform(LensDistortedShaderGLES3::UPSCALE, oversample); - lens_shader.set_uniform(LensDistortedShaderGLES3::ASPECT_RATIO, aspect_ratio); + lens_shader->bind(); + lens_shader->set_uniform(LensDistortedShaderGLES3::OFFSET_X, offset_x); + lens_shader->set_uniform(LensDistortedShaderGLES3::K1, k1); + lens_shader->set_uniform(LensDistortedShaderGLES3::K2, k2); + lens_shader->set_uniform(LensDistortedShaderGLES3::EYE_CENTER, eye_center); + lens_shader->set_uniform(LensDistortedShaderGLES3::UPSCALE, oversample); + lens_shader->set_uniform(LensDistortedShaderGLES3::ASPECT_RATIO, aspect_ratio); glBindVertexArray(half_screen_array); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); @@ -454,41 +507,7 @@ MobileVRInterface::MobileVRInterface() { k2 = 0.215; last_ticks = 0; - // create our shader stuff - lens_shader.init(); - - { - glGenBuffers(1, &half_screen_quad); - glBindBuffer(GL_ARRAY_BUFFER, half_screen_quad); - { - /* clang-format off */ - const float qv[16] = { - 0, -1, - -1, -1, - 0, 1, - -1, 1, - 1, 1, - 1, 1, - 1, -1, - 1, -1, - }; - /* clang-format on */ - - glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 16, qv, GL_STATIC_DRAW); - } - - glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind - - glGenVertexArrays(1, &half_screen_array); - glBindVertexArray(half_screen_array); - glBindBuffer(GL_ARRAY_BUFFER, half_screen_quad); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, 0); - glEnableVertexAttribArray(0); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, ((uint8_t *)NULL) + 8); - glEnableVertexAttribArray(4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind - } + lens_shader = NULL; }; MobileVRInterface::~MobileVRInterface() { diff --git a/modules/mobile_vr/mobile_vr_interface.h b/modules/mobile_vr/mobile_vr_interface.h index 7b2344f1fe..cee0cca90e 100644 --- a/modules/mobile_vr/mobile_vr_interface.h +++ b/modules/mobile_vr/mobile_vr_interface.h @@ -58,7 +58,7 @@ private: float eye_height; uint64_t last_ticks; - LensDistortedShaderGLES3 lens_shader; + LensDistortedShaderGLES3 *lens_shader; GLuint half_screen_quad; GLuint half_screen_array; |