Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - PL_Andrev

Pages: [1]
1
DotNet / Re: SFML within windows forms
« on: May 24, 2019, 09:23:38 pm »
Hello,

I tried conect SFML window into already designed winform to overlap not-used panel.
Unfortunatelly the result is white window (instead black) and rectangle is not shown on them.
What do I wrong?

namespace SFML_test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            DrawingSurface rendersurface = new DrawingSurface();
            rendersurface.Size = new System.Drawing.Size(400, 200);
            splitContainer4.Panel1.Controls.Add(rendersurface);
            rendersurface.Location = new System.Drawing.Point(0, 0);

            // initialize sfml
            SFML.Graphics.RenderWindow renderwindow = new
            SFML.Graphics.RenderWindow(rendersurface.Handle);

            // drawing loop
            while (splitContainer4.Panel1.Visible)
            {
                System.Windows.Forms.Application.DoEvents();
                renderwindow.DispatchEvents();
                renderwindow.Clear(SFML.Graphics.Color.Black); // ---> but is white !!!
                renderwindow.Display();

                RectangleShape rec = new RectangleShape();
                rec.Position = new Vector2f(10, 10);
                rec.Size = new Vector2f(20, 20);
                rec.OutlineThickness = 1;
                rec.FillColor = SFML.Graphics.Color.Blue;
                rec.OutlineColor = SFML.Graphics.Color.Red;

                renderwindow.Draw(rec); // ---> but is not shown !!!
            }
        }
    }

    public class DrawingSurface : System.Windows.Forms.Control
    {
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
        }
        protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
        {
        }
    }
}

2
Graphics / Rotation convex shape (ver 2.2).
« on: October 17, 2018, 03:41:02 pm »
Hello,

I'm trying to rotate convex shape (3 vertex) but without no success.
Code is build as:
x = 400;
y = 400;
sf::ConvexShape polygon;
polygon.setPointCount(3);
polygon.setPoint(0, sf::Vector2f(x, y);
polygon.setPoint(1, sf::Vector2f(x-5, y-5));
polygon.setPoint(2, sf::Vector2f(x+5, y-5));

Now if I'm trying rotate it (by 10 degs) shape is moving away from point (400,400).
I tried to use Origin function but didn't help.

Not sure what's wrong here,

Pages: [1]