Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Background Loading

Author
Message
Davey B
21
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 21st Sep 2010 23:33
Not sure if this is possible but I've developed a very large map divided into sectors. Only models in the players current sector are loaded along with their textures etc.

Trouble I'm having is that the transition from one sector to another lasts a good 5 - 10 seconds depending on the number of objects/textures to load in, which freezes the program until loading completes.

My question is, is there a way to load assets into a game dynamically without the player being aware whilst the main loop can carry on as normal? I'm sure such a solution will likely be over my head but if there are any suggestions it's be appreciated.

Thanks
Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 23rd Sep 2010 01:16
As far as I know, it's not possible to load an individual piece of media "in the background" in DBP. It's certainly a feature I would find useful, and I and many others have tried to find how to do this before, but to no avail. Perhaps something has changed since last I checked though.

You say that you have a number of models and textures. Load one at a time inbetween game cycles. If you don't have any really big single models or textures, it could be workable.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Sep 2010 01:24
I have a plug-in on my old site that allows a file to be loaded into a memblock in background (another thread), but didn't get any further with that. (DBPro isn't threadsafe, so going the whole hog with background loading could lose you whole sets of objects and images if certain events happen at the wrong time).

A few years ago I did experiment with a piece of code that allowed terrain to be generated gradually from a file and within the main loop using my function-pointer/co-routine plug-in. It worked after a fashion, but wasn't ideal. I can see if I can find the code if that's any help.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 23rd Sep 2010 18:28
I remember reading somewhere that DBPro isn't thread-safe because if you try and access an object's properties or manipulate it in some fashion while it's being loaded in the other thread, then that could (or would) cause something horrific to happen.

So what if you had an array where you stored all your object information, and in the array just a boolean value to indicate whether the object is fully loaded or not?

Then just write your program to NOT access any information about an object unless that value is true.

@IanM, is it possible that might work?

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 23rd Sep 2010 21:05
I can't remember where I saw this.. I swear it was a source code example on my PC, but I don't remember what it was from.

Possibly had to do with Styx, and using the Interval / Function Reference / Callback commands to load multiple bits of data at the same time. You could do it in sync with the main loop, or independently in threads.

I'll try to find it.

pcRaider
19
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 24th Sep 2010 19:30
You can make reading speed fast.
I attach sample data.
In reading time of these data, it is 8 seconds.
I can shorten reading time.

.JPG is slow.
.X is slow.
Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 25th Sep 2010 00:27 Edited at: 25th Sep 2010 00:29
I wasn't able to find the example I posted about earlier.. If anyone might happen to know what I'm talking about - I think it was an example program that loaded some stuff while an animated sprite was playing...

I'm almost positive it was something to do with Styx but I can't remember for certain. My help files for some reason are in complete disarray and I can't seem to find stuff I had on my old DBPro installation

Login to post a reply

Server time is: 2026-07-23 12:45:59
Your offset time is: 2026-07-23 12:45:59