private void _cacheInstance() { DebugTools.AssertNull(_cachedInstance); ShaderInstance instance; switch (Kind) { case ShaderKind.Source: instance = _clyde.InstanceShader(Source.ClydeHandle); _applyDefaultParameters(instance); break; case ShaderKind.Canvas: instance = _clyde.InstanceShader(CompiledCanvasShader); break; default: throw new ArgumentOutOfRangeException(); } if (_stencilEnabled) { instance.StencilTestEnabled = true; instance.StencilRef = _stencilRef; instance.StencilFunc = _stencilFunc; instance.StencilOp = _stencilOp; instance.StencilReadMask = _stencilReadMask; instance.StencilWriteMask = _stencilWriteMask; } instance.MakeImmutable(); _cachedInstance = instance; }
/// <summary> /// Creates a new instance of this shader. /// </summary> public ShaderInstance Instance() { switch (Kind) { case ShaderKind.Source: var instance = _clyde.InstanceShader(Source.ClydeHandle); _applyDefaultParameters(instance); return(instance); case ShaderKind.Canvas: return(_clyde.InstanceShader(CompiledCanvasShader)); default: throw new ArgumentOutOfRangeException(); } }
private void _cacheInstance() { DebugTools.AssertNull(_cachedInstance); ShaderInstance instance; switch (Kind) { case ShaderKind.Source: instance = _clyde.InstanceShader(Source.ClydeHandle); _applyDefaultParameters(instance); break; case ShaderKind.Canvas: instance = _clyde.InstanceShader(CompiledCanvasShader); break; default: throw new ArgumentOutOfRangeException(); } instance.MakeImmutable(); _cachedInstance = instance; }