1
DotNet / Re: SFML on PictureBox with no render loop and GDI+
« on: November 16, 2013, 09:24:12 am »
Do you just want to draw inside a Form? Then try the following code.
After copying my code you just need to add a timer, set it's interval to 5ms and enable it.
After copying my code you just need to add a timer, set it's interval to 5ms and enable it.
Quote
public partial class Form1 : Form
{
RenderWindow renderWnd;
public Form1()
{
InitializeComponent();
SetDoubleBuffered(panel1);
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
renderWnd = new RenderWindow(panel1.Handle, new ContextSettings(32, 0, );
}
public static void SetDoubleBuffered(Control c)
{
System.Reflection.PropertyInfo aProp =
typeof(Control).GetProperty(
"DoubleBuffered",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
aProp.SetValue(c, true, null);
}
private void timer1_Tick(object sender, EventArgs e)
{
renderWnd.Clear(new SFML.Graphics.Color(0,0,0));
var circle = new CircleShape(5);
circle.FillColor = SFML.Graphics.Color.Red;
var cursor = panel1.PointToClient(MousePosition);
circle.Position = new Vector2f(cursor.X, cursor.Y);
renderWnd.Draw(circle);
renderWnd.Display();
}
}