示例#1
0
        public override void Render()
        {
            base.BeforeRender();

            GL.Disable(All.Texture2D);
            GL.Color4(FillColor.R, FillColor.G, FillColor.B, FillColor.A);
            GL.Enable(All.Points);

            GL.EnableClientState(All.VertexArray);

            var vArray = new float[Stars.Count * 3];

            for (var i = 0; i < Stars.Count; i++)
            {
                vArray[i * 3 + 0] = (float)(Stars[i].X + Position.X);
                vArray[i * 3 + 1] = (float)(Stars[i].Y + Position.Y);
                vArray[i * 3 + 2] = (float)(Stars[i].Z + Position.Z);
            }

            // pin the data, so that GC doesn't move them, while used
            // by native code
            unsafe
            {
                fixed(float *pv = vArray)
                {
                    GL.VertexPointer(3, All.Float, 0, new IntPtr(pv));
                    GL.DrawArrays(All.Points, 0, 4);
                    GL.Finish();
                }
            }

            GL.Enable(All.Texture2D);

            GL.DisableClientState(All.VertexArray);

            base.AfterRender();
        }