/// <summary> /// シェーダー(2D)を生成する。 /// </summary> /// <param name="shaderText">シェーダーのコード</param> /// <param name="variableProperties">シェーダーで使用可能な外部入力可能な変数</param> /// <returns></returns> public Shader2D CreateShader2D(string shaderText, ShaderVariableProperty[] variableProperties) { swig.ShaderVariablePropertyVector vprops = new swig.ShaderVariablePropertyVector(); foreach (var v_ in variableProperties) { var sprop = new swig.ShaderVariableProperty(); sprop.Name = v_.Name; sprop.Type = (swig.ShaderVariableType)v_.Type; sprop.Offset = v_.Offset; vprops.Add(sprop); } var shader = graphics.CreateShader2D_Imp(shaderText, vprops); if (shader == null) { return(null); } var p = shader.GetPtr(); var existing = GC.Shader2Ds.GetObject(p); if (existing != null) { return(existing); } var ret = new Shader2D(shader); GC.Shader2Ds.AddObject(p, ret); return(ret); }
/// <summary> /// マテリアル(2D)を生成する。 /// </summary> /// <param name="shader">シェーダー</param> /// <returns>マテリアル(2D)</returns> public Material2D CreateMaterial2D(Shader2D shader) { var material = graphics.CreateMaterial2D_(shader.SwigObject); var p = material.GetPtr(); var existing = GC.Material2Ds.GetObject(p); if (existing != null) { return(existing); } var ret = new Material2D(material); GC.Material2Ds.AddObject(p, ret); return(ret); }
public void SetShader2D(string name, Shader2D value) { SwigObject.SetShader2D(value.SwigObject); }