|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.matthiasmann.textureloader.TextureManager
public class TextureManager
A texture manager which will load texture asynchronous on damand and also unloads them when not used for a certain amount of time.
Example main loop:
// before main loop
AsyncExecution async = new AsyncExecution();
TextureManager tm = new TextureManager(async);
...
// main loop
while(!Display.isCloseRequested()) {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
async.executeQueuedJobs();
tm.nextFrame();
handleInput();
renderStuff();
Display.update();
}
| Constructor Summary | |
|---|---|
TextureManager(AsyncExecution asyncExecution)
Creates a texture manager which uses a single threaded ExecutorService to
perform async loading of textures. |
|
TextureManager(AsyncExecution asyncExecution,
java.util.concurrent.ExecutorService executor)
Creates a texture manager which uses the specified ExecutorService to
perform async loading of textures. |
|
| Method Summary | |
|---|---|
static TextureLoader |
createTextureLoader(java.net.URL url)
Constructs a TextureLoader for the given URL. |
Texture |
getTexture(java.net.URL url)
Creates a managed texture instance for the specified URL. |
void |
nextFrame()
Checks for textures which have not been bound for a certain amount of time and unloads them. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TextureManager(AsyncExecution asyncExecution)
ExecutorService to
perform async loading of textures.
It is important to call AsyncExecution.executeQueuedJobs() on the
main thread at least once per frame.
asyncExecution - the AsyncExecution instance used to bridge threads
java.lang.NullPointerException - when asyncExecution is null
public TextureManager(AsyncExecution asyncExecution,
java.util.concurrent.ExecutorService executor)
ExecutorService to
perform async loading of textures.
It is important to call AsyncExecution.executeQueuedJobs() on the
main thread at least once per frame.
asyncExecution - the AsyncExecution instance used to bridge threadsexecutor - the ExecutorService used to load textures asynchronous to the GL thread
java.lang.NullPointerException - when one of the arguments is null| Method Detail |
|---|
public Texture getTexture(java.net.URL url)
Textures are cached using their URL.toString() as a key.
The texture is not loaded until it is first used.
url - the URL to load
public void nextFrame()
public static TextureLoader createTextureLoader(java.net.URL url)
TextureLoader for the given URL.
The file extension is used to select which subclass to use.
The following file extensions are supported: PNG, JPG, TGA and BMP
url -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||