summaryrefslogtreecommitdiff
path: root/modules/opensimplex
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-06-11 15:43:37 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-11 11:53:26 +0100
commit3f335ce3d446372eeb9ed87f7e117099c4d2dd6a (patch)
tree669db7ddb21f328215a9c26e9bdaf2565db8c853 /modules/opensimplex
parent9ffe57a10eecf79ab8df2f0497d0387383755df3 (diff)
Texture refactor
-Texture renamed to Texture2D -TextureLayered as base now inherits 2Darray, cubemap and cubemap array -Removed all references to flags in textures (they will go in the shader) -Texture3D gone for now (will come back later done properly) -Create base rasterizer for RenderDevice, RasterizerRD
Diffstat (limited to 'modules/opensimplex')
-rw-r--r--modules/opensimplex/noise_texture.cpp26
-rw-r--r--modules/opensimplex/noise_texture.h11
2 files changed, 18 insertions, 19 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 {
diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h
index 285fd1eba9..b1d7d3fac9 100644
--- a/modules/opensimplex/noise_texture.h
+++ b/modules/opensimplex/noise_texture.h
@@ -39,8 +39,8 @@
#include "editor/editor_plugin.h"
#include "editor/property_editor.h"
-class NoiseTexture : public Texture {
- GDCLASS(NoiseTexture, Texture);
+class NoiseTexture : public Texture2D {
+ GDCLASS(NoiseTexture, Texture2D);
private:
Ref<Image> data;
@@ -51,7 +51,7 @@ private:
bool update_queued;
bool regen_queued;
- RID texture;
+ mutable RID texture;
uint32_t flags;
Ref<OpenSimplexNoise> noise;
@@ -91,10 +91,7 @@ public:
int get_width() const;
int get_height() const;
- virtual void set_flags(uint32_t p_flags);
- virtual uint32_t get_flags() const;
-
- virtual RID get_rid() const { return texture; }
+ virtual RID get_rid() const;
virtual bool has_alpha() const { return false; }
virtual Ref<Image> get_data() const;