1
\$\begingroup\$

I've a question about loading resources at the beginning of my game written in MonoGame. I've several spritesheets which I'm loading at the beginning of the game. This take about 5-10 seconds on my computer but I've got some reports it takes up to a minute on other computers...that´s way too long. The reason is not loading the Texture2Ds but writing new RenderTargets on Startup. I've some colored spritesheets where I generate a black/white version of it on startup. That costs the time.

Now to my question: I've tried to do this operation later in the game so the game starts more quickly and I tried to start the color-> black/white operation when the player creates a new game - that would be a perfect situation to do it. But I always got two different kind of errors:

1. Operation not called on UI thread

or

2. Cannot call Present when a render target is active

As you may have guessed I do the load operation in a separate thread so the UI doesn't get frozen. But the actual problem seems to be, that I can not do RenderTarget operations when I'm already doing SpriteBatch operations (Begin and End).

How can I solve the problem?

Would be happy for any kind of suggestion.

Yheeky

\$\endgroup\$
2
  • \$\begingroup\$ Interesting problem. It might be worth posting the actual code that does the color => black/white operation. Also, have you considered pre-processing this content rather than doing it at run-time? \$\endgroup\$ Mar 25 '19 at 21:53
  • \$\begingroup\$ That´s what I'm currently doing actually :) That increases the file size but that´s the only way I could handle it so far \$\endgroup\$
    – Yheeky
    Mar 30 '19 at 2:13

You must log in to answer this question.

Browse other questions tagged .