Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Loading logic

Name: Anonymous 2011-10-18 17:37

Hi there /prog/

Let's discuss the logic for handling the loading of files, as well as displaying the "loading" image to user while the content is loading.  Currently I have a boolean, g_Loading.  After all of the assets have finished loading, I set the value of the boolean to false.

Every single iteration I check if g_Loading is true, if so display the loading graphic and nothing else.  Else, we should display everything but the loading graphic.  Currently this works well, however I'm sure there might be a slight performance decrease if we're still comparing the g_Loading boolean every single frame, even if we're already done loading.

Bow do you like to achieve this, /prog/?
Thanks for any help!

Name: Anonymous 2011-10-18 17:39

Comparing a booolean is so fast compared to that graphic stuff that you could do it a thousand times per frame and get no noticeable slowdown.
Also, interrupts.

Name: Anonymous 2011-10-18 20:47

Not sure what you're working with, but I'm sure you could find a way to anticipate how long it would take to load a given file. Typically by looking at the filesize of what you're pulling up. After that anticipated interval has passed, then run a check. Exit the loop once it finishes loading and you need not worry about it constantly checking after it, in fact, loads.

Name: Anonymous 2011-10-19 0:04

>performance decrease if we're still comparing the g_Loading boolean every single frame

Name: Anonymous 2011-10-19 1:24

You code is wrong: You should not compared anything or have such booleans. You just display whatever has loaded. If it doesn't loads instantly or stalls for a "loading screen" you have problems.
Loading screens are symptom of very low performance or very sloppy code.

Name: Anonymous 2011-10-19 2:03

Use an event dispatcher. You can have an update, complete, and error, which passes the (pointer to) the data as an argument to the callback, or an event object of your design. If you'd like, you can also design the dispatch routine to receive resources that you want it to load as arguments; this all depends on your needs,  what language you're writing in, and what your conventions are.

But anyway, it shouldn't be your job to keep track of the state of a procedure with your own (global!) scribbled note and an alarm clock. You should let the procedure do the work for you, and come back to you with a report, like a worker is supposed to.

Name: Anonymous 2011-10-19 2:16

You can just set pointers for non-loaded assets to default asset(loaded at startup) and when the code finished loading update the pointer to new location.

Name: Anonymous 2011-10-19 2:30

>>5
/thread

Don't change these.
Name: Email:
Entire Thread Thread List