org.ogre4j
Class Texture

java.lang.Object
  extended by org.xbig.base.NativeObject
      extended by org.ogre4j.Texture
All Implemented Interfaces:
IAllocatedObject<IResourceAllocPolicy>, IResource, IResourceAllocatedObject, IStringInterface, ITexture, INativeObject

public class Texture
extends NativeObject
implements ITexture


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.ogre4j.IResource
IResource.IListener, IResource.IListenerList
 
Field Summary
 
Fields inherited from class org.xbig.base.NativeObject
deleted, object, remote
 
Constructor Summary
  Texture(InstancePointer p)
          This constructor is public for internal useage only!
protected Texture(InstancePointer p, boolean remote)
          Creates a Java wrapper object for an existing C++ object.
  Texture(WithoutNativeObject val)
          Allows creation of Java objects without C++ objects.
 
Method Summary
 void _dirtyState()
          Manually mark the state of this resource as having been changed.
 void _fireBackgroundLoadingComplete()
          Firing of background loading complete event
 void _fireBackgroundPreparingComplete()
          Firing of background preparing complete event
 void _loadImages(IConstImagePtrList images)
          Internal method to load the texture from a set of images.
 void _notifyOrigin(java.lang.String origin)
           
 void addListener(IResource.IListener lis)
          Register a listener on this resource.
 void changeGroupOwnership(java.lang.String newGroup)
          Change the resource group ownership of a .
static void cleanupDictionary()
          Cleans up the static 'msDictionary' required to reset , otherwise the containers are left with invalid pointers, which will lead to a crash as soon as one of the implementers (e.g. ) initializes.
 void copyParametersTo(IStringInterface dest)
          Method for copying this object's parameters to another object.
 void copyToTexture(ITexturePtr target)
          Copies (and maybe scales to fit) the contents of this texture to another texture.
 void createInternalResources()
          Creates the internal texture resources for this texture.
 void delete()
          Deletes the corresponding C++ object.
 void escalateLoading()
          Escalates the loading of a background loaded resource.
 void finalize()
           
 void freeInternalResources()
          Frees internal texture resources for this texture.
 void getBuffer(IHardwarePixelBufferSharedPtr returnValue, int face, int mipmap)
          Return hardware pixel buffer for a surface.
 IResourceManager getCreator()
           
 int getDepth()
          Returns the depth of the texture (only applicable for 3D textures).
 int getDesiredFloatBitDepth()
          gets desired bit depth for float pixel format textures.
 PixelFormat getDesiredFormat()
          Returns the desired pixel format for the texture surface.
 int getDesiredIntegerBitDepth()
          gets desired bit depth for integer pixel format textures.
 PixelFormat getFormat()
          Returns the pixel format for the texture surface.
 long getFSAA()
          Get the level of multisample AA to be used if this texture is a rendertarget.
 float getGamma()
          Returns the gamma adjustment factor applied to this texture on loading.
 java.lang.String getGroup()
           
 long getHandle()
           
 int getHeight()
          Returns the height of the texture.
 Resource.LoadingState getLoadingState()
          Returns the current loading state.
 boolean getMipmapsHardwareGenerated()
          Are mipmaps hardware generated?
 java.lang.String getName()
          Gets resource name.
 int getNumFaces()
          Return the number of faces this texture has.
 int getNumMipmaps()
          Gets the number of mipmaps to be used for this texture.
 java.lang.String getOrigin()
          Get the origin of this resource, e.g. a script file name.
 IParamDictionary getParamDictionary_const()
           
 IParamDictionary getParamDictionary()
          Retrieves the parameter dictionary for this class.
 java.lang.String getParameter(java.lang.String name)
          Generic parameter retrieval method.
 IParameterList getParameters()
          Retrieves a list of parameters valid for this object.
 int getSize()
          Retrieves info about the size of the resource.
 int getSrcDepth()
          Returns the original depth of the input texture (only applicable for 3D textures).
 PixelFormat getSrcFormat()
          Returns the pixel format of the original input texture (may differ due to hardware requirements and pixel format convertion).
 int getSrcHeight()
          Returns the height of the original input texture (may differ due to hardware requirements).
 int getSrcWidth()
          Returns the width of the original input texture (may differ due to hardware requirements).
 int getStateCount()
          Returns the number of times this resource has changed state, which generally means the number of times it has been loaded.
 TextureType getTextureType()
          Gets the type of texture
 boolean getTreatLuminanceAsAlpha()
          Gets whether luminace pixel format will treated as alpha format when load this texture.
 int getUsage()
          Returns the TextureUsage indentifier for this
 int getWidth()
          Returns the width of the texture.
 boolean hasAlpha()
          Returns true if the texture has an alpha layer.
 boolean isBackgroundLoaded()
          Returns whether this has been earmarked for background loading.
 boolean isHardwareGammaEnabled()
          Gets whether this texture will be set up so that on sampling it, hardware gamma correction is applied.
 boolean isLoaded()
          Returns true if the has been loaded, false otherwise.
 boolean isLoading()
          Returns whether the resource is currently in the process of background loading.
 boolean isManuallyLoaded()
          Is this resource manually loaded?
 boolean isPrepared()
          Returns true if the has been prepared, false otherwise.
 boolean isReloadable()
          Returns true if the is reloadable, false otherwise.
 void load(boolean backgroundThread)
          Loads the resource, if it is not already.
 void loadImage(IImage img)
          Loads the data from an image.
 void loadRawData(IDataStreamPtr stream, int uWidth, int uHeight, PixelFormat eFormat)
          Loads the data from a raw stream.
 void prepare()
          Prepares the resource for load, if it is not already.
 void reload()
          Reloads the resource, if it is already loaded.
 void removeListener(IResource.IListener lis)
          Remove a listener on this resource.
 void setBackgroundLoaded(boolean bl)
          Tells the resource whether it is background loaded or not.
 void setDepth(int d)
          Set the depth of the texture (only applicable for 3D textures); ; can only do this before ;
 void setDesiredBitDepths(int integerBits, int floatBits)
          Sets desired bit depth for integer and float pixel format.
 void setDesiredFloatBitDepth(int bits)
          Sets desired bit depth for float pixel format textures.
 void setDesiredIntegerBitDepth(int bits)
          Sets desired bit depth for integer pixel format textures.
 void setFormat(PixelFormat pf)
          Sets the pixel format for the texture surface; can only be set before .
 void setFSAA(long fsaa)
          Set the level of multisample AA to be used if this texture is a rendertarget.
 void setGamma(float g)
          Sets the gamma adjustment factor applied to this texture on loading the data.
 void setHardwareGammaEnabled(boolean enabled)
          Sets whether this texture will be set up so that on sampling it, hardware gamma correction is applied.
 void setHeight(int h)
          Set the height of the texture; can only do this before ;
 void setNumMipmaps(int num)
          Sets the number of mipmaps to be used for this texture.
 boolean setParameter(java.lang.String name, java.lang.String value)
          Generic parameter setting method.
 void setParameterList(INameValuePairList paramList)
          Generic multiple parameter setting method.
 void setTextureType(TextureType ttype)
          Sets the type of texture; can only be changed before
 void setTreatLuminanceAsAlpha(boolean asAlpha)
          Sets whether luminace pixel format will treated as alpha format when load this texture.
 void setUsage(int u)
          Sets the TextureUsage indentifier for this ; only useful before
 void setWidth(int w)
          Set the width of the texture; can only do this before ;
 void touch()
          'Touches' the resource to indicate it has been used.
 void unload()
          Unloads the resource; this is not permanent, the resource can be reloaded later if required.
 
Methods inherited from class org.xbig.base.NativeObject
disconnectFromNativeObject, equals, getInstancePointer, hashCode, setInstancePointer, setInstancePointer, setInstancePointer, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xbig.base.INativeObject
disconnectFromNativeObject, getInstancePointer, setInstancePointer, setInstancePointer, setInstancePointer
 

Constructor Detail

Texture

public Texture(InstancePointer p)
This constructor is public for internal useage only! Do not use it!


Texture

protected Texture(InstancePointer p,
                  boolean remote)
Creates a Java wrapper object for an existing C++ object. If remote is set to 'true' this object cannot be deleted in Java.


Texture

public Texture(WithoutNativeObject val)
Allows creation of Java objects without C++ objects.

See Also:
WithoutNativeObject, INativeObject.disconnectFromNativeObject()
Method Detail

delete

public void delete()
Description copied from interface: INativeObject
Deletes the corresponding C++ object.

Subclasses must implement this but if the native instance was created by the underlying library the native call to dispose must not happen!

Specified by:
delete in interface INativeObject
Specified by:
delete in class NativeObject
See Also:
#remote

finalize

public void finalize()
Overrides:
finalize in class NativeObject

setTextureType

public void setTextureType(TextureType ttype)
Sets the type of texture; can only be changed before

Specified by:
setTextureType in interface ITexture

getTextureType

public TextureType getTextureType()
Gets the type of texture

Specified by:
getTextureType in interface ITexture

getNumMipmaps

public int getNumMipmaps()
Gets the number of mipmaps to be used for this texture.

Specified by:
getNumMipmaps in interface ITexture

setNumMipmaps

public void setNumMipmaps(int num)
Sets the number of mipmaps to be used for this texture.

Specified by:
setNumMipmaps in interface ITexture

getMipmapsHardwareGenerated

public boolean getMipmapsHardwareGenerated()
Are mipmaps hardware generated?

Specified by:
getMipmapsHardwareGenerated in interface ITexture

getGamma

public float getGamma()
Returns the gamma adjustment factor applied to this texture on loading.

Specified by:
getGamma in interface ITexture

setGamma

public void setGamma(float g)
Sets the gamma adjustment factor applied to this texture on loading the data.

Specified by:
setGamma in interface ITexture

setHardwareGammaEnabled

public void setHardwareGammaEnabled(boolean enabled)
Sets whether this texture will be set up so that on sampling it, hardware gamma correction is applied.

Specified by:
setHardwareGammaEnabled in interface ITexture

isHardwareGammaEnabled

public boolean isHardwareGammaEnabled()
Gets whether this texture will be set up so that on sampling it, hardware gamma correction is applied.

Specified by:
isHardwareGammaEnabled in interface ITexture

setFSAA

public void setFSAA(long fsaa)
Set the level of multisample AA to be used if this texture is a rendertarget.

Specified by:
setFSAA in interface ITexture

getFSAA

public long getFSAA()
Get the level of multisample AA to be used if this texture is a rendertarget.

Specified by:
getFSAA in interface ITexture

getHeight

public int getHeight()
Returns the height of the texture.

Specified by:
getHeight in interface ITexture

getWidth

public int getWidth()
Returns the width of the texture.

Specified by:
getWidth in interface ITexture

getDepth

public int getDepth()
Returns the depth of the texture (only applicable for 3D textures).

Specified by:
getDepth in interface ITexture

getSrcHeight

public int getSrcHeight()
Returns the height of the original input texture (may differ due to hardware requirements).

Specified by:
getSrcHeight in interface ITexture

getSrcWidth

public int getSrcWidth()
Returns the width of the original input texture (may differ due to hardware requirements).

Specified by:
getSrcWidth in interface ITexture

getSrcDepth

public int getSrcDepth()
Returns the original depth of the input texture (only applicable for 3D textures).

Specified by:
getSrcDepth in interface ITexture

setHeight

public void setHeight(int h)
Set the height of the texture; can only do this before ;

Specified by:
setHeight in interface ITexture

setWidth

public void setWidth(int w)
Set the width of the texture; can only do this before ;

Specified by:
setWidth in interface ITexture

setDepth

public void setDepth(int d)
Set the depth of the texture (only applicable for 3D textures); ; can only do this before ;

Specified by:
setDepth in interface ITexture

getUsage

public int getUsage()
Returns the TextureUsage indentifier for this

Specified by:
getUsage in interface ITexture

setUsage

public void setUsage(int u)
Sets the TextureUsage indentifier for this ; only useful before

Specified by:
setUsage in interface ITexture

createInternalResources

public void createInternalResources()
Creates the internal texture resources for this texture.

Specified by:
createInternalResources in interface ITexture

freeInternalResources

public void freeInternalResources()
Frees internal texture resources for this texture.

Specified by:
freeInternalResources in interface ITexture

copyToTexture

public void copyToTexture(ITexturePtr target)
Copies (and maybe scales to fit) the contents of this texture to another texture.

Specified by:
copyToTexture in interface ITexture

loadImage

public void loadImage(IImage img)
Loads the data from an image.

Specified by:
loadImage in interface ITexture

loadRawData

public void loadRawData(IDataStreamPtr stream,
                        int uWidth,
                        int uHeight,
                        PixelFormat eFormat)
Loads the data from a raw stream.

Specified by:
loadRawData in interface ITexture

_loadImages

public void _loadImages(IConstImagePtrList images)
Internal method to load the texture from a set of images.

Specified by:
_loadImages in interface ITexture

getFormat

public PixelFormat getFormat()
Returns the pixel format for the texture surface.

Specified by:
getFormat in interface ITexture

getDesiredFormat

public PixelFormat getDesiredFormat()
Returns the desired pixel format for the texture surface.

Specified by:
getDesiredFormat in interface ITexture

getSrcFormat

public PixelFormat getSrcFormat()
Returns the pixel format of the original input texture (may differ due to hardware requirements and pixel format convertion).

Specified by:
getSrcFormat in interface ITexture

setFormat

public void setFormat(PixelFormat pf)
Sets the pixel format for the texture surface; can only be set before .

Specified by:
setFormat in interface ITexture

hasAlpha

public boolean hasAlpha()
Returns true if the texture has an alpha layer.

Specified by:
hasAlpha in interface ITexture

setDesiredIntegerBitDepth

public void setDesiredIntegerBitDepth(int bits)
Sets desired bit depth for integer pixel format textures.

Specified by:
setDesiredIntegerBitDepth in interface ITexture

getDesiredIntegerBitDepth

public int getDesiredIntegerBitDepth()
gets desired bit depth for integer pixel format textures.

Specified by:
getDesiredIntegerBitDepth in interface ITexture

setDesiredFloatBitDepth

public void setDesiredFloatBitDepth(int bits)
Sets desired bit depth for float pixel format textures.

Specified by:
setDesiredFloatBitDepth in interface ITexture

getDesiredFloatBitDepth

public int getDesiredFloatBitDepth()
gets desired bit depth for float pixel format textures.

Specified by:
getDesiredFloatBitDepth in interface ITexture

setDesiredBitDepths

public void setDesiredBitDepths(int integerBits,
                                int floatBits)
Sets desired bit depth for integer and float pixel format.

Specified by:
setDesiredBitDepths in interface ITexture

setTreatLuminanceAsAlpha

public void setTreatLuminanceAsAlpha(boolean asAlpha)
Sets whether luminace pixel format will treated as alpha format when load this texture.

Specified by:
setTreatLuminanceAsAlpha in interface ITexture

getTreatLuminanceAsAlpha

public boolean getTreatLuminanceAsAlpha()
Gets whether luminace pixel format will treated as alpha format when load this texture.

Specified by:
getTreatLuminanceAsAlpha in interface ITexture

getNumFaces

public int getNumFaces()
Return the number of faces this texture has. This will be 6 for a cubemap texture and 1 for a 1D, 2D or 3D one.

Specified by:
getNumFaces in interface ITexture

getBuffer

public void getBuffer(IHardwarePixelBufferSharedPtr returnValue,
                      int face,
                      int mipmap)
Return hardware pixel buffer for a surface. This buffer can then be used to copy data from and to a particular level of the texture.

Specified by:
getBuffer in interface ITexture

prepare

public void prepare()
Prepares the resource for load, if it is not already. One can call before , but this is not required as will call itself, if needed. When OGRE_THREAD_SUPPORT==1 both and are thread-safe. When OGRE_THREAD_SUPPORT==2 however, only is thread-safe. The reason for this function is to allow a background thread to do some of the loading work, without requiring the whole render system to be thread-safe. The background thread would call while the main render loop would later call . So long as remains thread-safe, subclasses can arbitrarily split the work of loading a resource between and . It is best to try and do as much work in , however, since this will leave less work for the main render thread to do and thus increase FPS.

Specified by:
prepare in interface IResource

load

public void load(boolean backgroundThread)
Loads the resource, if it is not already.

Specified by:
load in interface IResource

reload

public void reload()
Reloads the resource, if it is already loaded.

Specified by:
reload in interface IResource

isReloadable

public boolean isReloadable()
Returns true if the is reloadable, false otherwise.

Specified by:
isReloadable in interface IResource

isManuallyLoaded

public boolean isManuallyLoaded()
Is this resource manually loaded?

Specified by:
isManuallyLoaded in interface IResource

unload

public void unload()
Unloads the resource; this is not permanent, the resource can be reloaded later if required.

Specified by:
unload in interface IResource

getSize

public int getSize()
Retrieves info about the size of the resource.

Specified by:
getSize in interface IResource

touch

public void touch()
'Touches' the resource to indicate it has been used.

Specified by:
touch in interface IResource

getName

public java.lang.String getName()
Gets resource name.

Specified by:
getName in interface IResource

getHandle

public long getHandle()
Specified by:
getHandle in interface IResource

isPrepared

public boolean isPrepared()
Returns true if the has been prepared, false otherwise.

Specified by:
isPrepared in interface IResource

isLoaded

public boolean isLoaded()
Returns true if the has been loaded, false otherwise.

Specified by:
isLoaded in interface IResource

isLoading

public boolean isLoading()
Returns whether the resource is currently in the process of background loading.

Specified by:
isLoading in interface IResource

getLoadingState

public Resource.LoadingState getLoadingState()
Returns the current loading state.

Specified by:
getLoadingState in interface IResource

isBackgroundLoaded

public boolean isBackgroundLoaded()
Returns whether this has been earmarked for background loading.

Specified by:
isBackgroundLoaded in interface IResource

setBackgroundLoaded

public void setBackgroundLoaded(boolean bl)
Tells the resource whether it is background loaded or not.

Specified by:
setBackgroundLoaded in interface IResource

escalateLoading

public void escalateLoading()
Escalates the loading of a background loaded resource.

Specified by:
escalateLoading in interface IResource

addListener

public void addListener(IResource.IListener lis)
Register a listener on this resource.

Specified by:
addListener in interface IResource

removeListener

public void removeListener(IResource.IListener lis)
Remove a listener on this resource.

Specified by:
removeListener in interface IResource

getGroup

public java.lang.String getGroup()
Specified by:
getGroup in interface IResource

changeGroupOwnership

public void changeGroupOwnership(java.lang.String newGroup)
Change the resource group ownership of a .

Specified by:
changeGroupOwnership in interface IResource

getCreator

public IResourceManager getCreator()
Specified by:
getCreator in interface IResource

getOrigin

public java.lang.String getOrigin()
Get the origin of this resource, e.g. a script file name.

Specified by:
getOrigin in interface IResource

_notifyOrigin

public void _notifyOrigin(java.lang.String origin)
Specified by:
_notifyOrigin in interface IResource

getStateCount

public int getStateCount()
Returns the number of times this resource has changed state, which generally means the number of times it has been loaded. Objects that build derived data based on the resource can check this value against a copy they kept last time they built this derived data, in order to know whether it needs rebuilding. This is a nice way of monitoring changes without having a tightly-bound callback.

Specified by:
getStateCount in interface IResource

_dirtyState

public void _dirtyState()
Manually mark the state of this resource as having been changed.

Specified by:
_dirtyState in interface IResource

_fireBackgroundLoadingComplete

public void _fireBackgroundLoadingComplete()
Firing of background loading complete event

Specified by:
_fireBackgroundLoadingComplete in interface IResource

_fireBackgroundPreparingComplete

public void _fireBackgroundPreparingComplete()
Firing of background preparing complete event

Specified by:
_fireBackgroundPreparingComplete in interface IResource

getParamDictionary

public IParamDictionary getParamDictionary()
Retrieves the parameter dictionary for this class.

Specified by:
getParamDictionary in interface IStringInterface

getParamDictionary_const

public IParamDictionary getParamDictionary_const()
Specified by:
getParamDictionary_const in interface IStringInterface

getParameters

public IParameterList getParameters()
Retrieves a list of parameters valid for this object.

Specified by:
getParameters in interface IStringInterface

setParameter

public boolean setParameter(java.lang.String name,
                            java.lang.String value)
Generic parameter setting method.

Specified by:
setParameter in interface IStringInterface

setParameterList

public void setParameterList(INameValuePairList paramList)
Generic multiple parameter setting method.

Specified by:
setParameterList in interface IStringInterface

getParameter

public java.lang.String getParameter(java.lang.String name)
Generic parameter retrieval method.

Specified by:
getParameter in interface IStringInterface

copyParametersTo

public void copyParametersTo(IStringInterface dest)
Method for copying this object's parameters to another object.

Specified by:
copyParametersTo in interface IStringInterface

cleanupDictionary

public static void cleanupDictionary()
Cleans up the static 'msDictionary' required to reset , otherwise the containers are left with invalid pointers, which will lead to a crash as soon as one of the implementers (e.g. ) initializes.



Copyright © 2007 netAllied GmbH. All Rights Reserved.