private void LoadStream(object tag) { var block = tag as GuerillaBlock; if (block == null) { return; } var stream = ( MemoryStream )vertexStreams[block]; var buffer = stream.ToArray( ); hexBox1.ByteProvider.DeleteBytes(0, hexBox1.ByteProvider.Length); hexBox1.ByteProvider.InsertBytes(0, buffer); hexBox1.ByteProvider.ApplyChanges(); hexBox1.Refresh(); var strBuilder = new StringBuilder( ); using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.Default, true)) { stream.Seek(0, SeekOrigin.Begin); var version = binaryReader.ReadInt16( ); strBuilder.AppendLine("#" + version); var instructionCount = binaryReader.ReadInt16( ); for (int i = 0; i < instructionCount; i++) { var instructionBytes = binaryReader.ReadBytes(16); var instruction = new VertexProgramInstruction(instructionBytes); strBuilder.AppendLine(instruction.ToAsm); } } asmLines.Text = strBuilder.ToString( ); }
public void DisplayVertexInstructions(TagDatum vertexDatum, CacheStream cache) { var vertexBlock = ( VertexShaderBlock )cache.Deserialize(vertexDatum.Identifier); var code = vertexBlock.GeometryClassifications[0].Code; var altCode = vertexBlock.GeometryClassifications[0].CompiledShader; var strBuilder = new StringBuilder(); foreach (var s in altCode) { strBuilder.Append("$ " + s + " "); } strBuilder.AppendLine(); if (code.Length < 4) { textEditorControl1.Text = strBuilder.ToString(); textEditorControl1.Refresh( ); return; } using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(code))) { var version = binaryReader.ReadInt16( ); strBuilder.AppendLine("#" + version); var instructionCount = binaryReader.ReadInt16( ); for (int i = 0; i < instructionCount; i++) { var instructionBytes = binaryReader.ReadBytes(16); var instruction = new VertexProgramInstruction(instructionBytes); strBuilder.AppendLine(instruction.ToAsm); } } textEditorControl1.Text = strBuilder.ToString( ); textEditorControl1.Refresh(); }
private void DisplayVertexInstructions(TagDatum vertexDatum, CacheStream cache) { foreach (var documentsDockContent in documentsDockContents) { documentsDockContent.DockHandler.DockPanel = null; documentsDockContent.Dispose( ); } var vertexBlock = ( VertexShaderBlock )cache.Deserialize(vertexDatum.Identifier); for (var i = 0; i < vertexBlock.GeometryClassifications.Length; i++) { var asmEditor = new AsmEditor($"vertex_{i}.glsl"); var code = vertexBlock.GeometryClassifications[i].Code; var altCode = vertexBlock.GeometryClassifications[i].CompiledShader; var strBuilder = new StringBuilder( ); foreach (var s in altCode) { strBuilder.Append("$ " + s + " "); } strBuilder.AppendLine( ); if (code.Length < 4) { asmEditor.SetText(strBuilder.ToString( )); return; } using (var binaryReader = new BinaryReader(new MemoryStream(code))) { var version = binaryReader.ReadInt16( ); strBuilder.AppendLine("#" + version); var instructionCount = binaryReader.ReadInt16( ); for (var index = 0; index < instructionCount; index++) { var instructionBytes = binaryReader.ReadBytes(16); var instruction = new VertexProgramInstruction(instructionBytes); strBuilder.AppendLine(instruction.ToAsm); } } documentsDockContents.Add(asmEditor); asmEditor.SetText(strBuilder.ToString( )); asmEditor.Show(dockPanel1, DockState.Document); } }