Exemplo n.º 1
0
        public static void Cull(CullMode cullMode)
        {
            if (_cull != cullMode)
            {
                switch (cullMode)
                {
                case CullMode.CullClockwiseFace:
                    GL11.FrontFace(All11.Ccw);
                    GL11.CullFace(All11.Back);
                    GL11.Enable(All11.CullFace);
                    break;

                case CullMode.CullCounterClockwiseFace:
                    GL11.FrontFace(All11.Cw);
                    GL11.CullFace(All11.Back);
                    GL11.Enable(All11.CullFace);
                    break;

                case CullMode.None:
                    GL11.Disable(All11.CullFace);
                    break;
                }
                _cull = cullMode;
            }
        }
Exemplo n.º 2
0
 public static void DepthTest(bool enable)
 {
     if (enable && (_depthTest != GLStateEnabled.True))
     {
         GL11.Enable(All11.DepthTest);
     }
     else
     {
         GL11.Disable(All11.DepthTest);
     }
 }
Exemplo n.º 3
0
 public static void Textures2D(bool enable)
 {
     if (enable && (_textures2D != GLStateEnabled.True))
     {
         GL11.Enable(All11.Texture2D);
     }
     else
     {
         GL11.Disable(All11.Texture2D);
     }
 }
Exemplo n.º 4
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();
        }