Exemple #1
0
        void DrawAdvanced(TRectF screen)
        {
            pTexBg.Draw2D((int)screen.x, (int)screen.y, (uint)screen.width, (uint)screen.height, 0, 0);

            TPoint2 pos = new TPoint2(screen.x + screen.width - 160f, screen.y + 20f);
            TPoint2 dim = new TPoint2(128f, 128f);

            pRender2D.DrawTexture(pTexPlanetRenderIn, ref pos, ref dim, 0, E_EFFECT2D_FLAGS.EF_BLEND |
                                  E_EFFECT2D_FLAGS.EF_FLIP_VERTICALLY /* because render targets are flipped */);

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);

            // not to triangulate complex polygon every frame we can batch it this way and triangulation will be done only after update tick
            pRender2D.BeginBatch(false);
            pRender2D.DrawPolygon(pTexAnimWater[counter / 5 % 11], ref waterWaves.ToArray()[0], (uint)waterWaves.Count,
                                  E_PRIMITIVE2D_FLAGS.PF_FILL);
            pRender2D.EndBatch();

            uint w, h;

            pTexJellyFish.GetDimensions(out w, out h);
            float   x_offset = (float)(Math.Abs(Math.Cos(counter / 20f)) * 50);
            float   y_offset = (float)(Math.Sin(counter / 10f) * 75);
            TPoint2 jellyPos = new TPoint2(screen.x + 175f, screen.y + 200f);

            TPoint2 vert1 = new TPoint2();
            TPoint2 vert2 = new TPoint2();
            TPoint2 vert3 = new TPoint2(x_offset, -y_offset);
            TPoint2 vert4 = new TPoint2(-x_offset, -y_offset);

            pRender2D.SetVerticesOffsets(ref vert1, ref vert2, ref vert3, ref vert4);
            TColor4 c = TColor4.ColorViolet();

            pRender2D.SetColorMix(ref c);
            dim = new TPoint2(w / 2f, h / 2f);
            pRender2D.DrawTexture(pTexJellyFish, ref jellyPos, ref dim, -45f, E_EFFECT2D_FLAGS.EF_BLEND |
                                  E_EFFECT2D_FLAGS.EF_VERTICES_OFFSETS | E_EFFECT2D_FLAGS.EF_COLOR_MIX);

            pTexLightRound.GetDimensions(out w, out h);
            pos = jellyPos - new TPoint2(90f, 15f);
            dim = new TPoint2(w, h);
            pRender2D.DrawTexture(pTexLightRound, ref pos, ref dim, 0, E_EFFECT2D_FLAGS.EF_BLEND |
                                  E_EFFECT2D_FLAGS.EF_COLOR_MIX);
        }
Exemple #2
0
        void DrawPrimitives(TRectF screen)
        {
            TColor4 c;
            TRectF  rect;

            rect = new TRectF(5f, 5f, 170f, 170f);
            c    = TColor4.ColorBlue();
            pRender2D.DrawRectangle(ref rect, ref c, E_PRIMITIVE2D_FLAGS.PF_LINE);

            rect = new TRectF(10f, 10f, 160f, 160f);
            c    = TColor4.ColorGray();
            pRender2D.DrawRectangle(ref rect, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            pRender2D.DrawTriangles(null, ref triangles[0], (uint)triangles.Length, E_PRIMITIVE2D_FLAGS.PF_FILL);

            for (int i = 0; i <= 12; i++)
            {
                TPoint2 p = new TPoint2(screen.x, screen.y) + new TPoint2(15f + 12 * i, 15f + 12 * i);
                c = TColor4.ColorTeal();
                pRender2D.DrawPoint(ref p, ref c, (uint)(1 + i));
            }

            for (int i = 0; i < 15; i++)
            {
                pRender2D.SetLineWidth((uint)(1 + i / 2));
                TPoint2 p  = new TPoint2(screen.width - i * 20, screen.height);
                TPoint2 p1 = new TPoint2(screen.width, screen.height - i * 20);
                c = TColor4.ColorOfficialOrange((byte)(255 - i * 17));
                pRender2D.DrawLine(ref p, ref p1, ref c);
            }

            pRender2D.SetLineWidth(2);
            TColor4 c1 = TColor4.ColorAqua(), c2 = TColor4.ColorFuchsia(), c3 = new TColor4(), c4 = new TColor4();

            pRender2D.SetVerticesColors(ref c1, ref c2, ref c3, ref c4); // override per vertex color for the line
            c = new TColor4();
            TPoint2 p2 = new TPoint2(screen.width, 75f);
            TPoint2 p3 = new TPoint2(200f, screen.height);

            pRender2D.DrawLine(ref p2, ref p3, ref c, E_PRIMITIVE2D_FLAGS.PF_VERTICES_COLORS);

            pRender2D.SetLineWidth(1);

            c1 = TColor4.ColorGray();
            c2 = TColor4.ColorMagenta();
            c3 = TColor4.ColorOrange();
            c4 = TColor4.ColorViolet();
            pRender2D.SetVerticesColors(ref c1, ref c2, ref c3, ref c4); // override per vertex color for the rectangle
            rect = new TRectF(250f, 25f, 125f, 125f);
            pRender2D.DrawRectangle(ref rect, ref c, (E_PRIMITIVE2D_FLAGS.PF_LINE | E_PRIMITIVE2D_FLAGS.PF_VERTICES_COLORS));

            c1 = TColor4.ColorBlack(0);
            c2 = TColor4.ColorGreen();
            c3 = TColor4.ColorGreen();
            c4 = TColor4.ColorBlack(0);
            pRender2D.SetVerticesColors(ref c1, ref c2, ref c3, ref c4);
            rect = new TRectF(260f, 35f, 105f, 105f);
            pRender2D.DrawRectangle(ref rect, ref c, (E_PRIMITIVE2D_FLAGS.PF_FILL | E_PRIMITIVE2D_FLAGS.PF_VERTICES_COLORS));

            p2 = new TPoint2(125f, 50f);
            c  = TColor4.ColorOrange();
            pRender2D.DrawCircle(ref p2, 40, 32, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            c = TColor4.ColorWhite();
            for (int i = 0; i < 6; i++)
            {
                pRender2D.DrawCircle(ref p2, (uint)(10 + i * 5), (uint)(4 + i * 2), ref c, E_PRIMITIVE2D_FLAGS.PF_LINE);
            }

            p2 = new TPoint2(200f, 250f);
            p3 = new TPoint2(110f, 34f);
            c  = TColor4.ColorViolet();
            pRender2D.DrawEllipse(ref p2, ref p3, 64, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            pRender2D.SetLineWidth(3);
            p3 = new TPoint2(100f, 30f);
            c  = TColor4.ColorWhite();
            pRender2D.DrawEllipse(ref p2, ref p3, 32, ref c, E_PRIMITIVE2D_FLAGS.PF_LINE);

            p3 = new TPoint2(80f, 24f);
            c  = TColor4.ColorFuchsia();
            pRender2D.DrawEllipse(ref p2, ref p3, 8, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            p3 = new TPoint2(30f, 75f);
            c  = TColor4.ColorOrange(100);
            pRender2D.DrawEllipse(ref p2, ref p3, 64, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            pRender2D.DrawPolygon(null, ref star_polygon[0], (uint)triangles.Length, E_PRIMITIVE2D_FLAGS.PF_FILL);
        }