com.jme.scene.state.lwjgl
Class LWJGLTextureState

java.lang.Object
  extended by com.jme.scene.state.RenderState
      extended by com.jme.scene.state.TextureState
          extended by com.jme.scene.state.lwjgl.LWJGLTextureState
All Implemented Interfaces:
Savable

public class LWJGLTextureState
extends TextureState

LWJGLTextureState subclasses the TextureState object using the LWJGL API to access OpenGL for texture processing.

Version:
$Id: LWJGLTextureState.java 4295 2009-04-29 08:08:56Z mulova $
Author:
Mark Powell, Joshua Slack

Nested Class Summary
protected static class LWJGLTextureState.LWJGLMipMap
          override MipMap to access helper methods
 
Nested classes/interfaces inherited from class com.jme.scene.state.TextureState
TextureState.CorrectionType
 
Nested classes/interfaces inherited from class com.jme.scene.state.RenderState
RenderState.StateType
 
Field Summary
 
Fields inherited from class com.jme.scene.state.TextureState
automaticMipMaps, automaticMipMapsDetected, defaultTexture, firstTexture, idCache, lastTexture, maxAnisotropic, numFixedTexUnits, numFragmentTexCoordUnits, numFragmentTexUnits, numTotalTexUnits, numVertexTexUnits, offset, supportsAniso, supportsAnisoDetected, supportsDepthTexture, supportsEnvCombine, supportsEnvCombineDetected, supportsEnvDot3, supportsEnvDot3Detected, supportsMultiTexture, supportsMultiTextureDetected, supportsNonPowerTwo, supportsNonPowerTwoDetected, supportsRectangular, supportsRectangularDetected, supportsS3TCCompression, supportsS3TCCompressionDetected, supportsShadow, supportsTexture3D, supportsTexture3DDetected, supportsTextureCubeMap, supportsTextureCubeMapDetected, texture
 
Fields inherited from class com.jme.scene.state.RenderState
QUICK_COMPARE, RS_BLEND, RS_CLIP, RS_COLORMASK_STATE, RS_CULL, RS_FOG, RS_FRAGMENT_PROGRAM, RS_GLSL_SHADER_OBJECTS, RS_LIGHT, RS_MATERIAL, RS_MAX_STATE, RS_SHADE, RS_STENCIL, RS_TEXTURE, RS_VERTEX_PROGRAM, RS_WIREFRAME, RS_ZBUFFER
 
Constructor Summary
LWJGLTextureState()
          Constructor instantiates a new LWJGLTextureState object.
 
Method Summary
 void apply()
          apply manages the textures being described by the state.
static void applyBlendColor(Texture texture, TextureUnitRecord unitRecord, int unit, TextureStateRecord record)
           
static void applyBorderColor(Texture texture, TextureRecord texRecord, int unit, TextureStateRecord record)
           
static void applyCombineFactors(Texture texture, TextureUnitRecord unitRecord, int unit, TextureStateRecord record)
           
static void applyEnvMode(Texture.ApplyMode mode, TextureUnitRecord unitRecord, int unit, TextureStateRecord record)
           
static void applyFilter(Texture texture, TextureRecord texRecord, int unit, TextureStateRecord record)
          Check if the filter settings of this particular texture have been changed and apply as needed.
static void applyShadow(Texture texture, TextureRecord texRecord, int unit, TextureStateRecord record)
          Check if the filter settings of this particular texture have been changed and apply as needed.
static void applyTexCoordGeneration(Texture texture, TextureUnitRecord unitRecord, int unit, TextureStateRecord record)
           
static void applyTextureTransforms(Texture texture, int unit, TextureStateRecord record)
           
static void applyWrap(Texture1D texture, TextureRecord texRecord, int unit, TextureStateRecord record)
          Check if the wrap mode of this particular texture has been changed and apply as needed.
static void applyWrap(Texture2D texture, TextureRecord texRecord, int unit, TextureStateRecord record)
          Check if the wrap mode of this particular texture has been changed and apply as needed.
static void applyWrap(Texture3D texture, TextureRecord texRecord, int unit, TextureStateRecord record)
          Check if the wrap mode of this particular texture has been changed and apply as needed.
static void applyWrap(TextureCubeMap cubeMap, TextureRecord texRecord, int unit, TextureStateRecord record)
          Check if the wrap mode of this particular texture has been changed and apply as needed.
static void applyWrap(Texture texture, TextureRecord texRecord, int unit, TextureStateRecord record)
          Check if the wrap mode of this particular texture has been changed and apply as needed.
static void checkAndSetUnit(int unit, TextureStateRecord record)
           
 StateRecord createStateRecord()
           
 void delete(int unit)
          Removes the texture of the given unit.
 void deleteAll()
          Removes all Texture set in this TextureState.
 void deleteAll(boolean removeFromCache)
          Removes all Texture set in this TextureState.
 void deleteTextureId(int textureId)
           
static void doTextureBind(int textureId, int unit, Texture.Type type)
          Useful for external lwjgl based classes that need to safely set the current texture.
 RenderState extract(java.util.Stack<? extends RenderState> stack, Spatial spat)
          Extracts from the stack the correct renderstate that should apply to the given spatial.
 void load(int unit)
          Loads the texture for the given unit into the underlying rendering system, generating mip maps if appropriate.
 
Methods inherited from class com.jme.scene.state.TextureState
clearTextures, getClassTag, getCorrectionType, getDefaultTexture, getDefaultTextureImage, getMaxAnisotropic, getNumberOfFixedUnits, getNumberOfFragmentTexCoordUnits, getNumberOfFragmentUnits, getNumberOfSetTextures, getNumberOfTotalUnits, getNumberOfVertexUnits, getStateType, getTexture, getTexture, getTextureCoordinateOffset, getTextureID, getTotalNumberOfUnits, getType, isAnisoSupported, isAutomaticMipmapsSupported, isEnvCombineSupported, isEnvDot3Supported, isMultiTextureSupported, isNonPowerOfTwoTextureSupported, isRectangularTextureSupported, isS3TCSupported, isTexture3DSupported, isTextureCubeMapSupported, load, overrideAnisoSupport, overrideAutomaticMipmapsSupport, overrideEnvCombineSupport, overrideEnvDot3Support, overrideMultiTextureSupport, overrideNonPowerOfTwoTextureSupport, overrideRectangularTextureSupport, overrideS3TCSupport, overrideTexture3DSupport, overrideTextureCubeMapSupport, read, removeTexture, removeTexture, resetAnisoSupport, resetAutomaticMipmapsSupport, resetEnvCombineSupport, resetEnvDot3Support, resetFirstLast, resetMultiTextureSupport, resetNonPowerOfTwoTextureSupport, resetRectangularTextureSupport, resetS3TCSupport, resetTexture3DSupport, resetTextureCubeMapSupport, setCorrectionType, setTexture, setTexture, setTextureCoordinateOffset, write
 
Methods inherited from class com.jme.scene.state.RenderState
isEnabled, needsRefresh, setEnabled, setNeedsRefresh, setQuickCompares
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LWJGLTextureState

public LWJGLTextureState()
Constructor instantiates a new LWJGLTextureState object. The number of textures that can be combined is determined during construction. This equates the number of texture units supported by the graphics card.

Method Detail

load

public final void load(int unit)
Description copied from class: TextureState
Loads the texture for the given unit into the underlying rendering system, generating mip maps if appropriate.

Specified by:
load in class TextureState

apply

public void apply()
apply manages the textures being described by the state. If the texture has not been loaded yet, it is generated and loaded using OpenGL11. This means the initial pass to set will be longer than subsequent calls. The multitexture extension is used to define the multiple texture states, with the number of units being determined at construction time.

Specified by:
apply in class RenderState
See Also:
RenderState.apply()

applyCombineFactors

public static void applyCombineFactors(Texture texture,
                                       TextureUnitRecord unitRecord,
                                       int unit,
                                       TextureStateRecord record)

applyEnvMode

public static void applyEnvMode(Texture.ApplyMode mode,
                                TextureUnitRecord unitRecord,
                                int unit,
                                TextureStateRecord record)

applyBlendColor

public static void applyBlendColor(Texture texture,
                                   TextureUnitRecord unitRecord,
                                   int unit,
                                   TextureStateRecord record)

applyBorderColor

public static void applyBorderColor(Texture texture,
                                    TextureRecord texRecord,
                                    int unit,
                                    TextureStateRecord record)

applyTextureTransforms

public static void applyTextureTransforms(Texture texture,
                                          int unit,
                                          TextureStateRecord record)

applyTexCoordGeneration

public static void applyTexCoordGeneration(Texture texture,
                                           TextureUnitRecord unitRecord,
                                           int unit,
                                           TextureStateRecord record)

checkAndSetUnit

public static void checkAndSetUnit(int unit,
                                   TextureStateRecord record)

applyShadow

public static void applyShadow(Texture texture,
                               TextureRecord texRecord,
                               int unit,
                               TextureStateRecord record)
Check if the filter settings of this particular texture have been changed and apply as needed.

Parameters:
texture - our texture object
texRecord - our record of the last state of the texture in gl
record -

applyFilter

public static void applyFilter(Texture texture,
                               TextureRecord texRecord,
                               int unit,
                               TextureStateRecord record)
Check if the filter settings of this particular texture have been changed and apply as needed.

Parameters:
texture - our texture object
texRecord - our record of the last state of the texture in gl
record -

applyWrap

public static void applyWrap(Texture3D texture,
                             TextureRecord texRecord,
                             int unit,
                             TextureStateRecord record)
Check if the wrap mode of this particular texture has been changed and apply as needed.

Parameters:
texture - our texture object
texRecord - our record of the last state of the unit in gl
record -

applyWrap

public static void applyWrap(Texture1D texture,
                             TextureRecord texRecord,
                             int unit,
                             TextureStateRecord record)
Check if the wrap mode of this particular texture has been changed and apply as needed.

Parameters:
texture - our texture object
texRecord - our record of the last state of the unit in gl
record -

applyWrap

public static void applyWrap(Texture texture,
                             TextureRecord texRecord,
                             int unit,
                             TextureStateRecord record)
Check if the wrap mode of this particular texture has been changed and apply as needed.

Parameters:
texture - our texture object
texRecord - our record of the last state of the unit in gl
record -

applyWrap

public static void applyWrap(Texture2D texture,
                             TextureRecord texRecord,
                             int unit,
                             TextureStateRecord record)
Check if the wrap mode of this particular texture has been changed and apply as needed.

Parameters:
texture - our texture object
texRecord - our record of the last state of the unit in gl
record -

applyWrap

public static void applyWrap(TextureCubeMap cubeMap,
                             TextureRecord texRecord,
                             int unit,
                             TextureStateRecord record)
Check if the wrap mode of this particular texture has been changed and apply as needed.

Parameters:
cubeMap - our texture object
texRecord - our record of the last state of the unit in gl
record -

extract

public RenderState extract(java.util.Stack<? extends RenderState> stack,
                           Spatial spat)
Description copied from class: RenderState
Extracts from the stack the correct renderstate that should apply to the given spatial. This is mainly used for RenderStates that can be cumulative such as TextureState or LightState. By default, the top of the static is returned. This function should not be called by users directly.

Overrides:
extract in class RenderState
Parameters:
stack - The stack to extract render states from.
spat - The spatial to apply the render states too.
Returns:
The render state to use.

delete

public void delete(int unit)
Description copied from class: TextureState
Removes the texture of the given unit.

Specified by:
delete in class TextureState
Parameters:
unit - The unit of the Texture to remove.

deleteAll

public void deleteAll()
Description copied from class: TextureState
Removes all Texture set in this TextureState. Does not also remove from TextureManager's cache.

Specified by:
deleteAll in class TextureState

deleteAll

public void deleteAll(boolean removeFromCache)
Description copied from class: TextureState
Removes all Texture set in this TextureState. Also removes the textures from the TextureManager cache if passed boolean is true.

Specified by:
deleteAll in class TextureState

deleteTextureId

public void deleteTextureId(int textureId)
Overrides:
deleteTextureId in class TextureState

createStateRecord

public StateRecord createStateRecord()
Specified by:
createStateRecord in class RenderState

doTextureBind

public static void doTextureBind(int textureId,
                                 int unit,
                                 Texture.Type type)
Useful for external lwjgl based classes that need to safely set the current texture.