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:jpcsp.graphics.RE.RenderingEngineLwjgl.java

License:Open Source License

@Override
public int getUniformLocation(int program, String name) {
    return GL20.glGetUniformLocation(program, name);
}

From source file:kubex.gui.DepthPeelingLiquidRenderer.java

License:Creative Commons License

/**
 * Performs the depth peeling rendering/* w  w w  .  j  a v  a 2 s .  c  o  m*/
 */
@Override
public void renderLayers(World w, int xres, int yres) {
    this.DPS.enable();
    int upperLimitDepth = GL20.glGetUniformLocation(this.DPS.getID(), "upperLimitDepth");
    int lowerLimitDepth = GL20.glGetUniformLocation(this.DPS.getID(), "lowerLimitDepth");
    int upperLimitIndex = GL20.glGetUniformLocation(this.DPS.getID(), "upperLimitIndex");

    GL20.glUniform1i(upperLimitDepth, KubexGame.LIQUIDLAYERS_TEXTURE_LOCATION);
    GL20.glUniform1i(lowerLimitDepth, KubexGame.BASEFBO_DEPTH_TEXTURE_LOCATION);

    GL20.glUniform1i(GL20.glGetUniformLocation(this.DPS.getID(), "xres"), xres);
    GL20.glUniform1i(GL20.glGetUniformLocation(this.DPS.getID(), "yres"), yres);

    w.overrideCurrentShader(this.DPS); //Makes world use the depth peeling shader when drawing chunks

    //Writes each liquid layer to a texture
    for (int i = 0; i < this.getNumLayers(); i++) {
        GL20.glUniform1i(upperLimitIndex, i - 1);
        glBindFramebuffer(GL_FRAMEBUFFER, this.layersFbos[i]);
        glClear(GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glViewport(0, 0, xres, yres);

        w.drawLiquids();
    }

    this.DPS.disable();
}

From source file:lessur.util.shader.ShaderManager.java

License:GNU General Public License

/**
 * /* w  w  w. ja  v  a 2  s  .c om*/
 * @param program ID/index of the program
 * @param name Name of the variable
 * @param value Value to set the variable
 */
public void setUniform1(int program, String name, float value) {
    if (has_opengl2) {
        int loc = GL20.glGetUniformLocation(program, name);
        checkVariableLocation(loc, name);
        GL20.glUniform1f(loc, value);
    } else if (has_arb) {
        int loc = ARBShaderObjects.glGetUniformLocationARB(program, name);
        checkVariableLocation(loc, name);
        ARBShaderObjects.glUniform1fARB(loc, value);
    }
}

From source file:lessur.util.shader.ShaderManager.java

License:GNU General Public License

/**
 * //from  w  ww . j  a  va 2s  . c o  m
 * @param program ID/index of the program
 * @param name Name of the variable
 * @param value Value to set the variable
 */
public void setUniform1i(int program, String name, int value) {
    if (has_opengl2) {
        int loc = GL20.glGetUniformLocation(program, name);
        checkVariableLocation(loc, name);
        GL20.glUniform1i(loc, value);
    } else if (has_arb) {
        int loc = ARBShaderObjects.glGetUniformLocationARB(program, name);
        checkVariableLocation(loc, name);
        ARBShaderObjects.glUniform1iARB(loc, value);
    }
}

From source file:lessur.util.shader.ShaderManager.java

License:GNU General Public License

/**
 * /*from  w ww .j a v  a 2 s . c  o m*/
 * @param program ID/index of the program
 * @param name Name of the variable
 * @param value Value to set the variable
 */
public void setUniform2(int program, String name, FloatBuffer value) {
    if (has_opengl2) {
        int loc = GL20.glGetUniformLocation(program, name);
        checkVariableLocation(loc, name);
        GL20.glUniform2(loc, value);
    } else if (has_arb) {
        int loc = ARBShaderObjects.glGetUniformLocationARB(program, name);
        checkVariableLocation(loc, name);
        ARBShaderObjects.glUniform2ARB(loc, value);
    }
}

From source file:lessur.util.shader.ShaderManager.java

License:GNU General Public License

/**
 * /*from  ww w. j  a va 2  s . co  m*/
 * @param program ID/index of the program
 * @param name Name of the variable
 * @param value Value to set the variable
 */
public void setUniform2i(int program, String name, IntBuffer value) {
    if (has_opengl2) {
        int loc = GL20.glGetUniformLocation(program, name);
        checkVariableLocation(loc, name);
        GL20.glUniform2(loc, value);
    } else if (has_arb) {
        int loc = ARBShaderObjects.glGetUniformLocationARB(program, name);
        checkVariableLocation(loc, name);
        ARBShaderObjects.glUniform2ARB(loc, value);
    }
}

From source file:lessur.util.shader.ShaderManager.java

License:GNU General Public License

/**
 * //w  w  w  .j ava2s .  c  o m
 * @param program ID/index of the program
 * @param name Name of the variable
 * @param value Value to set the variable
 */
public void setUniform3(int program, String name, FloatBuffer value) {
    if (has_opengl2) {
        int loc = GL20.glGetUniformLocation(program, name);
        checkVariableLocation(loc, name);
        GL20.glUniform3(loc, value);
    } else if (has_arb) {
        int loc = ARBShaderObjects.glGetUniformLocationARB(program, name);
        checkVariableLocation(loc, name);
        ARBShaderObjects.glUniform3ARB(loc, value);
    }
}

From source file:lessur.util.shader.ShaderManager.java

License:GNU General Public License

/**
 * //  w  w w .j  av a2s  . co m
 * @param program ID/index of the program
 * @param name Name of the variable
 * @param value Value to set the variable
 */
public void setUniform3i(int program, String name, IntBuffer value) {
    if (has_opengl2) {
        int loc = GL20.glGetUniformLocation(program, name);
        checkVariableLocation(loc, name);
        GL20.glUniform3(loc, value);
    } else if (has_arb) {
        int loc = ARBShaderObjects.glGetUniformLocationARB(program, name);
        checkVariableLocation(loc, name);
        ARBShaderObjects.glUniform3ARB(loc, value);
    }
}

From source file:lessur.util.shader.ShaderManager.java

License:GNU General Public License

/**
 * //from  w  w  w.  ja va2s.co m
 * @param program ID/index of the program
 * @param name Name of the variable
 * @param value Value to set the variable
 */
public void setUniform4(int program, String name, FloatBuffer value) {
    if (has_opengl2) {
        int loc = GL20.glGetUniformLocation(program, name);
        checkVariableLocation(loc, name);
        GL20.glUniform4(loc, value);
    } else if (has_arb) {
        int loc = ARBShaderObjects.glGetUniformLocationARB(program, name);
        checkVariableLocation(loc, name);
        ARBShaderObjects.glUniform4ARB(loc, value);
    }
}

From source file:lessur.util.shader.ShaderManager.java

License:GNU General Public License

/**
 * /*from   w  w  w .j a  v a  2  s.co  m*/
 * @param program ID/index of the program
 * @param name Name of the variable
 * @param value Value to set the variable
 */
public void setUniform4i(int program, String name, IntBuffer value) {
    if (has_opengl2) {
        int loc = GL20.glGetUniformLocation(program, name);
        checkVariableLocation(loc, name);
        GL20.glUniform4(loc, value);
    } else if (has_arb) {
        int loc = ARBShaderObjects.glGetUniformLocationARB(program, name);
        checkVariableLocation(loc, name);
        ARBShaderObjects.glUniform4ARB(loc, value);
    }
}