1
DotNet / Re: Updating texture of sprite.
« on: September 14, 2017, 03:05:24 pm »
Do you mean that this should work?
If I run the program with the code like this, the textures won't update.
Thread thread = new Thread(delegate () {
Monitor.Enter(w);
//w.SetActive(true);
tex.Update(imgB);
//w.SetActive(false);
Monitor.Exit(w);
});
thread.Start();
while (w.IsOpen) {
w.DispatchEvents();
Monitor.Enter(w);
//w.SetActive(true);
w.Clear(Color.White);
w.Draw(spr1);
w.Draw(spr2);
w.Draw(spr3);
w.Draw(spr4);
//w.SetActive(false);
Monitor.Exit(w);
w.Display();
}
Monitor.Enter(w);
//w.SetActive(true);
tex.Update(imgB);
//w.SetActive(false);
Monitor.Exit(w);
});
thread.Start();
while (w.IsOpen) {
w.DispatchEvents();
Monitor.Enter(w);
//w.SetActive(true);
w.Clear(Color.White);
w.Draw(spr1);
w.Draw(spr2);
w.Draw(spr3);
w.Draw(spr4);
//w.SetActive(false);
Monitor.Exit(w);
w.Display();
}
If I run the program with the code like this, the textures won't update.