1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gsk.ShaderArgsBuilder; 26 27 private import glib.Bytes; 28 private import glib.ConstructionException; 29 private import gobject.ObjectG; 30 private import graphene.Vec2; 31 private import graphene.Vec3; 32 private import graphene.Vec4; 33 private import gsk.GLShader; 34 private import gsk.c.functions; 35 public import gsk.c.types; 36 private import gtkd.Loader; 37 38 39 /** 40 * An object to build the uniforms data for a #GskGLShader. 41 */ 42 public class ShaderArgsBuilder 43 { 44 /** the main Gtk struct */ 45 protected GskShaderArgsBuilder* gskShaderArgsBuilder; 46 protected bool ownedRef; 47 48 /** Get the main Gtk struct */ 49 public GskShaderArgsBuilder* getShaderArgsBuilderStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return gskShaderArgsBuilder; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected void* getStruct() 58 { 59 return cast(void*)gskShaderArgsBuilder; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (GskShaderArgsBuilder* gskShaderArgsBuilder, bool ownedRef = false) 66 { 67 this.gskShaderArgsBuilder = gskShaderArgsBuilder; 68 this.ownedRef = ownedRef; 69 } 70 71 ~this () 72 { 73 if ( Linker.isLoaded(LIBRARY_GSK) && ownedRef ) 74 gsk_shader_args_builder_unref(gskShaderArgsBuilder); 75 } 76 77 78 /** */ 79 public static GType getType() 80 { 81 return gsk_shader_args_builder_get_type(); 82 } 83 84 /** 85 * Allocates a builder that can be used to construct a new uniform data 86 * chunk. 87 * 88 * Params: 89 * shader = a `GskGLShader` 90 * initialValues = optional `GBytes` with initial values 91 * 92 * Returns: The newly allocated builder, free with 93 * [method@Gsk.ShaderArgsBuilder.unref] 94 * 95 * Throws: ConstructionException GTK+ fails to create the object. 96 */ 97 public this(GLShader shader, Bytes initialValues) 98 { 99 auto __p = gsk_shader_args_builder_new((shader is null) ? null : shader.getGLShaderStruct(), (initialValues is null) ? null : initialValues.getBytesStruct()); 100 101 if(__p is null) 102 { 103 throw new ConstructionException("null returned by new"); 104 } 105 106 this(cast(GskShaderArgsBuilder*) __p); 107 } 108 109 /** 110 * Creates a new #GBytes args from the current state of the 111 * given @builder, and frees the @builder instance. 112 * 113 * Any uniforms of the shader that have not been explicitly set 114 * on the @builder are zero-initialized. 115 * 116 * Returns: the newly allocated buffer with 117 * all the args added to @builder 118 */ 119 public Bytes freeToArgs() 120 { 121 auto __p = gsk_shader_args_builder_free_to_args(gskShaderArgsBuilder); 122 123 if(__p is null) 124 { 125 return null; 126 } 127 128 return new Bytes(cast(GBytes*) __p, true); 129 } 130 131 alias doref = ref_; 132 /** 133 * Increases the reference count of a `GskShaderArgsBuilder` by one. 134 * 135 * Returns: the passed in `GskShaderArgsBuilder` 136 */ 137 public ShaderArgsBuilder ref_() 138 { 139 auto __p = gsk_shader_args_builder_ref(gskShaderArgsBuilder); 140 141 if(__p is null) 142 { 143 return null; 144 } 145 146 return ObjectG.getDObject!(ShaderArgsBuilder)(cast(GskShaderArgsBuilder*) __p, true); 147 } 148 149 /** 150 * Sets the value of the uniform @idx. 151 * 152 * The uniform must be of bool type. 153 * 154 * Params: 155 * idx = index of the uniform 156 * value = value to set the uniform to 157 */ 158 public void setBool(int idx, bool value) 159 { 160 gsk_shader_args_builder_set_bool(gskShaderArgsBuilder, idx, value); 161 } 162 163 /** 164 * Sets the value of the uniform @idx. 165 * 166 * The uniform must be of float type. 167 * 168 * Params: 169 * idx = index of the uniform 170 * value = value to set the uniform to 171 */ 172 public void setFloat(int idx, float value) 173 { 174 gsk_shader_args_builder_set_float(gskShaderArgsBuilder, idx, value); 175 } 176 177 /** 178 * Sets the value of the uniform @idx. 179 * 180 * The uniform must be of int type. 181 * 182 * Params: 183 * idx = index of the uniform 184 * value = value to set the uniform to 185 */ 186 public void setInt(int idx, int value) 187 { 188 gsk_shader_args_builder_set_int(gskShaderArgsBuilder, idx, value); 189 } 190 191 /** 192 * Sets the value of the uniform @idx. 193 * 194 * The uniform must be of uint type. 195 * 196 * Params: 197 * idx = index of the uniform 198 * value = value to set the uniform to 199 */ 200 public void setUint(int idx, uint value) 201 { 202 gsk_shader_args_builder_set_uint(gskShaderArgsBuilder, idx, value); 203 } 204 205 /** 206 * Sets the value of the uniform @idx. 207 * 208 * The uniform must be of vec2 type. 209 * 210 * Params: 211 * idx = index of the uniform 212 * value = value to set the uniform too 213 */ 214 public void setVec2(int idx, Vec2 value) 215 { 216 gsk_shader_args_builder_set_vec2(gskShaderArgsBuilder, idx, (value is null) ? null : value.getVec2Struct()); 217 } 218 219 /** 220 * Sets the value of the uniform @idx. 221 * 222 * The uniform must be of vec3 type. 223 * 224 * Params: 225 * idx = index of the uniform 226 * value = value to set the uniform too 227 */ 228 public void setVec3(int idx, Vec3 value) 229 { 230 gsk_shader_args_builder_set_vec3(gskShaderArgsBuilder, idx, (value is null) ? null : value.getVec3Struct()); 231 } 232 233 /** 234 * Sets the value of the uniform @idx. 235 * 236 * The uniform must be of vec4 type. 237 * 238 * Params: 239 * idx = index of the uniform 240 * value = value to set the uniform too 241 */ 242 public void setVec4(int idx, Vec4 value) 243 { 244 gsk_shader_args_builder_set_vec4(gskShaderArgsBuilder, idx, (value is null) ? null : value.getVec4Struct()); 245 } 246 247 /** 248 * Creates a new `GBytes` args from the current state of the 249 * given @builder. 250 * 251 * Any uniforms of the shader that have not been explicitly set on 252 * the @builder are zero-initialized. 253 * 254 * The given `GskShaderArgsBuilder` is reset once this function returns; 255 * you cannot call this function multiple times on the same @builder instance. 256 * 257 * This function is intended primarily for bindings. C code should use 258 * [method@Gsk.ShaderArgsBuilder.free_to_args]. 259 * 260 * Returns: the newly allocated buffer with 261 * all the args added to @builder 262 */ 263 public Bytes toArgs() 264 { 265 auto __p = gsk_shader_args_builder_to_args(gskShaderArgsBuilder); 266 267 if(__p is null) 268 { 269 return null; 270 } 271 272 return new Bytes(cast(GBytes*) __p, true); 273 } 274 275 /** 276 * Decreases the reference count of a `GskShaderArgBuilder` by one. 277 * 278 * If the resulting reference count is zero, frees the builder. 279 */ 280 public void unref() 281 { 282 gsk_shader_args_builder_unref(gskShaderArgsBuilder); 283 } 284 }