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:voxicity.ChunkNode.java

License:Open Source License

void create_shader_prog() {
    shader_prog = GL20.glCreateProgram();

    int vert_shader = create_vert_shader("shader/block.vert");
    int frag_shader = create_frag_shader("shader/block.frag");

    GL20.glAttachShader(shader_prog, vert_shader);
    GL20.glAttachShader(shader_prog, frag_shader);
    GL20.glLinkProgram(shader_prog);//from   w  w  w.  jav  a 2 s .c  o m

    if (check_shader_error(shader_prog)) {
        GL20.glDeleteProgram(shader_prog);
        shader_prog = 0;
    }

    GL20.glUseProgram(shader_prog);

    int uniform;
    if ((uniform = GL20.glGetUniformLocation(shader_prog, "textures")) != -1) {
        GL20.glUniform1i(uniform, 0);
    }

    System.out.println("Textures at: " + GL20.glGetUniformLocation(shader_prog, "textures"));

    GL20.glUseProgram(0);
}

From source file:wrapper.vbo.Vbo.java

License:Open Source License

public Vbo(int width, int height, Shader shader) {

    transformation = new Vertex3d(0, 0, 0);
    this.shader = shader;
    if (shader == null) {
        System.out.println("Null shader , Vbo will encounter errors!");
    }/* w ww .  j a v  a  2  s.com*/
    Vertex2d temp = new Vertex2d(width, height);
    width = (int) temp.x;
    height = (int) temp.y;
    vertexattrib = GL20.glGetAttribLocation(shader.programID, "vertex");
    System.out.println(GL20.glGetAttribLocation(shader.programID, "vertex"));
    textureattrib = GL20.glGetAttribLocation(shader.programID, "texturecoordinate");
    rotationcentreuniform = GL20.glGetUniformLocation(shader.programID, "rotation_centre");
    rotationuniform = GL20.glGetUniformLocation(shader.programID, "rotation");
    transformuniform = GL20.glGetUniformLocation(shader.programID, "translation");

}

From source file:wrath.client.graphics.ShaderProgram.java

License:Open Source License

/**
 * Gets the integer location of a uniform variable.
 * @param variableName The {@link java.lang.String} name of the Uniform variable.
 * @return Returns the integer location of a uniform variable.
 *///from w ww .  ja  v a 2  s  .  c o  m
public int getUniformVariableLocation(String variableName) {
    if (uniformMap.containsKey(variableName)) {
        int ret = uniformMap.get(variableName);
        if (ret != -1)
            return ret;
    }

    GL20.glUseProgram(programID);
    int ret = GL20.glGetUniformLocation(programID, variableName);
    uniformMap.put(variableName, ret);
    return ret;
}