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_kImageNames
The names of images used by an instance of a shader program.protected java.util.Vector<java.lang.String>
m_kSamplerImageNames
protected java.lang.String
m_kShaderName
The shader name, which contributes to a uniquely identifying string for a shader program.protected java.util.Vector<Texture>
m_kTextures
Texture objects store the actual images and the samplers that are used to sample the images.protected java.util.Vector<java.lang.Float>
m_kUserData
The user-defined data are specific to each shader object.protected Program
m_spkProgram
The shader program, which is dependent on graphics API.static java.lang.String
pixelShaderTexture2
static java.lang.String
pixelShaderTextureTransparent2
private static long
serialVersionUID
static java.lang.String
vertexShaderTexture2
static java.lang.String
vertexShaderTexture3
-
Constructor Summary
Constructors Modifier Constructor Description Shader()
Support for streaming.protected
Shader(java.lang.String rkShaderName)
The constructor called by the derived classes VertexShader and PixelShader.protected
Shader(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 void
dispose()
Delete memory.int
GetDiskUsed(StreamVersion rkVersion)
Returns the size of this object and it's children on disk for the current StreamVersion parameter.SamplerInformation
GetGetSamplerInformation(int i)
Returns the SamplerInformation associated with the ith texture or sampler in the shader program.java.lang.String
GetImageName(int i)
Get the image name.java.lang.String
GetShaderName()
The name of the shader object.Texture
GetTexture(int i)
Get the texture at position i.Texture
GetTexture(java.lang.String kSamplerImageName)
int
GetTextureQuantity()
Return number of textures in this shader.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.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.void
OnLoadProgram(Program pkProgram)
Called when a program is loaded.void
OnReleaseProgram()
Called when a program is released.boolean
Register(Stream rkStream)
Registers this object with the input Stream parameter.void
Save(Stream rkStream)
Write this object and all it's children to the Stream.StringTree
SaveStrings(java.lang.String acTitle)
Write this object into a StringTree for the scene-graph visualization.void
SetImageName(int i, java.lang.String rkName, java.lang.String kSamplerImageName)
Set the image name.void
SetTexture(int i, Texture kTexture, java.lang.String kSamplerImageName)
Set the texture at position i.void
SetTextureQuantity(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:
dispose
in 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:
GetDiskUsed
in interfaceStreamInterface
- Overrides:
GetDiskUsed
in 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:
Link
in interfaceStreamInterface
- Overrides:
Link
in 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:
Load
in interfaceStreamInterface
- Overrides:
Load
in 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:
Register
in interfaceStreamInterface
- Overrides:
Register
in 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:
Save
in interfaceStreamInterface
- Overrides:
Save
in 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:
SaveStrings
in interfaceStreamInterface
- Overrides:
SaveStrings
in 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.
-
-