Example #1
0
        void DrawView()
        {
            Context.MakeCurrent(null);
            GL.Oes.BindFramebuffer(All.FramebufferOes, ViewFrameBuffer);
            GL.Viewport(0, 0, BackingWidth, BackingHeight);

            GL.MatrixMode(All.Projection);
            GL.LoadIdentity();
            // GL.Ortho (-0.55f, 0.55f, -1.5f, 1.5f, -1.0f, 1.0f);
            GL.Ortho(-0.5f, 0.5f, -0.5f, 0.5f, -1.0f, 1.0f);
            GL.MatrixMode(All.Modelview);
            //if (finish)
            //	GL.Rotate (3.0f, 0.0f, 0.0f, 1.0f);

            GL.ClearColor(1f, 1f, 1f, 1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            float[] squareVerticesD = new float[8];
            float   countX          = MyColorContainer.ColorElements.Length;
            float   countY          = 1f;
            int     i = 0;

            for (float x = 0; x < countX; x += 1f)
            {
                for (float y = 0; y < countY; y += 1f)
                {
                    var   dx    = x / countX;
                    var   dy    = y / countY;
                    float sizeX = 1 / (countX * 1f);
                    float sizeY = 1 / (countY * 1f);
                    squareVerticesD [0] = -0.5f + dx;
                    squareVerticesD [1] = -0.5f + dy;
                    squareVerticesD [2] = -0.5f + sizeX + dx;
                    squareVerticesD [3] = -0.5f + dy;
                    squareVerticesD [4] = -0.5f + dx;
                    squareVerticesD [5] = -0.5f + sizeY + dy;
                    squareVerticesD [6] = -0.5f + sizeX + dx;
                    squareVerticesD [7] = -0.5f + sizeY + dy;
                    GL.VertexPointer(2, All.Float, 0, squareVerticesD);
                    GL.EnableClientState(All.VertexArray);
                    GL.ColorPointer(4, All.UnsignedByte, 0, MyColorContainer.ColorElement(i));
                    i = (i + 1) % 255;
                    GL.EnableClientState(All.ColorArray);
                    GL.DrawArrays(All.TriangleStrip, 0, 4);
                }
            }
            if (!finish)
            {
                if (sort == null)
                {
                    sort = SortFactory.Create(sortAlgorithm);
                    this.MainViewController.SetSortName(sort.SortName());
                    this.MainViewController.SegmentedControl.SelectedSegment = sortAlgorithm % 4;
                }
                sortstep++;
                if (AnimationInterval != 0 &&
                    sortstep % (int)((1 / AnimationInterval) / 30) == 0)
                {
                    finish = !sort.SortStep(MyColorContainer.ColorElements);
                    this.MainViewController.AnzahlIterationenLabel.Text = string.Format("{0} Interations for sorting {1} Elements", ++this.anzahlIterationen, anzahlElemente);
                }
            }
            else
            {
                if (sort != null)
                {
                    sortAlgorithm++;
                    sort              = null;
                    sortstep          = 0;
                    anzahlIterationen = 0;
                }
                sortstep++;
                if (AnimationInterval != 0 &&
                    sortstep % (int)((1 / AnimationInterval) * 5) == 0)
                {
                    finish = false;
                    MyColorContainer.Randomize(5000);
                }
            }

            // MyColorContainer.Sort ();

            GL.Oes.BindRenderbuffer(All.RenderbufferOes, ViewRenderBuffer);
            Context.EAGLContext.PresentRenderBuffer((uint)All.RenderbufferOes);
        }