public static void EditVertex(Rectangle ClientRectangle, int Width, int Height, GLControl RenderPanel, Point pt, byte R, byte G, byte B, byte A, bool AlphaOnly) { byte[] color = new byte[4]; Renderer.RenderColourBuffer(ClientRectangle, Width, Height, RenderPanel); GL.ReadPixels(pt.X, RenderPanel.Height - pt.Y - 1, 1, 1, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, PixelType.UnsignedByte, color); UInt32 Addr = (UInt32)((color[0] << 24) | (color[1] << 16) | (color[2] << 8) | color[3]); //StatusLabel.Text = Addr.ToString("x"); if (Addr != 0) { for (uint i = 0; i < Vertex.CurrentVertexList.Length; i++) { if (Addr == Vertex.CurrentVertexList[i]) { UInt32 colour = (uint)((R << 24) | (G << 16) | (B << 8) | A); if (colour == ROMManager.SM64ROM.ReadFourBytes(Addr + 12)) { return; //If it's the same, don't do anything } for (uint j = 29; j >= 1 && j <= 29; j--) //Shift all mem back one { Vertex.OriginalVertexMem[j] = Vertex.OriginalVertexMem[j - 1]; } Vertex.OriginalVertexMem[0] = new UInt32[1][]; //Set up new undo level with one combo Vertex.OriginalVertexMem[0][0] = new UInt32[2]; Vertex.OriginalVertexMem[0][0][0] = Addr + 12; Vertex.OriginalVertexMem[0][0][1] = ROMManager.SM64ROM.ReadFourBytes(Addr + 12); //Initial RGBA ROMManager.SetVertRGBA(Vertex.CurrentVertexList[i], colour, AlphaOnly); break; } } } }
private void button2_Click(object sender, EventArgs e) { for (uint j = 29; j >= 1 && j <= 29; j--) //Shift all mem back one { Vertex.OriginalVertexMem[j] = Vertex.OriginalVertexMem[j - 1]; } Vertex.OriginalVertexMem[0] = new UInt32[Vertex.CurrentVertexList.Length][]; //Set up new undo level with all combos for (uint i = 0; i < Vertex.CurrentVertexList.Length; i++) { Vertex.OriginalVertexMem[0][i] = new UInt32[2]; Vertex.OriginalVertexMem[0][i][0] = Vertex.CurrentVertexList[i] + 12; Vertex.OriginalVertexMem[0][i][1] = ROMManager.SM64ROM.ReadFourBytes(Vertex.CurrentVertexList[i] + 12); //Initial RGBA } byte R = (byte)Math.Round(RedNum.Value * ((decimal)Brightness.Value / 100)); byte G = (byte)Math.Round(GreenNum.Value * ((decimal)Brightness.Value / 100)); byte B = (byte)Math.Round(BlueNum.Value * ((decimal)Brightness.Value / 100)); byte A = (byte)AlphaNum.Value; UInt32 colour = (uint)((R << 24) | (G << 16) | (B << 8) | A); for (int i = 0; i < Vertex.CurrentVertexList.Length; i++) { ROMManager.SetVertRGBA(Vertex.CurrentVertexList[i], colour); } }