summaryrefslogtreecommitdiff
path: root/modules/opensimplex/noise_texture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/opensimplex/noise_texture.cpp')
-rw-r--r--modules/opensimplex/noise_texture.cpp26
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 {