I'm trying to integrate SFML window in my application, i created a separate SFML window (with Pinvoke), everything works well, except event handeling. In C# i created a timer :
renderTimer.Interval = 1;
renderTimer.Enabled = true;
renderTimer.Tick += (object sender, EventArgs e) => {
Render();
};
[DllImport("Lib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void Render();
In Render function i do poling events and rendering content. I faced a problem that i can catch MouseButtonPressed event only if i start to spam clicking mouse button (is there a multithreaded implementation of event handeling ?). With combination of isButtonPressed and getPosition everything works as expected.
P.S. on Windows everything is Ok.
Maybe a minimal code that reproduce the problem can help me getting some insights on the issue.
You can take a .net tutorial, run it with mono.
Then add a form, and try to run it in parallel :D
I did it like that :
1. In ctor i initialized sfml.
2. Created a timer, timer calls Frame :
API_EXPORT void Frame()
{
sf::RenderWindow & window = ... get window
sf::Event event;
while (window.pollEvent(event)) {
// get events here
}
// clear
// draw
}
3. I use delegates to get results on events :
#ifdef SFML_SYSTEM_WINDOWS
typedef void (__stdcall * clickDelegate)(cVector2);
#else
typedef void (* clickDelegate)(cVector2);
#endif
unsafe private delegate void OnClickDelegate(PointF pos);
unsafe private void click(PointF pos)
{
Text = pos.X.ToString() + " " + pos.Y.ToString();
}