Class ShaderParser

java.lang.Object
edu.cornell.gdiac.assets.ShaderParser
All Implemented Interfaces:
AssetParser<Shader>

public class ShaderParser extends Object implements AssetParser<Shader>
This class parses a JSON entry into a Shader.

The parser converts JSON entries into ShaderLoader.ShaderParameters values of the same name. In particular, the JSON entry allows the developer to group the vertex shader with its fragment shader. It also allows the developer to specify both GL20 and GL30 shaders for maximum flexibility.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if o is another ShaderParser
    Returns the asset type generated by this parser
    boolean
    Returns true if there are still assets left to generate
    void
    processNext(com.badlogic.gdx.assets.AssetManager manager, com.badlogic.gdx.utils.ObjectMap<String,String> keymap)
    Processes the next available texture, loading it into the asset manager
    void
    reset(com.badlogic.gdx.utils.JsonValue directory)
    Resets the parser iterator for the given directory.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ShaderParser

      public ShaderParser()
  • Method Details

    • getType

      public Class<Shader> getType()
      Returns the asset type generated by this parser
      Specified by:
      getType in interface AssetParser<Shader>
      Returns:
      the asset type generated by this parser
    • reset

      public void reset(com.badlogic.gdx.utils.JsonValue directory)
      Resets the parser iterator for the given directory.

      The value directory is assumed to be the root of a larger JSON structure. The individual assets are defined by subtrees in this structure.

      Specified by:
      reset in interface AssetParser<Shader>
      Parameters:
      directory - The JSON representation of the asset directory
    • hasNext

      public boolean hasNext()
      Returns true if there are still assets left to generate
      Specified by:
      hasNext in interface AssetParser<Shader>
      Returns:
      true if there are still assets left to generate
    • processNext

      public void processNext(com.badlogic.gdx.assets.AssetManager manager, com.badlogic.gdx.utils.ObjectMap<String,String> keymap)
      Processes the next available texture, loading it into the asset manager

      The parser converts JSON entries into ShaderLoader.ShaderParameters values of the same name. The file will be the contents of the file entry. The key will be the name of the font object. This method fails silently if there are no available assets to process.

      Specified by:
      processNext in interface AssetParser<Shader>
      Parameters:
      manager - The asset manager to load an asset
      keymap - The mapping of JSON keys to asset file names
    • equals

      public boolean equals(Object o)
      Returns true if o is another ShaderParser
      Overrides:
      equals in class Object
      Returns:
      true if o is another ShaderParser