Example usage for org.lwjgl.opengl GL20 glGetUniformLocation

List of usage examples for org.lwjgl.opengl GL20 glGetUniformLocation

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL20 glGetUniformLocation.

Prototype

@NativeType("GLint")
public static int glGetUniformLocation(@NativeType("GLuint") int program,
        @NativeType("GLchar const *") CharSequence name) 

Source Link

Document

Returns the location of a uniform variable.

Usage

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Specifies the values of a uniform variable array for this program. Must
 * be in use. Returns true if and only if the uniform exists and is active.
 * //from  w  w  w.java 2s. co  m
 * @param name The name of the uniform array to specify.
 * @param array An array of values to set the uniform to.
 * @return Whether or not the uniform exists and is active.
 */
public boolean uniform1fv(String name, float... array) {
    if (DGL.currentProgram() != this)
        throw new IllegalStateException("Program must be in use.");
    int loc = GL20.glGetUniformLocation(id, name);
    if (loc < 0)
        return false;

    long address = MemStack.wrapf(array);
    GL20.nglUniform1fv(loc, array.length, address);
    MemStack.pop();
    return true;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Specifies the value of a uniform variable for this program. Program must
 * be in use. Returns true if and only if the uniform exists and is active.
 * /*from ww w.  ja  v  a2 s  .  c om*/
 * @param name The name of the uniform to specify.
 * @return Whether or not the uniform exists and is active.
 */
public boolean uniform2f(String name, float x, float y) {
    if (DGL.currentProgram() != this)
        throw new IllegalStateException("Program must be in use.");
    int loc = GL20.glGetUniformLocation(id, name);
    if (loc < 0)
        return false;
    GL20.glUniform2f(loc, x, y);
    return true;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Specifies the values of a uniform variable array for this program. Must
 * be in use. Returns true if and only if the uniform exists and is active.
 * //from   w  w  w. j  a  va 2  s.  co m
 * @param name The name of the uniform array to specify.
 * @param array An array of values to set the uniform to.
 * @return Whether or not the uniform exists and is active.
 */
public boolean uniform2fv(String name, float... array) {
    if (DGL.currentProgram() != this)
        throw new IllegalStateException("Program must be in use.");
    int loc = GL20.glGetUniformLocation(id, name);
    if (loc < 0)
        return false;

    long address = MemStack.wrapf(array);
    GL20.nglUniform2fv(loc, array.length / 2, address);
    MemStack.pop();
    return true;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Specifies the values of a uniform variable array for this program. Must
 * be in use. Returns true if and only if the uniform exists and is active.
 * //from  w w  w  .j  a v a  2s . c  o  m
 * @param name The name of the uniform array to specify.
 * @param array An array of values to set the uniform to.
 * @return Whether or not the uniform exists and is active.
 */
public boolean uniformVec2v(String name, Vec2... array) {
    if (DGL.currentProgram() != this)
        throw new IllegalStateException("Program must be in use.");
    int loc = GL20.glGetUniformLocation(id, name);
    if (loc < 0)
        return false;

    long address = MemStack.wrapv(array);
    GL20.nglUniform2fv(loc, array.length, address);
    MemStack.pop();
    return true;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Specifies the value of a uniform variable for this program. Program must
 * be in use. Returns true if and only if the uniform exists and is active.
 * // w  w  w  .  j  av a  2 s .  com
 * @param name The name of the uniform to specify.
 * @return Whether or not the uniform exists and is active.
 */
public boolean uniform3f(String name, float x, float y, float z) {
    if (DGL.currentProgram() != this)
        throw new IllegalStateException("Program must be in use.");
    int loc = GL20.glGetUniformLocation(id, name);
    if (loc < 0)
        return false;
    GL20.glUniform3f(loc, x, y, z);
    return true;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Specifies the values of a uniform variable array for this program. Must
 * be in use. Returns true if and only if the uniform exists and is active.
 * /*from   w w  w .j a  v a 2s.  co m*/
 * @param name The name of the uniform array to specify.
 * @param array An array of values to set the uniform to.
 * @return Whether or not the uniform exists and is active.
 */
public boolean uniform3fv(String name, float... array) {
    if (DGL.currentProgram() != this)
        throw new IllegalStateException("Program must be in use.");
    int loc = GL20.glGetUniformLocation(id, name);
    if (loc < 0)
        return false;

    long address = MemStack.wrapf(array);
    GL20.nglUniform3fv(loc, array.length / 3, address);
    MemStack.pop();
    return true;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Specifies the values of a uniform variable array for this program. Must
 * be in use. Returns true if and only if the uniform exists and is active.
 * /*  ww w  .ja v a  2s.c o  m*/
 * @param name The name of the uniform array to specify.
 * @param array An array of values to set the uniform to.
 * @return Whether or not the uniform exists and is active.
 */
public boolean uniformVec3v(String name, Vec3... array) {
    if (DGL.currentProgram() != this)
        throw new IllegalStateException("Program must be in use.");
    int loc = GL20.glGetUniformLocation(id, name);
    if (loc < 0)
        return false;

    long address = MemStack.wrapv(array);
    GL20.nglUniform3fv(loc, array.length, address);
    MemStack.pop();
    return true;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Specifies the value of a uniform variable for this program. Program must
 * be in use. Returns true if and only if the uniform exists and is active.
 * //  ww  w .  j  av  a2s. c  o  m
 * @param name The name of the uniform to specify.
 * @return Whether or not the uniform exists and is active.
 */
public boolean uniform4f(String name, float x, float y, float z, float w) {
    if (DGL.currentProgram() != this)
        throw new IllegalStateException("Program must be in use.");
    int loc = GL20.glGetUniformLocation(id, name);
    if (loc < 0)
        return false;
    GL20.glUniform4f(loc, x, y, z, w);
    return true;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Specifies the values of a uniform variable array for this program. Must
 * be in use. Returns true if and only if the uniform exists and is active.
 * /*from w ww .ja  v  a 2s  . c  o m*/
 * @param name The name of the uniform array to specify.
 * @param array An array of values to set the uniform to.
 * @return Whether or not the uniform exists and is active.
 */
public boolean uniform4fv(String name, float... array) {
    if (DGL.currentProgram() != this)
        throw new IllegalStateException("Program must be in use.");
    int loc = GL20.glGetUniformLocation(id, name);
    if (loc < 0)
        return false;

    long address = MemStack.wrapf(array);
    GL20.nglUniform4fv(loc, array.length / 4, address);
    MemStack.pop();
    return true;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Specifies the values of a uniform variable array for this program. Must
 * be in use. Returns true if and only if the uniform exists and is active.
 * //w  ww.  ja v  a 2s . c o m
 * @param name The name of the uniform array to specify.
 * @param array An array of values to set the uniform to.
 * @return Whether or not the uniform exists and is active.
 */
public boolean uniformVec4v(String name, Vec4... array) {
    if (DGL.currentProgram() != this)
        throw new IllegalStateException("Program must be in use.");
    int loc = GL20.glGetUniformLocation(id, name);
    if (loc < 0)
        return false;

    long address = MemStack.wrapv(array);
    GL20.nglUniform4fv(loc, array.length, address);
    MemStack.pop();
    return true;
}