Search in sources :

Example 1 with GLSLMaterial

use of org.terasology.rendering.opengl.GLSLMaterial in project Terasology by MovingBlocks.

the class ShaderManagerLwjgl method addShaderProgram.

// TODO: discuss having a `public removeShaderProgram`, to dispose shader programs no longer in use by any node
public GLSLMaterial addShaderProgram(String title) {
    String uri = "engine:" + title;
    Optional<? extends Shader> shader = Assets.getShader(uri);
    checkState(shader.isPresent(), "Failed to resolve %s", uri);
    shader.get().recompile();
    GLSLMaterial material = (GLSLMaterial) Assets.generateAsset(new ResourceUrn("engine:prog." + title), new MaterialData(shader.get()), Material.class);
    progamaticShaders.add(material);
    return material;
}
Also used : Material(org.terasology.rendering.assets.material.Material) GLSLMaterial(org.terasology.rendering.opengl.GLSLMaterial) MaterialData(org.terasology.rendering.assets.material.MaterialData) ResourceUrn(org.terasology.assets.ResourceUrn) GLSLMaterial(org.terasology.rendering.opengl.GLSLMaterial)

Aggregations

ResourceUrn (org.terasology.assets.ResourceUrn)1 Material (org.terasology.rendering.assets.material.Material)1 MaterialData (org.terasology.rendering.assets.material.MaterialData)1 GLSLMaterial (org.terasology.rendering.opengl.GLSLMaterial)1