Example usage for org.lwjgl.opengl GL20 glUniform1i

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

Introduction

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

Prototype

public static void glUniform1i(@NativeType("GLint") int location, @NativeType("GLint") int v0) 

Source Link

Document

Specifies the value of an int uniform variable for the current program object.

Usage

From source file:org.terasology.rendering.physics.BulletPhysicsRenderer.java

License:Apache License

public void render() {
    _discreteDynamicsWorld.stepSimulation(Terasology.getInstance().getDelta() / 1000f);

    TextureManager.getInstance().bindTexture("terrain");
    ShaderManager.getInstance().enableShader("block");

    FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(3);
    colorBuffer.put(1).put(1).put(1);//from  w  ww  .  j a v  a2 s  .c om
    colorBuffer.flip();

    int textured = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("block"), "textured");
    GL20.glUniform1i(textured, 1);
    int colorOffset = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("block"), "colorOffset");
    GL20.glUniform3(colorOffset, colorBuffer);
    int lightRef = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("block"), "light");

    Player player = Terasology.getInstance().getActiveWorldRenderer().getPlayer();
    FloatBuffer mBuffer = BufferUtils.createFloatBuffer(16);
    float[] mFloat = new float[16];

    GL11.glPushMatrix();
    GL11.glTranslated(-player.getPosition().x, -player.getPosition().y, -player.getPosition().z);

    for (BlockRigidBody b : _blocks) {
        Transform t = new Transform();
        b.getMotionState().getWorldTransform(t);

        t.getOpenGLMatrix(mFloat);
        mBuffer.put(mFloat);
        mBuffer.flip();

        GL11.glPushMatrix();
        GL11.glMultMatrix(mBuffer);
        GL11.glScalef(0.5f, 0.5f, 0.5f);

        float lightValue = Terasology.getInstance().getActiveWorldRenderer()
                .getRenderingLightValueAt(new Vector3d(t.origin));
        GL20.glUniform1f(lightRef, lightValue);

        BlockManager.getInstance().getBlock(b.getType()).render();

        GL11.glPopMatrix();
    }

    GL11.glPopMatrix();

    ShaderManager.getInstance().enableShader(null);
}

From source file:org.terasology.rendering.shader.ShaderProgram.java

License:Apache License

public void setInt(String desc, int i) {
    enable();
    int id = GL20.glGetUniformLocation(shaderProgram, desc);
    GL20.glUniform1i(id, i);
}

From source file:ovh.tgrhavoc.gameengine.core.Shader.java

License:Open Source License

public void setUniformi(String name, int value) {
    GL20.glUniform1i(uniforms.get(name), value);
}

From source file:playn.java.JavaGL20.java

License:Apache License

@Override
public void glUniform1i(int location, int x) {
    GL20.glUniform1i(location, x);
}

From source file:processing.lwjgl.PGL.java

License:Open Source License

public void uniform1i(int loc, int value) {
    GL20.glUniform1i(loc, value);
}

From source file:processing.lwjgl.PLWJGL.java

License:Open Source License

public void uniform1i(int location, int value) {
    GL20.glUniform1i(location, value);
}

From source file:processing.opengl.PLWJGL.java

License:Open Source License

@Override
public void uniform1i(int location, int value) {
    GL20.glUniform1i(location, value);
}

From source file:renderEngine.ShaderProgram.java

/**
 * Loads an integer value to the uniform variable in the specified location.
 *
 * @param location The location of the uniform variable to which the integer
 * needs to be loaded./*from w w w.  j a va 2 s .c  o m*/
 * @param value The value that needs to be loaded into the uniform variable.
 */
protected void loadInt(int location, int value) {
    GL20.glUniform1i(location, value);
}

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

License:Apache License

/** Sets the uniform with the given name with the given Integer. You need the {@link #addUniform(String) addUniform} before
 * being able to set the uniform./*from  w ww.j a  va  2s  .  co  m*/
 *
 * @param uniform The uniform name
 * @param i Integer
 * @return This ShaderProgram */
public ShaderProgram setUniform1i(String uniform, int i) {
    GL20.glUniform1i(uniforms.get(uniform), i);
    return this;
}

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

License:Open Source License

public static void glUniform1i(int a, int b) {
    GL20.glUniform1i(a, b);
}