Package arc.assets.loaders
Class ShaderProgramLoader
java.lang.Object
arc.assets.loaders.AssetLoader<T,P>
arc.assets.loaders.AsynchronousAssetLoader<Shader,ShaderProgramLoader.ShaderProgramParameter>
arc.assets.loaders.ShaderProgramLoader
public class ShaderProgramLoader
extends AsynchronousAssetLoader<Shader,ShaderProgramLoader.ShaderProgramParameter>
AssetLoader
for Shader
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 Shader.prependVertexCode
and Shader.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
-
Constructor Summary
ConstructorDescriptionShaderProgramLoader
(FileHandleResolver resolver) ShaderProgramLoader
(FileHandleResolver resolver, String vertexFileSuffix, String fragmentFileSuffix) -
Method Summary
Modifier and TypeMethodDescriptiongetDependencies
(String fileName, Fi file, ShaderProgramLoader.ShaderProgramParameter parameter) Returns the assets this asset requires to be loaded first.void
loadAsync
(AssetManager manager, String fileName, Fi file, ShaderProgramLoader.ShaderProgramParameter parameter) Loads the non-OpenGL part of the asset and injects any dependencies of the asset into the AssetManager.loadSync
(AssetManager manager, String fileName, Fi file, ShaderProgramLoader.ShaderProgramParameter parameter) Loads the OpenGL part of the asset.Methods inherited from class arc.assets.loaders.AssetLoader
resolve
-
Constructor Details
-
ShaderProgramLoader
-
ShaderProgramLoader
public ShaderProgramLoader(FileHandleResolver resolver, String vertexFileSuffix, String fragmentFileSuffix)
-
-
Method Details
-
getDependencies
public Seq<AssetDescriptor> getDependencies(String fileName, Fi 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<Shader,
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, String fileName, Fi 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<Shader,
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 Shader loadSync(AssetManager manager, String fileName, Fi file, ShaderProgramLoader.ShaderProgramParameter parameter) Description copied from class:AsynchronousAssetLoader
Loads the OpenGL part of the asset.- Specified by:
loadSync
in classAsynchronousAssetLoader<Shader,
ShaderProgramLoader.ShaderProgramParameter> file
- the resolved file to load
-