Esempio n. 1
0
    ///// Light Texture
    public static void Draw(LightingBuffer2D buffer)
    {
        float z = buffer.transform.position.z;

        size.x = buffer.bufferCamera.orthographicSize;
        size.y = buffer.bufferCamera.orthographicSize;

        if (buffer.lightSource.rotationEnabled)
        {
            // Light Rotation!!!
            CalculatePoints(buffer);
            CalculateOffsets();

            GL.PushMatrix();
            buffer.lightSource.GetMaterial().SetPass(0);
            GL.Begin(GL.QUADS);

            Max2D.DrawImage_Batched(Vector2.zero, size, buffer.lightSource.transform.rotation.eulerAngles.z, z);

            buffer.lightSource.GetMaterial().color = Color.black;

            Max2DMatrix.DrawQuad(right0, right1, right2, right3, z);
            Max2DMatrix.DrawQuad(left0, left1, left2, left3, z);
            Max2DMatrix.DrawQuad(down0, down1, down2, down3, z);
            Max2DMatrix.DrawQuad(up0, up1, up2, up3, z);

            GL.End();
            GL.PopMatrix();
        }
        else
        {
            Max2D.DrawImage(buffer.lightSource.GetMaterial(), Vector2.zero, size, 0, z);
        }
    }