Skip to content

Commit

Permalink
Fix pink GradientTexture2D
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusmdx committed Jul 28, 2024
1 parent e343dbb commit 7a0cd87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
10 changes: 4 additions & 6 deletions scene/resources/gradient_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void GradientTexture1D::_queue_update() {
callable_mp(this, &GradientTexture1D::update_now).call_deferred();
}

void GradientTexture1D::_update() {
void GradientTexture1D::_update() const {
update_pending = false;

if (gradient.is_null()) {
Expand Down Expand Up @@ -172,14 +172,13 @@ RID GradientTexture1D::get_rid() const {
}

Ref<Image> GradientTexture1D::get_image() const {
const_cast<GradientTexture1D *>(this)->update_now();
if (!texture.is_valid()) {
return Ref<Image>();
}
return RenderingServer::get_singleton()->texture_2d_get(texture);
}

void GradientTexture1D::update_now() {
void GradientTexture1D::update_now() const {
if (update_pending) {
_update();
}
Expand Down Expand Up @@ -225,7 +224,7 @@ void GradientTexture2D::_queue_update() {
callable_mp(this, &GradientTexture2D::update_now).call_deferred();
}

void GradientTexture2D::_update() {
void GradientTexture2D::_update() const {
update_pending = false;

if (gradient.is_null()) {
Expand Down Expand Up @@ -405,14 +404,13 @@ RID GradientTexture2D::get_rid() const {
}

Ref<Image> GradientTexture2D::get_image() const {
const_cast<GradientTexture2D *>(this)->update_now();
if (!texture.is_valid()) {
return Ref<Image>();
}
return RenderingServer::get_singleton()->texture_2d_get(texture);
}

void GradientTexture2D::update_now() {
void GradientTexture2D::update_now() const {
if (update_pending) {
_update();
}
Expand Down
12 changes: 6 additions & 6 deletions scene/resources/gradient_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ class GradientTexture1D : public Texture2D {

private:
Ref<Gradient> gradient;
bool update_pending = false;
mutable bool update_pending = false;
mutable RID texture;
int width = 256;
bool use_hdr = false;

void _queue_update();
void _update();
void _update() const;

protected:
static void _bind_methods();
Expand All @@ -64,7 +64,7 @@ class GradientTexture1D : public Texture2D {
virtual bool has_alpha() const override { return true; }

virtual Ref<Image> get_image() const override;
void update_now();
void update_now() const;

GradientTexture1D();
virtual ~GradientTexture1D();
Expand Down Expand Up @@ -102,9 +102,9 @@ class GradientTexture2D : public Texture2D {

float _get_gradient_offset_at(int x, int y) const;

bool update_pending = false;
mutable bool update_pending = false;
void _queue_update();
void _update();
void _update() const;

protected:
static void _bind_methods();
Expand Down Expand Up @@ -134,7 +134,7 @@ class GradientTexture2D : public Texture2D {
virtual RID get_rid() const override;
virtual bool has_alpha() const override { return true; }
virtual Ref<Image> get_image() const override;
void update_now();
void update_now() const;

GradientTexture2D();
virtual ~GradientTexture2D();
Expand Down

0 comments on commit 7a0cd87

Please sign in to comment.