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:playn.java.JavaGL20.java

License:Apache License

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

From source file:processing.lwjgl.PGL.java

License:Open Source License

public int getUniformLocation(int prog, String name) {
    return GL20.glGetUniformLocation(prog, name);
}

From source file:renderEngine.ShaderProgram.java

/**
 * Get the location for a uniform variable.
 *
 * @param uniformName The name of the uniform variable for which the
 * location will be returned./*w  ww. j a  v a2 s  .c om*/
 * @return The location of a uniform variable specified by the name.
 */
protected int getUniformLocation(String uniformName) {
    return GL20.glGetUniformLocation(programID, uniformName);
}

From source file:se.angergard.engine.graphics.ShaderProgram.java

License:Apache License

/** Add the uniform to the uniforms hashmap
 * @param Uniform name/* w w w. ja v a  2s  .  c  o  m*/
 * @return This ShaderProgram */
public ShaderProgram addUniform(String uniform) {
    int location = GL20.glGetUniformLocation(program, uniform);
    if (location == -1) {
        System.err.println("Can't find uniform location :" + uniform);
    } else {
        uniforms.put(uniform, location);
    }
    return this;
}

From source file:sketchwars.map.MapWater.java

private void setShaderVariables(float angleOffset) {
    int waveAngleLoc = GL20.glGetUniformLocation(shader.getProgram(), "wave_angle");
    GL20.glUniform1f(waveAngleLoc, waveAngle + angleOffset);

    int waveLengthLoc = GL20.glGetUniformLocation(shader.getProgram(), "wave_length");
    GL20.glUniform1f(waveLengthLoc, WAVE_LENGTH);

    int ampliLoc = GL20.glGetUniformLocation(shader.getProgram(), "amplitude");
    GL20.glUniform1f(ampliLoc, WAVE_AMPLITUDE);

    int yOffsetLoc = GL20.glGetUniformLocation(shader.getProgram(), "y_offset");
    GL20.glUniform1f(yOffsetLoc, Y_OFFSET);
}

From source file:thebounzer.org.lwgldemo.Chapter5.java

License:Open Source License

@Override
public void loopCycle() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    float f = (float) (time * Math.PI * 0.1f);
    Matrix4f modelViewM = new Matrix4f();
    Matrix4f mat = new Matrix4f();
    Matrix4f transOne = new Matrix4f();
    Matrix4f transTwo = new Matrix4f();
    Matrix4f rotaOne = new Matrix4f();
    Matrix4f rotaTwo = new Matrix4f();
    Matrix4f.translate(new Vector3f(0.0f, 0.0f, -0.4f), mat, transOne);
    Matrix4f.translate(new Vector3f((float) Math.sin(2.1f * f) * 0.5f, (float) Math.cos(1.7f * f) * 0.5f,
            (float) Math.sin(1.3f * f) * (float) Math.cos(1.5 * f) * 2.0f), mat, transTwo);
    Matrix4f.rotate(time * 45.0f, new Vector3f(0.0f, 1.0f, 0.0f), mat, rotaOne);
    Matrix4f.rotate(time * 81.0f, new Vector3f(1.0f, 0.0f, 0.0f), mat, rotaTwo);
    Matrix4f.mul(modelViewM, transOne, modelViewM);
    Matrix4f.mul(modelViewM, transTwo, modelViewM);
    Matrix4f.mul(modelViewM, rotaOne, modelViewM);
    Matrix4f.mul(modelViewM, rotaTwo, modelViewM);

    GL20.glUseProgram(program.getId());/*w w w .j  a  v  a  2  s. co  m*/
    FloatBuffer matrixBuf = BufferUtils.createFloatBuffer(16);
    modelViewM.store(matrixBuf);
    matrixBuf.flip();
    int uniLoc = GL20.glGetUniformLocation(program.getId(), "mv_matrix");
    GL20.glUniformMatrix4(uniLoc, false, matrixBuf);
    int uniProjMatLoc = GL20.glGetUniformLocation(program.getId(), "proj_matrix");
    GL20.glUniformMatrix4(uniProjMatLoc, false, matrixBuf);
    vaoId = GL30.glGenVertexArrays();
    GL30.glBindVertexArray(vaoId);
    GL11.glDrawArrays(GL11.GL_POINTS, 0, 36);
    GL20.glUseProgram(0);
    time += 0.001f;
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static int glGetUniformLocation(int a, ByteBuffer b) {
    return GL20.glGetUniformLocation(a, b);
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static int glGetUniformLocation(int a, CharSequence b) {
    return GL20.glGetUniformLocation(a, b);
}

From source file:uk.co.ifs_studios.engine.shader.ShaderProgram.java

License:Open Source License

/**
 * Create uniform.//from  ww  w .  jav  a  2 s . co m
 * 
 * @param name
 *            - Name of variable uniform.
 * @return - Uniform ID.
 */
public int addUniform(String name) {
    return GL20.glGetUniformLocation(this.id, name);
}

From source file:vertigo.graphics.lwjgl.ShaderUtils.java

License:Open Source License

public static ShaderProg updateShader(ShaderProg prog) {
    int progID = -1;
    System.out.println("updateShader:\n" + prog.getVertexSource() + "\n------\n" + prog.getFragmentSource());
    if (prog.isDirty()) {
        try {//from   w  w  w  .  ja  v a  2  s  .  c  om
            progID = attachVFShaders(prog);
        } catch (Exception ex) {
            System.out.println("Exception attachShaders");
            Logger.getLogger(LWJGL_Renderer.class.getName()).log(Level.SEVERE, null, ex);
            // Renderer or LWJGL_Renderer ?

        }
        prog.setHandle(progID);

        GL20.glUseProgram(progID);

        for (Uniform uniform : prog.getAllUniforms()) {
            System.out.println("uniform " + uniform.getName());
            prog.setUniformLocation(uniform.getName(), GL20.glGetUniformLocation(progID, uniform.getName()));
        }
        for (Attribute attribute : prog.getAllAttributes()) {
            System.out.println("attr " + attribute.getName());
            prog.setAttributeLocation(attribute.getName(),
                    GL20.glGetAttribLocation(progID, attribute.getName()));
        }
        GL20.glUseProgram(0);

    }
    return prog;
}