Hi! I’m trying to make LoadingScreen work with no threads UWP policy. It looks like everything works but I dont see anything on screen besides my GraphicDevice.Clear(color) results. I don’t have any more ideas anymore what’s wrong here, trying to make it work for forever.
Load method, everything gets called as intended.
private async void LoadAsync() { while (!done) { long lastTime = Stopwatch.GetTimestamp(); GameTime gameTime = GetGameTime(ref lastTime); DrawLoadAnimation(gameTime); await Task.Delay(10).ConfigureAwait(false); } }
Draw methods
void DrawLoadAnimation(GameTime gameTime) { if ((ScreenManager.GraphicsDevice == null) || ScreenManager.GraphicsDevice.IsDisposed) return; DrawAnim(gameTime); ScreenManager.GraphicsDevice.Present(); }
public int testIncrease = 0; public void DrawAnim(GameTime gameTime) { testIncrease++; ScreenManager.GraphicsDevice.Clear(new Color(testIncrease, testIncrease, testIncrease)); SpriteBatch spriteBatch = ScreenManager.SpriteBatch; spriteBatch.Begin(); //testing with some fresh texture Texture2D blankTexture = new Texture2D(ScreenManager.GraphicsDevice, 1, 1); blankTexture.SetData(new[] { Color.Red }); spriteBatch.Draw(blankTexture, new Rectangle(64, 64, 512, 512), Color.White); //also some text writing code here 100% functional in usual draw loop spriteBatch.End(); }
As you can see in the last method I use testIncrease to change GraphicDevice.Clear color, and it works! Background color gradually changing from black to white while loading, but textures and text are invisible. Do I need to do something else? Prepare spritebatch in some way for Present()?
Also, I did try to swap main thread and async tasks: main thread drawing and async task are loading the next screen. It works, but it is super slow so I really want to make this work (async drawing, main loading).
Any help greatly appreciated!