diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-02-11 16:01:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 16:01:55 +0100 |
commit | 1eb424ec9549bdd086dfb54c847d107519be73d9 (patch) | |
tree | d9a3ec0c72f3a4eda02e16ed883f560e02cf1ccf /modules/opensimplex/noise_texture.cpp | |
parent | 3e3f8a47616327d7faeb17f558bb81a943385e82 (diff) | |
parent | db81928e08cb58d5f67908c6dfcf9433e572ffe8 (diff) |
Merge pull request #36098 from godotengine/vulkan
Add initial Vulkan support, master branch goes UNSTABLE
Diffstat (limited to 'modules/opensimplex/noise_texture.cpp')
-rw-r--r-- | modules/opensimplex/noise_texture.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index aa1c822813..19aa281a72 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -42,17 +42,16 @@ NoiseTexture::NoiseTexture() { seamless = false; as_normalmap = false; bump_strength = 8.0; - flags = FLAGS_DEFAULT; noise = Ref<OpenSimplexNoise>(); - texture = VS::get_singleton()->texture_create(); - _queue_update(); } NoiseTexture::~NoiseTexture() { - VS::get_singleton()->free(texture); + if (texture.is_valid()) { + VS::get_singleton()->free(texture); + } if (noise_thread) { Thread::wait_to_finish(noise_thread); memdelete(noise_thread); @@ -101,8 +100,12 @@ void NoiseTexture::_validate_property(PropertyInfo &property) const { void NoiseTexture::_set_texture_data(const Ref<Image> &p_image) { data = p_image; if (data.is_valid()) { - VS::get_singleton()->texture_allocate(texture, size.x, size.y, 0, Image::FORMAT_RGBA8, VS::TEXTURE_TYPE_2D, flags); - VS::get_singleton()->texture_set_data(texture, p_image); + if (texture.is_valid()) { + RID new_texture = VS::get_singleton()->texture_2d_create(p_image); + VS::get_singleton()->texture_replace(texture, new_texture); + } else { + texture = VS::get_singleton()->texture_2d_create(p_image); + } } emit_changed(); } @@ -250,13 +253,12 @@ int NoiseTexture::get_height() const { return size.y; } -void NoiseTexture::set_flags(uint32_t p_flags) { - flags = p_flags; - VS::get_singleton()->texture_set_flags(texture, flags); -} +RID NoiseTexture::get_rid() const { + if (!texture.is_valid()) { + texture = VS::get_singleton()->texture_2d_placeholder_create(); + } -uint32_t NoiseTexture::get_flags() const { - return flags; + return texture; } Ref<Image> NoiseTexture::get_data() const { |