Package com.badlogic.gdx.assets.loaders
Class ShaderProgramLoader
- java.lang.Object
-
- com.badlogic.gdx.assets.loaders.AssetLoader<T,P>
-
- com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<ShaderProgram,ShaderProgramLoader.ShaderProgramParameter>
-
- com.badlogic.gdx.assets.loaders.ShaderProgramLoader
-
public class ShaderProgramLoader extends AsynchronousAssetLoader<ShaderProgram,ShaderProgramLoader.ShaderProgramParameter>
AssetLoader
forShaderProgram
instances loaded from text files. If the file suffix is ".vert", it is assumed to be a vertex shader, and a fragment shader is found using the same file name with a ".frag" suffix. And vice versa if the file suffix is ".frag". These default suffixes can be changed in the ShaderProgramLoader constructor.For all other file suffixes, the same file is used for both (and therefore should internally distinguish between the programs using preprocessor directives and
ShaderProgram.prependVertexCode
andShaderProgram.prependFragmentCode
).The above default behavior for finding the files can be overridden by explicitly setting the file names in a
ShaderProgramLoader.ShaderProgramParameter
. The parameter can also be used to prepend code to the programs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShaderProgramLoader.ShaderProgramParameter
-
Constructor Summary
Constructors Constructor Description ShaderProgramLoader(FileHandleResolver resolver)
ShaderProgramLoader(FileHandleResolver resolver, java.lang.String vertexFileSuffix, java.lang.String fragmentFileSuffix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Array<AssetDescriptor>
getDependencies(java.lang.String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)
Returns the assets this asset requires to be loaded first.void
loadAsync(AssetManager manager, java.lang.String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)
Loads the non-OpenGL part of the asset and injects any dependencies of the asset into the AssetManager.ShaderProgram
loadSync(AssetManager manager, java.lang.String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)
Loads the OpenGL part of the asset.-
Methods inherited from class com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader
unloadAsync
-
Methods inherited from class com.badlogic.gdx.assets.loaders.AssetLoader
resolve
-
-
-
-
Constructor Detail
-
ShaderProgramLoader
public ShaderProgramLoader(FileHandleResolver resolver)
-
ShaderProgramLoader
public ShaderProgramLoader(FileHandleResolver resolver, java.lang.String vertexFileSuffix, java.lang.String fragmentFileSuffix)
-
-
Method Detail
-
getDependencies
public Array<AssetDescriptor> getDependencies(java.lang.String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)
Description copied from class:AssetLoader
Returns the assets this asset requires to be loaded first. This method may be called on a thread other than the GL thread.- Specified by:
getDependencies
in classAssetLoader<ShaderProgram,ShaderProgramLoader.ShaderProgramParameter>
- Parameters:
fileName
- name of the asset to loadfile
- the resolved file to loadparameter
- parameters for loading the asset- Returns:
- other assets that the asset depends on and need to be loaded first or null if there are no dependencies.
-
loadAsync
public void loadAsync(AssetManager manager, java.lang.String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)
Description copied from class:AsynchronousAssetLoader
Loads the non-OpenGL part of the asset and injects any dependencies of the asset into the AssetManager.- Specified by:
loadAsync
in classAsynchronousAssetLoader<ShaderProgram,ShaderProgramLoader.ShaderProgramParameter>
fileName
- the name of the asset to loadfile
- the resolved file to loadparameter
- the parameters to use for loading the asset
-
loadSync
public ShaderProgram loadSync(AssetManager manager, java.lang.String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)
Description copied from class:AsynchronousAssetLoader
Loads the OpenGL part of the asset.- Specified by:
loadSync
in classAsynchronousAssetLoader<ShaderProgram,ShaderProgramLoader.ShaderProgramParameter>
file
- the resolved file to load
-
-