protected override Statement TransformDraw(Draw draw) { var src = draw.Source; var scope = new Scope(src); var field = GetField(draw); var obj = new LoadField(src, new This(src, field.DeclaringType).Address, field).Address; var index = 0; foreach (var t in TerminalFields) { if (t.Value != draw.State.Terminals[t.Key].ToString()) { scope.Statements.Add(ILFactory.SetProperty(src, obj, t.Key, draw.State.Terminals[t.Key])); } } foreach (var v in draw.State.RuntimeConstants) { scope.Statements.Add(CallConst(src, obj, v, index++)); } scope.Statements.Add(ILFactory.CallMethod(src, obj, "Use")); foreach (var v in draw.State.VertexAttributes) { scope.Statements.Add(CallAttrib(src, obj, v, index++)); } foreach (var v in draw.State.Uniforms) { scope.Statements.Add(CallUniform(src, obj, v, index++)); } foreach (var v in draw.State.PixelSamplers) { scope.Statements.Add(CallSampler(src, obj, v, index++)); } scope.Statements.Add(draw.State.OptionalIndices == null ? ILFactory.CallMethod(src, obj, "DrawArrays", draw.State.Terminals["VertexCount"]) : ILFactory.CallMethod(src, obj, "Draw", draw.State.Terminals["VertexCount"], draw.State.OptionalIndices.IndexType, draw.State.OptionalIndices.Buffer)); return(draw.State.Terminals.ContainsKey("CullDrawable") ? (Statement) new IfElse(src, ILFactory.CallOperator(src, Essentials.Bool, "!", draw.State.Terminals["CullDrawable"]), scope) : scope); }