Package WildMagic.LibGraphics.Shaders
Class Shader
- java.lang.Object
-
- WildMagic.LibGraphics.ObjectSystem.GraphicsObject
-
- WildMagic.LibGraphics.Shaders.Shader
-
- All Implemented Interfaces:
java.io.Serializable,StreamInterface
- Direct Known Subclasses:
PixelShader,VertexShader
public abstract class Shader extends GraphicsObject implements StreamInterface, java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Vector<java.lang.String>m_kImageNamesThe names of images used by an instance of a shader program.protected java.util.Vector<java.lang.String>m_kSamplerImageNamesprotected java.lang.Stringm_kShaderNameThe shader name, which contributes to a uniquely identifying string for a shader program.protected java.util.Vector<Texture>m_kTexturesTexture objects store the actual images and the samplers that are used to sample the images.protected java.util.Vector<java.lang.Float>m_kUserDataThe user-defined data are specific to each shader object.protected Programm_spkProgramThe shader program, which is dependent on graphics API.static java.lang.StringpixelShaderTexture2static java.lang.StringpixelShaderTextureTransparent2private static longserialVersionUIDstatic java.lang.StringvertexShaderTexture2static java.lang.StringvertexShaderTexture3
-
Constructor Summary
Constructors Modifier Constructor Description Shader()Support for streaming.protectedShader(java.lang.String rkShaderName)The constructor called by the derived classes VertexShader and PixelShader.protectedShader(java.lang.String rkShaderName, java.lang.String rkProgramText)The constructor called by the derived classes VertexShader and PixelShader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()Delete memory.intGetDiskUsed(StreamVersion rkVersion)Returns the size of this object and it's children on disk for the current StreamVersion parameter.SamplerInformationGetGetSamplerInformation(int i)Returns the SamplerInformation associated with the ith texture or sampler in the shader program.java.lang.StringGetImageName(int i)Get the image name.java.lang.StringGetShaderName()The name of the shader object.TextureGetTexture(int i)Get the texture at position i.TextureGetTexture(java.lang.String kSamplerImageName)intGetTextureQuantity()Return number of textures in this shader.voidLink(Stream rkStream, Stream.Link pkLink)Copies this objects children objects from the input Stream's HashTable, based on the LinkID of the child stored in the pkLink parameter.voidLoad(Stream rkStream, Stream.Link pkLink)Loads this object from the input parameter rkStream, using the input Stream.Link to store the IDs of children objects of this object for linking after all objects are loaded from the Stream.voidOnLoadProgram(Program pkProgram)Called when a program is loaded.voidOnReleaseProgram()Called when a program is released.booleanRegister(Stream rkStream)Registers this object with the input Stream parameter.voidSave(Stream rkStream)Write this object and all it's children to the Stream.StringTreeSaveStrings(java.lang.String acTitle)Write this object into a StringTree for the scene-graph visualization.voidSetImageName(int i, java.lang.String rkName, java.lang.String kSamplerImageName)Set the image name.voidSetTexture(int i, Texture kTexture, java.lang.String kSamplerImageName)Set the texture at position i.voidSetTextureQuantity(int iQuantity)Set the number of textures in this shader.-
Methods inherited from class WildMagic.LibGraphics.ObjectSystem.GraphicsObject
GetAllObjectsByName, GetID, GetName, GetNextID, GetObjectByID, GetObjectByIDBase, GetObjectByName, GetObjectByNameBase, SetName
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
m_kShaderName
protected java.lang.String m_kShaderName
The shader name, which contributes to a uniquely identifying string for a shader program.
-
m_spkProgram
protected Program m_spkProgram
The shader program, which is dependent on graphics API.
-
m_kUserData
protected java.util.Vector<java.lang.Float> m_kUserData
The user-defined data are specific to each shader object. The Program object knows only the name, which register to assign the value to, and how many registers to use. The storage provided here is for the convenience of Shader-derived classes. However, a derived class may provide alternate storage by calling UserConstant::SetDataSource for each user constant of interest.
-
m_kImageNames
protected java.util.Vector<java.lang.String> m_kImageNames
The names of images used by an instance of a shader program. The Texture objects store the actual images and the samplers that are used to sample the images.
-
m_kTextures
protected java.util.Vector<Texture> m_kTextures
Texture objects store the actual images and the samplers that are used to sample the images.
-
m_kSamplerImageNames
protected java.util.Vector<java.lang.String> m_kSamplerImageNames
-
vertexShaderTexture2
public static java.lang.String vertexShaderTexture2
-
vertexShaderTexture3
public static java.lang.String vertexShaderTexture3
-
pixelShaderTexture2
public static java.lang.String pixelShaderTexture2
-
pixelShaderTextureTransparent2
public static java.lang.String pixelShaderTextureTransparent2
-
-
Constructor Detail
-
Shader
public Shader()
Support for streaming.
-
Shader
protected Shader(java.lang.String rkShaderName)
The constructor called by the derived classes VertexShader and PixelShader.- Parameters:
rkShaderName- shader name.
-
Shader
protected Shader(java.lang.String rkShaderName, java.lang.String rkProgramText)The constructor called by the derived classes VertexShader and PixelShader.- Parameters:
rkShaderName- shader name.rkProgramText- shader program text.bUnique- flag
-
-
Method Detail
-
dispose
public void dispose()
Delete memory.- Overrides:
disposein classGraphicsObject
-
GetDiskUsed
public int GetDiskUsed(StreamVersion rkVersion)
Returns the size of this object and it's children on disk for the current StreamVersion parameter.- Specified by:
GetDiskUsedin interfaceStreamInterface- Overrides:
GetDiskUsedin classGraphicsObject- Parameters:
rkVersion- the current version of the Stream file being created.- Returns:
- the size of this object on disk.
-
GetGetSamplerInformation
public SamplerInformation GetGetSamplerInformation(int i)
Returns the SamplerInformation associated with the ith texture or sampler in the shader program.- Parameters:
i- the ith sampler in the shader program.- Returns:
- SamplerInformation.
-
GetImageName
public java.lang.String GetImageName(int i)
Get the image name.- Parameters:
i- image position.- Returns:
- image name.
-
GetShaderName
public final java.lang.String GetShaderName()
The name of the shader object. The program object has a name that contains the shader name as a substring, but adds additional text as needed (the path to a shader on disk, the identifying information for a procedurally generated shader).- Returns:
- shader name.
-
GetTexture
public Texture GetTexture(int i)
Get the texture at position i.- Parameters:
i- texture index.- Returns:
- texture at position i.
-
GetTexture
public Texture GetTexture(java.lang.String kSamplerImageName)
-
GetTextureQuantity
public int GetTextureQuantity()
Return number of textures in this shader.- Returns:
- number of textures in this shader.
-
Link
public void Link(Stream rkStream, Stream.Link pkLink)
Copies this objects children objects from the input Stream's HashTable, based on the LinkID of the child stored in the pkLink parameter.- Specified by:
Linkin interfaceStreamInterface- Overrides:
Linkin classGraphicsObject- Parameters:
rkStream- the Stream where the child objects are stored.pkLink- the Link class from which the child object IDs are read.
-
Load
public void Load(Stream rkStream, Stream.Link pkLink)
Loads this object from the input parameter rkStream, using the input Stream.Link to store the IDs of children objects of this object for linking after all objects are loaded from the Stream.- Specified by:
Loadin interfaceStreamInterface- Overrides:
Loadin classGraphicsObject- Parameters:
rkStream- the Stream from which this object is being read.pkLink- the Link class for storing the IDs of this object's children objects.
-
OnLoadProgram
public void OnLoadProgram(Program pkProgram)
Called when a program is loaded.- Parameters:
pkProgram- the newly loaded program.
-
OnReleaseProgram
public void OnReleaseProgram()
Called when a program is released.
-
Register
public boolean Register(Stream rkStream)
Registers this object with the input Stream parameter. All objects streamed to disk are registered with the Stream so that a unique list of objects is maintained.- Specified by:
Registerin interfaceStreamInterface- Overrides:
Registerin classGraphicsObject- Parameters:
rkStream- the Stream where the child objects are stored.- Returns:
- true if this object is registered, false if the object has already been registered.
-
Save
public void Save(Stream rkStream)
Write this object and all it's children to the Stream.- Specified by:
Savein interfaceStreamInterface- Overrides:
Savein classGraphicsObject- Parameters:
rkStream- the Stream where the child objects are stored.
-
SaveStrings
public StringTree SaveStrings(java.lang.String acTitle)
Write this object into a StringTree for the scene-graph visualization.- Specified by:
SaveStringsin interfaceStreamInterface- Overrides:
SaveStringsin classGraphicsObject- Parameters:
acTitle- the header for this object in the StringTree.- Returns:
- StringTree containing a String-based representation of this object and it's children.
-
SetImageName
public void SetImageName(int i, java.lang.String rkName, java.lang.String kSamplerImageName)Set the image name.- Parameters:
i- image position.rkName- image name.
-
SetTexture
public void SetTexture(int i, Texture kTexture, java.lang.String kSamplerImageName)Set the texture at position i.- Parameters:
i- texture index.kTexture- texture to put at position i.
-
SetTextureQuantity
public void SetTextureQuantity(int iQuantity)
Set the number of textures in this shader.- Parameters:
iQuantity- the number of textures in this shader.
-
-