Esempio n. 1
0
        //Z-BUFFER
        private void show_z_buff()
        {
            int[] buff = new int[pictureBox1.Width * pictureBox1.Height];

            figure.calculateZBuffer(pictureBox1.Width, pictureBox1.Height, out buff);

            Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);

            pictureBox1.Image = bmp;

            g.Clear(Color.White);

            for (int i = 0; i < pictureBox1.Width; ++i)
            {
                for (int j = 0; j < pictureBox1.Height; ++j)
                {
                    Color c = Color.FromArgb(buff[i * pictureBox1.Height + j], buff[i * pictureBox1.Height + j], buff[i * pictureBox1.Height + j]);
                    bmp.SetPixel(i, j, c);
                }
            }

            pictureBox1.Refresh();
        }