Search in sources :

Example 46 with GL20

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

the class ShaderProgram method setUniformMatrix4fv.

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

Example 47 with GL20

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

the class ShaderProgram method setUniform2fv.

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

Example 48 with GL20

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

the class ShaderProgram method setVertexAttribute.

public void setVertexAttribute(int location, int size, int type, boolean normalize, int stride, Buffer buffer) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    gl.glVertexAttribPointer(location, size, type, normalize, stride, buffer);
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

Example 49 with GL20

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

the class ShaderProgram method setUniformi.

public void setUniformi(int location, int value) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    gl.glUniform1i(location, value);
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

Example 50 with GL20

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

the class VertexBufferObject method bind.

@Override
public void bind(ShaderProgram shader, int[] locations) {
    final GL20 gl = Gdx.gl20;
    gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, bufferHandle);
    if (isDirty) {
        byteBuffer.limit(buffer.limit() * 4);
        gl.glBufferData(GL20.GL_ARRAY_BUFFER, byteBuffer.limit(), byteBuffer, usage);
        isDirty = false;
    }
    final int numAttributes = attributes.size();
    if (locations == null) {
        for (int i = 0; i < numAttributes; i++) {
            final VertexAttribute attribute = attributes.get(i);
            final int location = shader.getAttributeLocation(attribute.alias);
            if (location < 0)
                continue;
            shader.enableVertexAttribute(location);
            shader.setVertexAttribute(location, attribute.numComponents, attribute.type, attribute.normalized, attributes.vertexSize, attribute.offset);
        }
    } else {
        for (int i = 0; i < numAttributes; i++) {
            final VertexAttribute attribute = attributes.get(i);
            final int location = locations[i];
            if (location < 0)
                continue;
            shader.enableVertexAttribute(location);
            shader.setVertexAttribute(location, attribute.numComponents, attribute.type, attribute.normalized, attributes.vertexSize, attribute.offset);
        }
    }
    isBound = true;
}
Also used : GL20(com.badlogic.gdx.graphics.GL20) VertexAttribute(com.badlogic.gdx.graphics.VertexAttribute)

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