Example usage for com.badlogic.gdx.graphics GL20 glGetUniformLocation

List of usage examples for com.badlogic.gdx.graphics GL20 glGetUniformLocation

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics GL20 glGetUniformLocation.

Prototype

public int glGetUniformLocation(int program, String name);

Source Link

Usage

From source file:net.mgsx.game.examples.gpu.utils.ShaderProgramEx.java

License:Apache License

public int fetchUniformLocation(String name, boolean pedantic) {
    GL20 gl = Gdx.gl20;
    // -2 == not yet cached
    // -1 == cached but not found
    int location;
    if ((location = uniforms.get(name, -2)) == -2) {
        location = gl.glGetUniformLocation(program, name);
        if (location == -1 && pedantic)
            throw new IllegalArgumentException("no uniform with name '" + name + "' in shader");
        uniforms.put(name, location);//from   w  ww  .  ja  v a  2s  . c om
    }
    return location;
}