Texture loading in Thread

Started by saifujiwara, October 13, 2008, 21:30:37

Previous topic - Next topic

saifujiwara

Hi, All

I have a big problem to manage time loading for one game http://mugen-net.sourceforge.net

Somes Characters has many many pictures in it (larges, and smalls), and it take very very long to load all image to texture.
One solution i found is to load on demand, if the texture is requiered the i load it, but this solution slow down the game.
(I can't change how the character picture is loading because of specification of Mugen, Mugen is not a game but it an engime)

Then I tried to load texture in a separate thread, but it seems that the loaded texture is empty because when it has to display, it display in White (no image ).

In this thread i tried GLContext.useContext(Display.getDrawable().getContext()); or/and Display.makeCurrent(); but it didn't solve my problem.

The thing i ask to myself, how do the other manage texture loading in Professionnal game, because i think they have more texture than i use.

Thank you very much for your helps

Best Regards

dronus

OpenGL doesn't like switching of threads. You could, however, just load the texture to some Buffer and keep that until rendering. On rendering, you just check if some Buffer  is there and then bind via  glTexImage2D. Works well.

I load awt  images in another thread. The texture renderer then checks before every rendering if the image loader has set the textures' image filed (!=null then) and then binds the texture. But that means that object with unloaded textures aren't not correctly rendered what is maybe not you want.


Professional games ususally preload a set of lo-res texure images, and then reload them in hi res as they became visible. Some engines keep the lo res images until the hires ones are fully loaded, thus enable smooth operation at cost of image quality, but the most ones wait till the textures are loaded thus slowing down rendering. This relies on the fact that objects came in view one after another. If vast amounts of new objects appear, the engine stalls on load. This can be seen on some engines for example on sudden explosions.

Evil-Devil

How about the overhead? In example several fuzzy and high detail textures will be loaded. Thats means to me i need at least one fuzzy texture for each high detail texture and when iam done with the high detail texture loading won't the bufferswap overhead not to big? Or how do you manage the data transfer from the texloader thread to the ogl thread?