gzz.gfx.gl
Class MipzipLoader

gzz.gfx.gl.MipzipLoader gzz.mem.MemoryConsumer gzz.mem.MemoryPartitioner gzz.gfx.gl.MipzipMemoryConsumer ../../../../gl/Mipzip.gen.html#mipziploaderThread mipziploaderThread_small gzz.gfx.gl.MipzipLoader MipzipLoader.Level GL.Texture ../../../../gl/Mipzip.gen.html#mipziploaderStruct mipziploaderStruct_small
java.lang.Object
  |
  +--gzz.gfx.gl.MipzipLoader

public class MipzipLoader
extends java.lang.Object

A loader for Mipzip files: files of zipped, compressed mipmap levels.

RESPONSIBILITIES: Manage the combination of a single texture and a mipzip file, creating a "virtualized" texture of which better-quality versions can be loaded and discarded at will.


Field Summary
static boolean dbg
           
 
Constructor Summary
MipzipLoader(java.io.File mipzipFile)
          Create a new MipzipLoader for the given mipzip file.
 
Method Summary
 int getLevelForBytes(int memory)
          Get the level that uses at most given amount of memory.
 int getLevelForQuality(float quality)
          Get the level that needs to be used to obtain the given quality.
 java.awt.Dimension getLevelSize(int level)
          Get the size, in texels, of a texture level.
 int getMemory()
          Get the amount of memory currently used.
 int getMemory(int level)
          Get the amount of memory used if given level is loaded.
 int getNLevels()
          Get the number of mipmap levels in this mipzip.
 float getQuality()
           
 float getQuality(int level)
           
 GL.Texture getTexture()
          Get the OpenGL texture for this MipzipLoader.
 void loadToBaseLevelSynch(int level)
          Load to the base level synchronously: no discards.
 void setGoalBaseLevel(int level, Background bg, float priority)
          Set the base level goal for asynchronous loading.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dbg

public static boolean dbg
Constructor Detail

MipzipLoader

public MipzipLoader(java.io.File mipzipFile)
             throws java.io.IOException
Create a new MipzipLoader for the given mipzip file. Must be run in the GL thread.

Method Detail

loadToBaseLevelSynch

public void loadToBaseLevelSynch(int level)
                          throws java.io.IOException
Load to the base level synchronously: no discards.

Parameters:
level - The base level: the lowest-detail level to be loaded
java.io.IOException

setGoalBaseLevel

public void setGoalBaseLevel(int level,
                             Background bg,
                             float priority)
Set the base level goal for asynchronous loading. Calling this method starts the asynchronous process of loading or discarding mipmap levels.

Parameters:
level - The base level to move towards
bg - The background thread in which to run the part of loading which does not need to be in the OpenGL thread.
priority - The priority to pass to the background thread and UpdateManager

getTexture

public GL.Texture getTexture()
Get the OpenGL texture for this MipzipLoader. The only operations on the texture should be drawing it, or setting the following OpenGL parameters: Texture base level and max level and the actual texture images should not be touched.


getMemory

public int getMemory()
Get the amount of memory currently used.

Returns:
Memory, in bytes

getMemory

public int getMemory(int level)
Get the amount of memory used if given level is loaded.

Returns:
Memory, in bytes

getLevelForBytes

public int getLevelForBytes(int memory)
Get the level that uses at most given amount of memory.

Returns:
The level index.

getLevelForQuality

public int getLevelForQuality(float quality)
Get the level that needs to be used to obtain the given quality. Quality = pixels per texcoord unit, i.e. 1 = the whole texture is shown in 1 pixel, 100 = texture shown in 100x100 square (or like).


getQuality

public float getQuality()

getQuality

public float getQuality(int level)

getNLevels

public int getNLevels()
Get the number of mipmap levels in this mipzip.


getLevelSize

public java.awt.Dimension getLevelSize(int level)
Get the size, in texels, of a texture level. The return value must not be altered!


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object