1 /** 2 Array of textures stored in a single primitive. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.texturearray; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.texturelayered; 25 /** 26 Array of textures stored in a single primitive. 27 28 $(D TextureArray)s store an array of $(D Image)s in a single $(D Texture) primitive. Each layer of the texture array has its own mipmap chain. This makes it is a good alternative to texture atlases. 29 $(D TextureArray)s must be displayed using shaders. After importing your file as a $(D TextureArray) and setting the appropriate Horizontal and Vertical Slices, display it by setting it as a uniform to a shader, for example: 30 31 32 shader_type canvas_item; 33 34 uniform sampler2DArray tex; 35 uniform int index; 36 37 void fragment() { 38 COLOR = texture(tex, vec3(UV.x, UV.y, float(index))); 39 } 40 41 42 Set the integer uniform "index" to show a particular part of the texture as defined by the Horizontal and Vertical Slices in the importer. 43 */ 44 @GodotBaseClass struct TextureArray 45 { 46 package(godot) enum string _GODOT_internal_name = "TextureArray"; 47 public: 48 @nogc nothrow: 49 union { /** */ godot_object _godot_object; /** */ TextureLayered _GODOT_base; } 50 alias _GODOT_base this; 51 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 52 package(godot) __gshared bool _classBindingInitialized = false; 53 package(godot) static struct GDNativeClassBinding 54 { 55 __gshared: 56 } 57 /// 58 pragma(inline, true) bool opEquals(in TextureArray other) const 59 { return _godot_object.ptr is other._godot_object.ptr; } 60 /// 61 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 62 { _godot_object.ptr = n; return null; } 63 /// 64 pragma(inline, true) bool opEquals(typeof(null) n) const 65 { return _godot_object.ptr is n; } 66 /// 67 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 68 mixin baseCasts; 69 /// Construct a new instance of TextureArray. 70 /// Note: use `memnew!TextureArray` instead. 71 static TextureArray _new() 72 { 73 static godot_class_constructor constructor; 74 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("TextureArray"); 75 if(constructor is null) return typeof(this).init; 76 return cast(TextureArray)(constructor()); 77 } 78 @disable new(size_t s); 79 }