Search in sources :

Example 41 with GL20

use of com.badlogic.gdx.graphics.GL20 in project libgdx by libgdx.

the class ShaderProgram method setUniform3fv.

public void setUniform3fv(String name, float[] values, int offset, int length) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    int location = fetchUniformLocation(name);
    gl.glUniform3fv(location, length / 3, values, offset);
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

Example 42 with GL20

use of com.badlogic.gdx.graphics.GL20 in project libgdx by libgdx.

the class ShaderProgram method fetchAttributeLocation.

private int fetchAttributeLocation(String name) {
    GL20 gl = Gdx.gl20;
    // -2 == not yet cached
    // -1 == cached but not found
    int location;
    if ((location = attributes.get(name, -2)) == -2) {
        location = gl.glGetAttribLocation(program, name);
        attributes.put(name, location);
    }
    return location;
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

Example 43 with GL20

use of com.badlogic.gdx.graphics.GL20 in project libgdx by libgdx.

the class ShaderProgram method end.

/** Disables this shader. Must be called when one is done with the shader. Don't mix it with dispose, that will release the
	 * shader resources. */
public void end() {
    GL20 gl = Gdx.gl20;
    gl.glUseProgram(0);
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

Example 44 with GL20

use of com.badlogic.gdx.graphics.GL20 in project libgdx by libgdx.

the class ShaderProgram method setUniform1fv.

public void setUniform1fv(int location, float[] values, int offset, int length) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    gl.glUniform1fv(location, length, values, offset);
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

Example 45 with GL20

use of com.badlogic.gdx.graphics.GL20 in project libgdx by libgdx.

the class ShaderProgram method linkProgram.

private int linkProgram(int program) {
    GL20 gl = Gdx.gl20;
    if (program == -1)
        return -1;
    gl.glAttachShader(program, vertexShaderHandle);
    gl.glAttachShader(program, fragmentShaderHandle);
    gl.glLinkProgram(program);
    ByteBuffer tmp = ByteBuffer.allocateDirect(4);
    tmp.order(ByteOrder.nativeOrder());
    IntBuffer intbuf = tmp.asIntBuffer();
    gl.glGetProgramiv(program, GL20.GL_LINK_STATUS, intbuf);
    int linked = intbuf.get(0);
    if (linked == 0) {
        // Gdx.gl20.glGetProgramiv(program, GL20.GL_INFO_LOG_LENGTH, intbuf);
        // int infoLogLength = intbuf.get(0);
        // if (infoLogLength > 1) {
        log = Gdx.gl20.glGetProgramInfoLog(program);
        // }
        return -1;
    }
    return program;
}
Also used : GL20(com.badlogic.gdx.graphics.GL20) IntBuffer(java.nio.IntBuffer) ByteBuffer(java.nio.ByteBuffer)

Aggregations

GL20 (com.badlogic.gdx.graphics.GL20)52 IntBuffer (java.nio.IntBuffer)3 VertexAttribute (com.badlogic.gdx.graphics.VertexAttribute)2 Cubemap (com.badlogic.gdx.graphics.Cubemap)1 ByteBuffer (java.nio.ByteBuffer)1