org.xith3d.loaders.shaders.impl.glsl
Class GLSLShaderLoader

java.lang.Object
  extended by org.xith3d.loaders.shaders.base.ShaderLoader<GLSLShader>
      extended by org.xith3d.loaders.shaders.impl.glsl.GLSLShaderLoader

public class GLSLShaderLoader
extends ShaderLoader<GLSLShader>

Loads a GLSL shaders.


Nested Class Summary
static class GLSLShaderLoader.InlineVariableMapping
          This defines a mapping for placeholders in a shader source, that are replaced by the provided values.
 
Constructor Summary
GLSLShaderLoader()
          Constructs a Loader with default values for all variables.
GLSLShaderLoader(java.lang.String basePath)
          Constructs a Loader with the specified basePath.
GLSLShaderLoader(java.net.URL baseURL)
          Constructs a Loader with the specified baseURL.
 
Method Summary
static GLSLShaderLoader getInstance()
           
 GLSLFragmentShader loadFragmentShader(java.lang.String name)
          Retrives the Shader with the given name.
 GLSLFragmentShader loadFragmentShader(java.net.URL url)
          Retrives the Shader with the given name.
 GLSLFragmentShader loadFragmentShader(java.net.URL url, GLSLShaderLoader.InlineVariableMapping... inlineVariables)
          Retrives the Shader with the given name.
 GLSLFragmentShader loadFragmentShaderFromString(java.lang.String source)
          Creates a Shader from the given String.
 GLSLFragmentShader loadFragmentShaderFromString(java.lang.String source, GLSLShaderLoader.InlineVariableMapping... inlineVariables)
          Creates a Shader from the given String.
 GLSLShader loadShader(java.io.InputStream in, Shader.ShaderType type)
          Retrives the Shader from the given InputStream.
 GLSLShader loadShader(java.io.InputStream in, Shader.ShaderType type, GLSLShaderLoader.InlineVariableMapping... inlineVariables)
          
 GLSLShader loadShader(java.io.Reader reader, Shader.ShaderType type)
          Retrives the Shader from the given reader.
 GLSLShader loadShader(java.io.Reader reader, Shader.ShaderType type, GLSLShaderLoader.InlineVariableMapping... inlineVariables)
          
 GLSLShader loadShader(java.lang.String name, Shader.ShaderType type)
          Retrives the Shader with the given name.
 GLSLShader loadShader(java.net.URL url, Shader.ShaderType type)
          Retrives the Shader from the given URL.
 GLSLShader loadShader(java.net.URL url, Shader.ShaderType type, GLSLShaderLoader.InlineVariableMapping... inlineVariables)
          
 GLSLShader loadShaderFromString(java.lang.String source, Shader.ShaderType typ)
          Creates a Shader from the given String.
 GLSLShader loadShaderFromString(java.lang.String source, Shader.ShaderType typ, GLSLShaderLoader.InlineVariableMapping... inlineVariables)
          
 GLSLVertexShader loadVertexShader(java.lang.String name)
          Retrives the Shader with the given name.
 GLSLVertexShader loadVertexShader(java.net.URL url)
          Retrives the Shader with the given name.
 GLSLVertexShader loadVertexShader(java.net.URL url, GLSLShaderLoader.InlineVariableMapping... inlineVariables)
          Retrives the Shader with the given name.
 GLSLVertexShader loadVertexShaderFromString(java.lang.String source)
          Creates a Shader from the given String.
 GLSLVertexShader loadVertexShaderFromString(java.lang.String source, GLSLShaderLoader.InlineVariableMapping... inlineVariables)
          Creates a Shader from the given String.
 
Methods inherited from class org.xith3d.loaders.shaders.base.ShaderLoader
cacheShader, getBasePath, getBaseURL, getFromCache, popBasePath, popBaseURL, setBasePath, setBasePathFromShaderFile, setBaseURL, setBaseURLFromShaderURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GLSLShaderLoader

public GLSLShaderLoader(java.net.URL baseURL)
Constructs a Loader with the specified baseURL.

Parameters:
baseURL - the new baseURL to take resources from

GLSLShaderLoader

public GLSLShaderLoader(java.lang.String basePath)
Constructs a Loader with the specified basePath.

Parameters:
basePath - the new basePath to take resources from

GLSLShaderLoader

public GLSLShaderLoader()
Constructs a Loader with default values for all variables.

Method Detail

loadShader

public GLSLShader loadShader(java.io.Reader reader,
                             Shader.ShaderType type,
                             GLSLShaderLoader.InlineVariableMapping... inlineVariables)


loadShader

public GLSLShader loadShader(java.io.Reader reader,
                             Shader.ShaderType type)
                      throws java.io.IOException
Retrives the Shader from the given reader.

Specified by:
loadShader in class ShaderLoader<GLSLShader>
Parameters:
reader - the reader to load the Shader from
type - the desired Shader type
Returns:
the Shader object
Throws:
java.io.IOException

loadShader

public GLSLShader loadShader(java.io.InputStream in,
                             Shader.ShaderType type,
                             GLSLShaderLoader.InlineVariableMapping... inlineVariables)


loadShader

public GLSLShader loadShader(java.io.InputStream in,
                             Shader.ShaderType type)
                      throws java.io.IOException
Retrives the Shader from the given InputStream.

Specified by:
loadShader in class ShaderLoader<GLSLShader>
Parameters:
in - the InputStream to load the Shader from
type - the desired Shader type
Returns:
the Shader object
Throws:
java.io.IOException

loadShader

public GLSLShader loadShader(java.net.URL url,
                             Shader.ShaderType type,
                             GLSLShaderLoader.InlineVariableMapping... inlineVariables)
                      throws java.io.IOException

Throws:
java.io.IOException

loadShader

public GLSLShader loadShader(java.net.URL url,
                             Shader.ShaderType type)
                      throws java.io.IOException
Retrives the Shader from the given URL.

Specified by:
loadShader in class ShaderLoader<GLSLShader>
Parameters:
url - the URL to load the Shader from
type - the desired Shader type
Returns:
the Shader object
Throws:
java.io.IOException

loadShader

public GLSLShader loadShader(java.lang.String name,
                             Shader.ShaderType type)
                      throws java.io.IOException
Retrives the Shader with the given name. Loading works in the following order:
If the Shader was already loaded and is still in the cache then the existing Shader is returned. So don't modify Shaders returned by this method.
The Shader is loaded from the basePath or basURL.

Specified by:
loadShader in class ShaderLoader<GLSLShader>
Parameters:
name - The name of the Shader
type - The desired Shader type
Returns:
the Shader object
Throws:
java.io.IOException

loadVertexShader

public GLSLVertexShader loadVertexShader(java.net.URL url,
                                         GLSLShaderLoader.InlineVariableMapping... inlineVariables)
                                  throws java.io.IOException
Retrives the Shader with the given name.

Parameters:
url - The url of the Shader.
Returns:
The Shader object
Throws:
java.io.IOException

loadVertexShader

public GLSLVertexShader loadVertexShader(java.net.URL url)
                                  throws java.io.IOException
Retrives the Shader with the given name.

Parameters:
url - The url of the Shader.
Returns:
The Shader object
Throws:
java.io.IOException

loadVertexShader

public GLSLVertexShader loadVertexShader(java.lang.String name)
                                  throws java.io.IOException
Retrives the Shader with the given name.

Parameters:
name - The name of the Shader.
Returns:
The Shader object
Throws:
java.io.IOException

loadFragmentShader

public GLSLFragmentShader loadFragmentShader(java.net.URL url,
                                             GLSLShaderLoader.InlineVariableMapping... inlineVariables)
                                      throws java.io.IOException
Retrives the Shader with the given name.

Parameters:
url - The url of the Shader.
Returns:
The Shader object
Throws:
java.io.IOException

loadFragmentShader

public GLSLFragmentShader loadFragmentShader(java.net.URL url)
                                      throws java.io.IOException
Retrives the Shader with the given name.

Parameters:
url - The url of the Shader.
Returns:
The Shader object
Throws:
java.io.IOException

loadFragmentShader

public GLSLFragmentShader loadFragmentShader(java.lang.String name)
                                      throws java.io.IOException
Retrives the Shader with the given name.

Parameters:
name - The name of the Shader.
Returns:
The Shader object
Throws:
java.io.IOException

loadShaderFromString

public GLSLShader loadShaderFromString(java.lang.String source,
                                       Shader.ShaderType typ,
                                       GLSLShaderLoader.InlineVariableMapping... inlineVariables)


loadShaderFromString

public GLSLShader loadShaderFromString(java.lang.String source,
                                       Shader.ShaderType typ)
Creates a Shader from the given String. The generated Shader is not cached.

Specified by:
loadShaderFromString in class ShaderLoader<GLSLShader>
Parameters:
source - The String that should get parsed
Returns:
Shader A Shader object that is based on the current content of the given String

loadVertexShaderFromString

public GLSLVertexShader loadVertexShaderFromString(java.lang.String source,
                                                   GLSLShaderLoader.InlineVariableMapping... inlineVariables)
Creates a Shader from the given String. The generated Shader is not cached.

Parameters:
source - The String that should get parsed
Returns:
Shader A Shader object that is based on the current content of the given String

loadVertexShaderFromString

public GLSLVertexShader loadVertexShaderFromString(java.lang.String source)
Creates a Shader from the given String. The generated Shader is not cached.

Parameters:
source - The String that should get parsed
Returns:
Shader A Shader object that is based on the current content of the given String

loadFragmentShaderFromString

public GLSLFragmentShader loadFragmentShaderFromString(java.lang.String source,
                                                       GLSLShaderLoader.InlineVariableMapping... inlineVariables)
Creates a Shader from the given String. The generated Shader is not cached.

Parameters:
source - The String that should get parsed
Returns:
Shader A Shader object that is based on the current content of the given String

loadFragmentShaderFromString

public GLSLFragmentShader loadFragmentShaderFromString(java.lang.String source)
Creates a Shader from the given String. The generated Shader is not cached.

Parameters:
source - The String that should get parsed
Returns:
Shader A Shader object that is based on the current content of the given String

getInstance

public static GLSLShaderLoader getInstance()
Returns:
the singleton instance of the TextureLoader