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:opengl.test.object.endgame.endgame.java

@Override
protected void initUniformValues() {
    this.bind();/*from  ww w  . jav a  2 s.  co  m*/

    modelID = GL20.glGetUniformLocation(this.getProgramID(), "model");
    Matrix4F m = new Matrix4F();
    GL20.glUniformMatrix4fv(modelID, false, m.toFloatBuffer());

    viewID = GL20.glGetUniformLocation(this.getProgramID(), "view");
    Matrix4F v = new Matrix4F();
    GL20.glUniformMatrix4fv(viewID, false, v.toFloatBuffer());

    projectionID = GL20.glGetUniformLocation(this.getProgramID(), "projection");
    Matrix4F p = new Matrix4F();

    GL20.glUniformMatrix4fv(projectionID, false, p.toFloatBuffer());

    this.unbind();
}

From source file:opengl.test.object.lineCube.java

@Override
protected void initUniformValues() {
    this.bind();/*from w w  w .ja va  2s .c  o  m*/

    modelID = GL20.glGetUniformLocation(this.getProgramID(), "model");
    x_calc = 0;
    y_calc = 0;
    if (x == 0)
        y_calc = 0.3f;
    if (x == 1)
        y_calc = 0;
    if (x == 2)
        y_calc = -0.3f;
    if (y == 0)
        x_calc = -0.3f;
    if (y == 1)
        x_calc = 0f;
    if (y == 2)
        x_calc = 0.3f;

    Matrix4F m = Matrix4F.ratio(0.3f, 0.3f, 0.3f).nhanMaTran(Matrix4F.move(x_calc, y_calc, 0f))
            .nhanMaTran(Model);

    GL20.glUniformMatrix4fv(modelID, false, m.toFloatBuffer());

    viewID = GL20.glGetUniformLocation(this.getProgramID(), "view");
    Matrix4F v = new Matrix4F();
    GL20.glUniformMatrix4fv(viewID, false, v.toFloatBuffer());

    projectionID = GL20.glGetUniformLocation(this.getProgramID(), "projection");
    Matrix4F p = new Matrix4F();
    GL20.glUniformMatrix4fv(projectionID, false, p.toFloatBuffer());

    this.unbind();
}

From source file:opengl.test.object.tree.testobject.leaf.java

private void initUniformValues() {
    this.bind();/*from   ww  w  . j  av a2s .co m*/

    modelID = GL20.glGetUniformLocation(this.getProgramID(), "model");
    Matrix4F m = new Matrix4F();
    GL20.glUniformMatrix4fv(modelID, false, m.toFloatBuffer());

    viewID = GL20.glGetUniformLocation(this.getProgramID(), "view");
    Matrix4F v = new Matrix4F();
    GL20.glUniformMatrix4fv(viewID, false, v.toFloatBuffer());

    projectionID = GL20.glGetUniformLocation(this.getProgramID(), "projection");
    Matrix4F p = new Matrix4F();

    GL20.glUniformMatrix4fv(projectionID, false, p.toFloatBuffer());

    this.unbind();
}

From source file:opengl.test.object.XO.java

@Override
protected void initUniformValues() {
    this.bind();//from   w  w w  . j  a  v  a 2 s .c om
    if (x != -1 && y != -1) {
        modelID = GL20.glGetUniformLocation(this.getProgramID(), "model");
        x_calc = 0;
        y_calc = 0;
        if (x == 0)
            y_calc = 0.3f;
        if (x == 1)
            y_calc = 0;
        if (x == 2)
            y_calc = -0.3f;
        if (y == 0)
            x_calc = -0.3f;
        if (y == 1)
            x_calc = 0f;
        if (y == 2)
            x_calc = 0.3f;

        Matrix4F m = Matrix4F.ratio(0.10f, 0.10f, 0.10f).nhanMaTran(Matrix4F.rotateOX(90))
                .nhanMaTran(Matrix4F.move(x_calc, y_calc, -0.0005f));
        GL20.glUniformMatrix4fv(modelID, false, m.toFloatBuffer());
    } else {
        modelID = GL20.glGetUniformLocation(this.getProgramID(), "model");
        Matrix4F m = new Matrix4F();
        GL20.glUniformMatrix4fv(modelID, false, m.toFloatBuffer());
    }

    viewID = GL20.glGetUniformLocation(this.getProgramID(), "view");
    Matrix4F v = new Matrix4F();
    GL20.glUniformMatrix4fv(viewID, false, v.toFloatBuffer());

    projectionID = GL20.glGetUniformLocation(this.getProgramID(), "projection");
    Matrix4F p = new Matrix4F();

    GL20.glUniformMatrix4fv(projectionID, false, p.toFloatBuffer());

    this.unbind();
}

From source file:org.bonsaimind.badgersvoyage.opengl.RenderObject.java

License:Open Source License

protected void createOpenGL(int programId) {
    modelMatrix = new Matrix4f();
    modelMatrixLocation = GL20.glGetUniformLocation(programId, "modelMatrix");
    modelMatrixBuffer = BufferUtils.createFloatBuffer(16);

    verticesCount = vertices.length / 3;

    verticesBuffer = BufferUtils.createFloatBuffer(vertices.length);
    verticesBuffer.put(vertices);/*from w  w  w . j a  va 2s  .c o  m*/
    verticesBuffer.flip();

    vaoId = GL30.glGenVertexArrays();
    GL30.glBindVertexArray(vaoId);

    vboId = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW);
    GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    GL30.glBindVertexArray(0);
}

From source file:org.bonsaimind.badgersvoyage.tools.planetstudio.Camera.java

License:Open Source License

public Camera(float aspectRatio, Vector3f camera, float farPlane, float fieldOfView, float nearPlane,
        int programId) {
    this.aspectRatio = aspectRatio;
    this.camera = camera;
    this.farPlane = farPlane;
    this.fieldOfView = fieldOfView;
    this.nearPlane = nearPlane;
    this.programId = programId;

    this.projectionMatrix = new Matrix4f();
    this.projectionMatrixLocation = GL20.glGetUniformLocation(this.programId, "projectionMatrix");
    ErrorChecker.exitOnOpenGlError("ProjectionMatrixLocation.");

    this.viewMatrix = new Matrix4f();
    this.viewMatrixLocation = GL20.glGetUniformLocation(this.programId, "viewMatrix");
    ErrorChecker.exitOnOpenGlError("ViewMatrixLocation.");

    this.yScale = 1 / (float) Math.tan(Math.toRadians(this.fieldOfView / 2f));
    this.xScale = this.yScale / aspectRatio;
    this.frustumLength = this.farPlane - this.nearPlane;

    this.projectionMatrix.m00 = this.xScale;
    this.projectionMatrix.m11 = this.yScale;
    this.projectionMatrix.m22 = -((this.farPlane - this.nearPlane) / this.frustumLength);
    this.projectionMatrix.m23 = -1;
    this.projectionMatrix.m32 = -((2 * nearPlane * farPlane) / frustumLength);

    this.buffer = BufferUtils.createFloatBuffer(16);
}

From source file:org.jogamp.glg2d.impl.shader.AnyModePipeline.java

License:Apache License

@Override
protected void setupUniformsAndAttributes() {
    super.setupUniformsAndAttributes();

    transformLocation = GL20.glGetUniformLocation(programId, "u_transform");
    colorLocation = GL20.glGetUniformLocation(programId, "u_color");

    vertCoordLocation = GL20.glGetAttribLocation(programId, "a_vertCoord");
}

From source file:org.jogamp.glg2d.impl.shader.GeometryShaderStrokePipeline.java

License:Apache License

@Override
protected void setupUniformsAndAttributes() {
    super.setupUniformsAndAttributes();

    transformLocation = GL20.glGetUniformLocation(programId, "u_transform");
    colorLocation = GL20.glGetUniformLocation(programId, "u_color");
    lineWidthLocation = GL20.glGetUniformLocation(programId, "u_lineWidth");
    miterLimitLocation = GL20.glGetUniformLocation(programId, "u_miterLimit");
    joinTypeLocation = GL20.glGetUniformLocation(programId, "u_joinType");
    drawEndLocation = GL20.glGetUniformLocation(programId, "u_drawEnd");
    capTypeLocation = GL20.glGetUniformLocation(programId, "u_capType");

    vertCoordLocation = GL20.glGetAttribLocation(programId, "a_vertCoord");
    vertBeforeLocation = GL20.glGetAttribLocation(programId, "a_vertBefore");
    vertAfterLocation = GL20.glGetAttribLocation(programId, "a_vertAfter");
}

From source file:org.jogamp.glg2d.impl.shader.GL2ES2ImagePipeline.java

License:Apache License

@Override
protected void setupUniformsAndAttributes() {
    super.setupUniformsAndAttributes();

    transformLocation = GL20.glGetUniformLocation(programId, "u_transform");
    colorLocation = GL20.glGetUniformLocation(programId, "u_color");
    textureLocation = GL20.glGetUniformLocation(programId, "u_tex");

    vertCoordLocation = GL20.glGetAttribLocation(programId, "a_vertCoord");
    texCoordLocation = GL20.glGetAttribLocation(programId, "a_texCoord");
}

From source file:org.jogamp.glg2d.impl.shader.text.TextPipeline.java

License:Apache License

@Override
protected void setupUniformsAndAttributes() {
    super.setupUniformsAndAttributes();

    xOffsetLocation = GL20.glGetUniformLocation(programId, "u_xoffset");
    yOffsetLocation = GL20.glGetUniformLocation(programId, "u_yoffset");
}