Is there a way to force a redraw "now"?

Hi,

I’m sure I overlooked something simple, but I’m facing a problem where my computer seems to be “too fast” for…

[java]
nifty.getScreen(“screen1”).findElementByName(“text_loading”).getRenderer(TextRenderer.class).setText(“LOADING”);
[/java]

…to be drawn by the GPU before the rest of the start_game() event handler loads very asset and starts the game. Basically, on my computer, it hangs for 1 second which is not that bad, but for an older computer, the loading process may take up to 5 seconds, so I’d like this LOADING message to be shown on the screen while the user waits, but I can’t find any way of forcing the buffers to update on the GPU. Any idea?

Is there like a: sleep(20f) function or something so that I can insert this line between the nifty text update and the rest of the loading process?

Thx :smiley:

Just don’t block the update loop? Or at least do your stuff in the second frame and let the first frame through to display the UI.

2 Likes

Yeah that’s what I was afraid I’d end up doing. So basically, all the asset loading and level generation will have to happen after the first update loop. The first one will just be used to refresh the Nifty text label. Is that right?

If you are afraid of doing this, stop game development now ^^

Quit trolling. I was saying that because I find it unclean to perform an IF branch on every update loop. What I ended up doing is create a 10ms timer and upon timeout, proceed with loading assets and start the game, therefore 10ms is plenty enough for at least a redraw and my loading message is displaying correctly. I’m not comfortable settling to have the whole game update loop in a IF branch, unless that wasn’t what you were talking about…? Anyhow, I +1’ed you. Thx

Why not use a initial loading AppState? then just detach it later, way cleaner.

@.Ben. said: Quit trolling. I was saying that because I find it unclean to perform an IF branch on every update loop. What I ended up doing is create a 10ms timer and upon timeout, proceed with loading assets and start the game, therefore 10ms is plenty enough for at least a redraw and my loading message is displaying correctly. I'm not comfortable settling to have the whole game update loop in a IF branch, unless that wasn't what you were talking about...? Anyhow, I +1'ed you. Thx

Thats a bad idea and nobody suggested that, you better go with what Empire said or make your own class that detaches itself from the update after it did its work.

I will study how AppStates work and try it, thank you for the suggestion.