| 408 | } |
| 409 | |
| 410 | static Ref<Resource> _dds_create_texture(const Vector<Ref<Image>> &p_images, uint32_t p_dds_type, uint32_t p_width, uint32_t p_height, uint32_t p_layer_count, uint32_t p_mipmaps, Error *r_error) { |
| 411 | ERR_FAIL_COND_V(p_images.is_empty(), Ref<Resource>()); |
| 412 | |
| 413 | if ((p_dds_type & DDST_TYPE_MASK) == DDST_2D) { |
| 414 | if (p_dds_type & DDST_ARRAY) { |
| 415 | Ref<Texture2DArray> texture; |
| 416 | texture.instantiate(); |
| 417 | texture->create_from_images(p_images); |
| 418 | |
| 419 | if (r_error) { |
| 420 | *r_error = OK; |
| 421 | } |
| 422 | |
| 423 | return texture; |
| 424 | |
| 425 | } else { |
| 426 | if (r_error) { |
| 427 | *r_error = OK; |
| 428 | } |
| 429 | |
| 430 | return ImageTexture::create_from_image(p_images[0]); |
| 431 | } |
| 432 | |
| 433 | } else if ((p_dds_type & DDST_TYPE_MASK) == DDST_CUBEMAP) { |
| 434 | ERR_FAIL_COND_V(p_layer_count % 6 != 0, Ref<Resource>()); |
| 435 | |
| 436 | if (p_dds_type & DDST_ARRAY) { |
| 437 | Ref<CubemapArray> texture; |
| 438 | texture.instantiate(); |
| 439 | texture->create_from_images(p_images); |
| 440 | |
| 441 | if (r_error) { |
| 442 | *r_error = OK; |
| 443 | } |
| 444 | |
| 445 | return texture; |
| 446 | |
| 447 | } else { |
| 448 | Ref<Cubemap> texture; |
| 449 | texture.instantiate(); |
| 450 | texture->create_from_images(p_images); |
| 451 | |
| 452 | if (r_error) { |
| 453 | *r_error = OK; |
| 454 | } |
| 455 | |
| 456 | return texture; |
| 457 | } |
| 458 | |
| 459 | } else if ((p_dds_type & DDST_TYPE_MASK) == DDST_3D) { |
| 460 | Ref<ImageTexture3D> texture; |
| 461 | texture.instantiate(); |
| 462 | texture->create(p_images[0]->get_format(), p_width, p_height, p_layer_count, p_mipmaps > 1, p_images); |
| 463 | |
| 464 | if (r_error) { |
| 465 | *r_error = OK; |
| 466 | } |
| 467 |
no test coverage detected