APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.assets.loaders

public Class ShaderProgramLoader

extends AsynchronousAssetLoader<ShaderProgram, ShaderProgramLoader.ShaderProgramParameter>
Class Inheritance
Imports
com.badlogic.gdx.assets.AssetDescriptor, .AssetLoaderParameters, .AssetManager, com.badlogic.gdx.files.FileHandle, com.badlogic.gdx.graphics.glutils.ShaderProgram, com.badlogic.gdx.utils.Array

AssetLoader for ShaderProgram 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 and ShaderProgram#prependFragmentCode).

The above default behavior for finding the files can be overridden by explicitly setting the file names in a ShaderProgramParameter. The parameter can also be used to prepend code to the programs.

Author
cypherdare

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private String
private String

Constructor Summary

AccessConstructor and Description
public
public
ShaderProgramLoader(FileHandleResolver resolver, String vertexFileSuffix, String fragmentFileSuffix)

Method Summary

Modifier and TypeMethod and Description
public Array<AssetDescriptor<T>>
getDependencies(String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AssetLoader.getDependencies.

Returns the assets this asset requires to be loaded first.

public void
loadAsync(AssetManager manager, String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadAsync.

Loads the non-OpenGL part of the asset and injects any dependencies of the asset into the AssetManager.

public ShaderProgram
loadSync(AssetManager manager, String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadSync.

Loads the OpenGL part of the asset.

Inherited from com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader:
unloadAsync

Field Detail

fragmentFileSuffixback to summary
private String fragmentFileSuffix
vertexFileSuffixback to summary
private String vertexFileSuffix

Constructor Detail

ShaderProgramLoaderback to summary
public ShaderProgramLoader(FileHandleResolver resolver)
ShaderProgramLoaderback to summary
public ShaderProgramLoader(FileHandleResolver resolver, String vertexFileSuffix, String fragmentFileSuffix)

Method Detail

getDependenciesback to summary
public Array<AssetDescriptor<T>> getDependencies(String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AssetLoader.getDependencies.

Doc from com.badlogic.gdx.assets.loaders.AssetLoader.getDependencies.

Returns the assets this asset requires to be loaded first. This method may be called on a thread other than the GL thread.

Annotations
@Override
loadAsyncback to summary
public void loadAsync(AssetManager manager, String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadAsync.

Doc from com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadAsync.

Loads the non-OpenGL part of the asset and injects any dependencies of the asset into the AssetManager.

Annotations
@Override
loadSyncback to summary
public ShaderProgram loadSync(AssetManager manager, String fileName, FileHandle file, ShaderProgramLoader.ShaderProgramParameter parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadSync.

Doc from com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadSync.

Loads the OpenGL part of the asset.

Annotations
@Override
com.badlogic.gdx.assets.loaders back to summary

public Class ShaderProgramLoader.ShaderProgramParameter

extends AssetLoaderParameters<ShaderProgram>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public String
fragmentFile

File name to be used for the fragment program instead of the default determined by the file name used to submit this asset to AssetManager.

public boolean
logOnCompileFailure

Whether to log (at the error level) the shader's log if it fails to compile.

public String
prependFragmentCode

Code that is always added to the fragment shader code.

public String
prependVertexCode

Code that is always added to the vertex shader code.

public String
vertexFile

File name to be used for the vertex program instead of the default determined by the file name used to submit this asset to AssetManager.

Inherited from com.badlogic.gdx.assets.AssetLoaderParameters:
loadedCallback

Constructor Summary

AccessConstructor and Description
public

Field Detail

fragmentFileback to summary
public String fragmentFile

File name to be used for the fragment program instead of the default determined by the file name used to submit this asset to AssetManager.

logOnCompileFailureback to summary
public boolean logOnCompileFailure

Whether to log (at the error level) the shader's log if it fails to compile. Default true.

prependFragmentCodeback to summary
public String prependFragmentCode

Code that is always added to the fragment shader code. This is added as-is, and you should include a newline (`\n`) if needed. ShaderProgram#prependFragmentCode is placed before this code.

prependVertexCodeback to summary
public String prependVertexCode

Code that is always added to the vertex shader code. This is added as-is, and you should include a newline (`\n`) if needed. ShaderProgram#prependVertexCode is placed before this code.

vertexFileback to summary
public String vertexFile

File name to be used for the vertex program instead of the default determined by the file name used to submit this asset to AssetManager.

Constructor Detail

ShaderProgramParameterback to summary
public ShaderProgramParameter()