The slow part of loading texture is loading them off disk - just load them
using another thread into any app-defined memory you have lying around. Then
have the loader thread signal that the texture is loaded, then the main
thread copies it into the D3D/OGL-owned buffer. It's very quick - you won't
be doing more than one of these a frame, so the speed bump will hardly be
noticeable.
For smooth progress bars, I just have a little routine (not in a thread)
that you call really frequently, and it keeps a record of when it was last
called. If it was less than say 100ms ago, it just returns. Otherwise it
does a smooth interpolation of the progress bar (just a displayed_val = 0.9F
* displayed_val + real_val * 0.1f; does nicely) and draws it to the screen.
Then you scatter calls to this liberally all over your loading routines, and
there you go - smooth loading bars.
Tom Forsyth - purely hypothetical Muckyfoot bloke.
This email is the product of your deranged imagination,
and does not in any way imply existence of the author.
> -----Original Message-----
> From: Thatcher Ulrich [mailto:tu...@tu...]
> Sent: 07 August 2002 04:27
> To: gam...@li...
> Subject: Re: [GD-General] worker threads, level loading and progress
> bars
>
>
> I took a stab at this (loading in a background thread) in Soul Ride.
> In Win32, it's pretty easy to set up a new OpenGL render context, and
> use wglShareLists() so that textures defined in one thread are usable
> in the other thread.
>
> In captivity it worked, pretty well in fact. But at the time
> (early/mid 2000, IIRC) it was highly vulnerable to bugs in driver
> thread support, so I gave up and fell back on the DoWork() pattern.
>
> Under X, there seems to be a way to share textures across threads, but
> I never got around to trying it. Nowadays I try to use SDL for all
> video setup & config, and it does not have a facility like
> wglShareLists :(
>
> The worker queue thing works as well; my Chunked LOD demo uses this
> pattern -- I load the image data in the loader thread, and bind it in
> the foreground thread. But it still means some extra, unnecessary
> work for the foreground thread; plus the coding work.
>
> -Thatcher
>
> On Aug 07, 2002 at 04:44 +0200, Ignacio Casta?o wrote:
> > Hmm... it seems to my now, that the problem with the
> multiple threads could
> > be easily solved.
> >
> > The only OpenGL operation performed by the worker thread is
> to upload
> > textures, so my texture manager could have a list of
> textures waiting to be
> > uploaded, and I could process them on each game loop.
> >
> > Anyway, I still would like to hear how others have solve
> this problem.
> >
> >
> > Ignacio Casta?o
> > cas...@ya...
> >
> >
> > Ignacio Casta?o wrote:
> > > Hi,
> > > to display a progress bar during the level loads, I've always used
> > somekind
> > > of callback mechanism, or a simple 'DoWork' function that
> performs a
> > little
> > > part of the work in each call and returns a special value
> when the work
> > has
> > > been finished. Those approaches worked ok, but the
> progress of the bar
> > > wasn't smooth and the resulting code was not very clean:
> > > ...
> >
> >
> > _______________________________________________________________
> > Copa del Mundo de la FIFA 2002
> > El ?nico lugar de Internet con v?deos de los 64 partidos.
> > ?Ap?ntante ya! en http://fifaworldcup.yahoo.com/fc/es/
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Gamedevlists-general mailing list
> > Gam...@li...
> > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
> > Archives:
> > http://sourceforge.net/mailarchive/forum.php?forum_id=557
>
> --
> Thatcher Ulrich
> http://tulrich.com
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Gamedevlists-general mailing list
> Gam...@li...
> https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_id=557
>
|