1 /** 2 A custom shader program. 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.shader; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.resource; 24 import godot.texture; 25 import godot.reference; 26 /** 27 A custom shader program. 28 29 This class allows you to define a custom shader program that can be used for various materials to render objects. 30 */ 31 @GodotBaseClass struct Shader 32 { 33 enum string _GODOT_internal_name = "Shader"; 34 public: 35 @nogc nothrow: 36 union { godot_object _godot_object; Resource _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct _classBinding 41 { 42 __gshared: 43 @GodotName("get_mode") GodotMethod!(Shader.Mode) getMode; 44 @GodotName("set_code") GodotMethod!(void, String) setCode; 45 @GodotName("get_code") GodotMethod!(String) getCode; 46 @GodotName("set_default_texture_param") GodotMethod!(void, String, Texture) setDefaultTextureParam; 47 @GodotName("get_default_texture_param") GodotMethod!(Texture, String) getDefaultTextureParam; 48 @GodotName("has_param") GodotMethod!(bool, String) hasParam; 49 } 50 bool opEquals(in Shader other) const { return _godot_object.ptr is other._godot_object.ptr; } 51 Shader opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 52 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 53 mixin baseCasts; 54 static Shader _new() 55 { 56 static godot_class_constructor constructor; 57 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Shader"); 58 if(constructor is null) return typeof(this).init; 59 return cast(Shader)(constructor()); 60 } 61 @disable new(size_t s); 62 /// 63 enum Mode : int 64 { 65 /** 66 67 */ 68 modeSpatial = 0, 69 /** 70 71 */ 72 modeCanvasItem = 1, 73 /** 74 75 */ 76 modeParticles = 2, 77 } 78 /// 79 enum Constants : int 80 { 81 modeSpatial = 0, 82 modeCanvasItem = 1, 83 modeParticles = 2, 84 } 85 /** 86 Returns the shader mode for the shader, either `MODE_CANVAS_ITEM`, `MODE_SPATIAL` or `MODE_PARTICLES` 87 */ 88 Shader.Mode getMode() const 89 { 90 checkClassBinding!(typeof(this))(); 91 return ptrcall!(Shader.Mode)(_classBinding.getMode, _godot_object); 92 } 93 /** 94 95 */ 96 void setCode(StringArg0)(in StringArg0 code) 97 { 98 checkClassBinding!(typeof(this))(); 99 ptrcall!(void)(_classBinding.setCode, _godot_object, code); 100 } 101 /** 102 103 */ 104 String getCode() const 105 { 106 checkClassBinding!(typeof(this))(); 107 return ptrcall!(String)(_classBinding.getCode, _godot_object); 108 } 109 /** 110 111 */ 112 void setDefaultTextureParam(StringArg0)(in StringArg0 param, Texture texture) 113 { 114 checkClassBinding!(typeof(this))(); 115 ptrcall!(void)(_classBinding.setDefaultTextureParam, _godot_object, param, texture); 116 } 117 /** 118 119 */ 120 Ref!Texture getDefaultTextureParam(StringArg0)(in StringArg0 param) const 121 { 122 checkClassBinding!(typeof(this))(); 123 return ptrcall!(Texture)(_classBinding.getDefaultTextureParam, _godot_object, param); 124 } 125 /** 126 127 */ 128 bool hasParam(StringArg0)(in StringArg0 name) const 129 { 130 checkClassBinding!(typeof(this))(); 131 return ptrcall!(bool)(_classBinding.hasParam, _godot_object, name); 132 } 133 /** 134 135 */ 136 @property String code() 137 { 138 return getCode(); 139 } 140 /// ditto 141 @property void code(String v) 142 { 143 setCode(v); 144 } 145 }