This code is released under the
GPL license... (so no ninja copy & paste)
using System;
using SFML.Graphics;
using SFML.Window;
using SFML.System;
namespace Example
{
static class Program
{
static void Main()
{
var window = new RenderWindow(new VideoMode(800, 600), "Lines");
window.SetVerticalSyncEnabled(true);
var lines = new VertexArray(PrimitiveType.Lines);
bool down = false;
var lastposition = new Vector2f();
window.MouseButtonPressed += (sender, e) =>
{
down = e.Button == Mouse.Button.Left;
lastposition = new Vector2f(e.X, e.Y);
};
window.MouseButtonReleased += (sender, e) =>
{
down = !(down && e.Button == Mouse.Button.Left);
};
window.MouseMoved += (sender, e) =>
{
if (down)
{
lines.Append(new Vertex(lastposition, Color.White));
lastposition = new Vector2f(e.X, e.Y);
lines.Append(new Vertex(lastposition, Color.White));
}
};
while(window.IsOpen)
{
window.DispatchEvents();
window.Clear(Color.Black);
window.Draw(lines);
window.Display();
}
}
}
}