com.badlogic.gdx.graphics.g3d.utils
Class DefaultTextureBinder

java.lang.Object
  extended by com.badlogic.gdx.graphics.g3d.utils.DefaultTextureBinder
All Implemented Interfaces:
TextureBinder

public final class DefaultTextureBinder
extends Object
implements TextureBinder

Class that you assign a range of texture units and binds textures for you within that range. It does some basic usage tracking to avoid unnessecary bind calls.

Author:
xoppa

Field Summary
static int MAX_GLES_UNITS
          GLES only supports up to 32 textures
static int ROUNDROBIN
           
static int WEIGHTED
           
 
Constructor Summary
DefaultTextureBinder(int method)
          Uses all available texture units and reuse weight of 3
DefaultTextureBinder(int method, int offset)
          Uses all remaining texture units and reuse weight of 3
DefaultTextureBinder(int method, int offset, int count)
          Uses reuse weight of 10
DefaultTextureBinder(int method, int offset, int count, int reuseWeight)
           
 
Method Summary
 void begin()
          Prepares the binder for operation, must be matched with a call to TextureBinder.end().
 int bind(GLTexture texture)
          Binds the texture to an available unit.
 int bind(TextureDescriptor textureDesc)
          Binds the texture to an available unit and applies the filters in the descriptor.
 void end()
          Disables all used texture units and unbinds textures.
 int getBindCount()
           
 int getReuseCount()
           
 void resetCounts()
          Resets the bind/reuse counts
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROUNDROBIN

public static final int ROUNDROBIN
See Also:
Constant Field Values

WEIGHTED

public static final int WEIGHTED
See Also:
Constant Field Values

MAX_GLES_UNITS

public static final int MAX_GLES_UNITS
GLES only supports up to 32 textures

See Also:
Constant Field Values
Constructor Detail

DefaultTextureBinder

public DefaultTextureBinder(int method)
Uses all available texture units and reuse weight of 3


DefaultTextureBinder

public DefaultTextureBinder(int method,
                            int offset)
Uses all remaining texture units and reuse weight of 3


DefaultTextureBinder

public DefaultTextureBinder(int method,
                            int offset,
                            int count)
Uses reuse weight of 10


DefaultTextureBinder

public DefaultTextureBinder(int method,
                            int offset,
                            int count,
                            int reuseWeight)
Method Detail

begin

public void begin()
Description copied from interface: TextureBinder
Prepares the binder for operation, must be matched with a call to TextureBinder.end().

Specified by:
begin in interface TextureBinder

end

public void end()
Description copied from interface: TextureBinder
Disables all used texture units and unbinds textures. Resets the counts.

Specified by:
end in interface TextureBinder

bind

public final int bind(TextureDescriptor textureDesc)
Description copied from interface: TextureBinder
Binds the texture to an available unit and applies the filters in the descriptor.

Specified by:
bind in interface TextureBinder
Parameters:
textureDesc - the TextureDescriptor
Returns:
the unit the texture was bound to

bind

public final int bind(GLTexture texture)
Description copied from interface: TextureBinder
Binds the texture to an available unit.

Specified by:
bind in interface TextureBinder
Parameters:
texture - the Texture
Returns:
the unit the texture was bound to

getBindCount

public final int getBindCount()
Specified by:
getBindCount in interface TextureBinder
Returns:
the number of binds actually executed since the last call to TextureBinder.resetCounts()

getReuseCount

public final int getReuseCount()
Specified by:
getReuseCount in interface TextureBinder
Returns:
the number of binds that could be avoided by reuse

resetCounts

public final void resetCounts()
Description copied from interface: TextureBinder
Resets the bind/reuse counts

Specified by:
resetCounts in interface TextureBinder


Copyright © 2013. All Rights Reserved.