1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #include "texture_loader_dummy.h"
- #include "core/os/file_access.h"
- #include "core/print_string.h"
- #include <string.h>
- RES ResourceFormatDummyTexture::load(const String &p_path, const String &p_original_path, Error *r_error) {
- unsigned int width = 8;
- unsigned int height = 8;
-
- Image::Format fmt = Image::FORMAT_RGB8;
- int rowsize = 3 * width;
- PoolVector<uint8_t> dstbuff;
- dstbuff.resize(rowsize * height);
- uint8_t **row_p = memnew_arr(uint8_t *, height);
- for (unsigned int i = 0; i < height; i++) {
- row_p[i] = 0;
- }
- memdelete_arr(row_p);
- Ref<Image> img = memnew(Image(width, height, 0, fmt, dstbuff));
- Ref<ImageTexture> texture = memnew(ImageTexture);
- texture->create_from_image(img);
- if (r_error)
- *r_error = OK;
- return texture;
- }
- void ResourceFormatDummyTexture::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back("png");
- p_extensions->push_back("hdr");
- p_extensions->push_back("jpg");
- p_extensions->push_back("tga");
- }
- bool ResourceFormatDummyTexture::handles_type(const String &p_type) const {
- return ClassDB::is_parent_class(p_type, "Texture");
- }
- String ResourceFormatDummyTexture::get_resource_type(const String &p_path) const {
- String extension = p_path.get_extension().to_lower();
- if (extension == "png" || extension == "hdr" || extension == "jpg" || extension == "tga")
- return "ImageTexture";
- return "";
- }
|