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?
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)
{
}
}
}
{
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)
{
}
}
}