SFML community forums

Bindings - other languages => DotNet => Topic started by: thoniel on July 23, 2009, 12:09:55 am

Title: sfml in widget (qt or whatever)
Post by: thoniel on July 23, 2009, 12:09:55 am
hi
is there a good way to use sfml in qt or smiliar as a widget?

i saw a way for c++ in the wiki, but c# does not support multiple inheritance as c++ does.
Title: sfml in widget (qt or whatever)
Post by: Laurent on July 23, 2009, 12:38:03 am
I have no idea. I guess it should work if you are able to retrieve the internal Win32 handle of your target window, and pass it to SFML.
Title: sfml in widget (qt or whatever)
Post by: thoniel on July 23, 2009, 01:16:08 pm
thanks. you are right. (should work with qt as well. i will try)

Windows Form
Code: [Select]
public partial class Form1 : Form
{
UnitTestMitForm game;
public Form1() {
InitializeComponent();

game = new UnitTestMitForm(this.Handle);
game.Run();
}

public void RenderFrame() {
game.RenderFrame();
}
}


Game.RenderFrame()

Code: [Select]
public void RenderFrame() {
float deltaTime = window.GetFrameTime();

// Events feuern
window.DispatchEvents();

// spiel aktualisieren
Update(deltaTime);

// spiel malen
window.Clear();
Draw(gameDrawer, deltaTime);
window.Display();
}


Program
Code: [Select]
Form1 form = new Form1();

form.Show();

while(form.Created) {
form.RenderFrame();
Application.DoEvents();
}


seems to work. i will try to use it and i will see if there is something wrong i cant see right now.