ImageTexture.load returns an error code.

This commit is contained in:
Pieter-Jan Briers 2018-05-12 16:53:45 +02:00
parent 81b1d3c846
commit 622a754584
4 changed files with 11 additions and 6 deletions

View File

@ -338,6 +338,7 @@
<argument index="0" name="buffer" type="PoolByteArray">
</argument>
<description>
Loads an image from the binary contents of a JPEG file.
</description>
</method>
<method name="load_png_from_buffer">
@ -346,6 +347,7 @@
<argument index="0" name="buffer" type="PoolByteArray">
</argument>
<description>
Loads an image from the binary contents of a PNG file.
</description>
</method>
<method name="lock">

View File

@ -47,12 +47,12 @@
</description>
</method>
<method name="load">
<return type="void">
<return type="int" enum="Error">
</return>
<argument index="0" name="path" type="String">
</argument>
<description>
Load an [code]ImageTexture[/code].
Load an [code]ImageTexture[/code] from a file path.
</description>
</method>
<method name="set_data">

View File

@ -220,12 +220,15 @@ Image::Format ImageTexture::get_format() const {
return format;
}
void ImageTexture::load(const String &p_path) {
Error ImageTexture::load(const String &p_path) {
Ref<Image> img;
img.instance();
img->load(p_path);
create_from_image(img);
Error err = img->load(p_path);
if (err == OK) {
create_from_image(img);
}
return err;
}
void ImageTexture::set_data(const Ref<Image> &p_image) {

View File

@ -124,7 +124,7 @@ public:
void set_flags(uint32_t p_flags);
uint32_t get_flags() const;
Image::Format get_format() const;
void load(const String &p_path);
Error load(const String &p_path);
void set_data(const Ref<Image> &p_image);
Ref<Image> get_data() const;