Fixed various previews not showing up

ImageTexture::create_from_image is now static, this was nasty...
master
Marc Gilleron 2022-07-30 22:56:33 +01:00
parent ae26c13d68
commit b5257f0f48
6 changed files with 8 additions and 17 deletions

View File

@ -119,9 +119,7 @@ private:
_noise->generate_image(im, false);
}
Ref<ImageTexture> tex;
tex.instantiate();
tex->create_from_image(im);
Ref<ImageTexture> tex = ImageTexture::create_from_image(im);
_texture_rect->set_texture(tex);
}

View File

@ -130,9 +130,7 @@ private:
}
}
Ref<ImageTexture> tex;
tex.instantiate();
tex->create_from_image(im);
Ref<ImageTexture> tex = ImageTexture::create_from_image(im);
_texture_rect->set_texture(tex);
}

View File

@ -7,7 +7,8 @@ namespace zylann::voxel {
VoxelGraphEditorNodePreview::VoxelGraphEditorNodePreview() {
_image.instantiate();
_image->create(RESOLUTION, RESOLUTION, false, Image::FORMAT_L8);
_texture.instantiate();
_image->fill(Color(0.5, 0.5, 0.5));
_texture = ImageTexture::create_from_image(_image);
update_texture();
_texture_rect = memnew(TextureRect);
_texture_rect->set_stretch_mode(TextureRect::STRETCH_SCALE);
@ -22,7 +23,7 @@ Ref<Image> VoxelGraphEditorNodePreview::get_image() const {
}
void VoxelGraphEditorNodePreview::update_texture() {
_texture->create_from_image(_image);
_texture->update(_image);
}
} // namespace zylann::voxel

View File

@ -75,9 +75,7 @@ void VoxelMeshSDFViewer::update_view() {
float sdf_max;
vb->get_buffer().get_range_f(sdf_min, sdf_max, VoxelBufferInternal::CHANNEL_SDF);
Ref<Image> image = vb->debug_print_sdf_y_slice((sdf_max - sdf_min) / 2.0, _slice_y);
Ref<ImageTexture> texture;
texture.instantiate();
texture->create_from_image(image);
Ref<ImageTexture> texture = ImageTexture::create_from_image(image);
_texture_rect->set_texture(texture);
// TODO Implement a raymarched view.

View File

@ -339,9 +339,7 @@ Error VoxelVoxMeshImporter::import(const String &p_source_file, const String &p_
//Ref<Texture> texture = ResourceLoader::load(atlas_path);
// TODO THIS IS A WORKAROUND, it is not supposed to be an ImageTexture...
// See earlier code, I could not find any way to reference a separate StreamTexture.
Ref<ImageTexture> texture;
texture.instantiate();
texture->create_from_image(atlas);
Ref<ImageTexture> texture = ImageTexture::create_from_image(atlas);
material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, texture);
material->set_texture_filter(StandardMaterial3D::TEXTURE_FILTER_NEAREST);
}

View File

@ -329,9 +329,7 @@ Error VoxelVoxSceneImporter::import(const String &p_source_file, const String &p
//Ref<Texture> texture = ResourceLoader::load(atlas_path);
// TODO THIS IS A WORKAROUND, it is not supposed to be an ImageTexture...
// See earlier code, I could not find any way to reference a separate StreamTexture.
Ref<ImageTexture> texture;
texture.instantiate();
texture->create_from_image(atlas);
Ref<ImageTexture> texture = ImageTexture::create_from_image(atlas);
material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, texture);
material->set_texture_filter(StandardMaterial3D::TEXTURE_FILTER_NEAREST);
}