예제 #1
0
        void DrawShadows(Scene scene)
        {
            foreach (Shadow shadow in scene.Shadows)
            {
                if (shadow.Vertices != null)
                {
                    float[]  vertices = new float[2 * 4];
                    Color4[] colors   = new Color4[4];
                    for (int i = 0; i < 4; i++)
                    {
                        vertices[i * 2 + 0] = shadow.Vertices[i].X;
                        vertices[i * 2 + 1] = shadow.Vertices[i].Y;
                        colors[i].R         = 0.0f;
                        colors[i].G         = 0.0f;
                        colors[i].B         = 0.0f;
                        colors[i].A         = 0.2f;
                    }

                    Geometry shadowGeometry =
                        new Geometry(OpenTK.Graphics.OpenGL4.PrimitiveType.Triangles, shadow.Vertices, shadow.Colors, null, null);

                    ShadowEffect.Begin();
                    ShadowEffect.WorldViewMatrix = Camera.ProjectionMatrix * Camera.ViewMatrix;

                    shadowGeometry.Draw();

                    ShadowEffect.End();
                    GL.BindVertexArray(0);
                }
            }
        }