Search in sources :

Example 26 with GL20

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

the class ShaderProgram method setVertexAttribute.

/** Sets the vertex attribute with the given name. The {@link ShaderProgram} must be bound for this to work.
	 * 
	 * @param name the attribute name
	 * @param size the number of components, must be >= 1 and <= 4
	 * @param type the type, must be one of GL20.GL_BYTE, GL20.GL_UNSIGNED_BYTE, GL20.GL_SHORT,
	 *           GL20.GL_UNSIGNED_SHORT,GL20.GL_FIXED, or GL20.GL_FLOAT. GL_FIXED will not work on the desktop
	 * @param normalize whether fixed point data should be normalized. Will not work on the desktop
	 * @param stride the stride in bytes between successive attributes
	 * @param buffer the buffer containing the vertex attributes. */
public void setVertexAttribute(String name, int size, int type, boolean normalize, int stride, Buffer buffer) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    int location = fetchAttributeLocation(name);
    if (location == -1)
        return;
    gl.glVertexAttribPointer(location, size, type, normalize, stride, buffer);
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

Example 27 with GL20

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

the class PathTest method render.

@Override
public void render() {
    GL20 gl = Gdx.gl20;
    gl.glClearColor(0.7f, 0.7f, 0.7f, 1);
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    if (wait > 0)
        wait -= Gdx.graphics.getDeltaTime();
    else {
        t += speed * Gdx.graphics.getDeltaTime();
        zt += zspeed * Gdx.graphics.getDeltaTime();
        while (t >= 1f) {
            currentPath = (currentPath + 1) % paths.size;
            pathLength = paths.get(currentPath).approxLength(500);
            if (currentPath > 2) {
                avg_speed = speed * pathLength / 8.0f;
            } else {
                avg_speed = speed * pathLength;
            }
            if (currentPath == 0) {
                zigzag = !zigzag;
                zt = 0;
            }
            t -= 1f;
            t2 = 0f;
        }
        paths.get(currentPath).valueAt(tmpV, t);
        paths.get(currentPath).derivativeAt(tmpV2, t);
        paths.get(currentPath).derivativeAt(tmpV3, t2);
        t2 += avg_speed * Gdx.graphics.getDeltaTime() / tmpV3.len();
        paths.get(currentPath).valueAt(tmpV4, t2);
        if (zigzag) {
            tmpV2.nor();
            tmpV2.set(-tmpV2.y, tmpV2.x);
            tmpV2.scl((float) Math.sin(zt) * ZIGZAG_SCALE);
            tmpV.add(tmpV2);
        }
        obj.setPosition(tmpV.x, tmpV.y);
        obj2.setPosition(tmpV4.x, tmpV4.y);
    }
    renderer.begin(spriteBatch.getProjectionMatrix(), GL20.GL_LINE_STRIP);
    float val = 0f;
    while (val <= 1f) {
        renderer.color(0f, 0f, 0f, 1f);
        paths.get(currentPath).valueAt(/* out: */
        tmpV, val);
        renderer.vertex(tmpV.x, tmpV.y, 0);
        val += SAMPLE_POINT_DISTANCE;
    }
    renderer.end();
    spriteBatch.begin();
    obj.draw(spriteBatch);
    obj2.draw(spriteBatch);
    spriteBatch.end();
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

Example 28 with GL20

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

the class ShaderProgram method setUniformf.

/** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work.
	 * 
	 * @param name the name of the uniform
	 * @param value1 the first value
	 * @param value2 the second value */
public void setUniformf(String name, float value1, float value2) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    int location = fetchUniformLocation(name);
    gl.glUniform2f(location, value1, value2);
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

Example 29 with GL20

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

the class VertexBufferObject method dispose.

/** Disposes of all resources this VertexBufferObject uses. */
@Override
public void dispose() {
    GL20 gl = Gdx.gl20;
    gl.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
    gl.glDeleteBuffer(bufferHandle);
    bufferHandle = 0;
    if (ownsBuffer)
        BufferUtils.disposeUnsafeByteBuffer(byteBuffer);
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

Example 30 with GL20

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

the class ShaderProgram method setUniformi.

/** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work.
	 * 
	 * @param name the name of the uniform
	 * @param value the value */
public void setUniformi(String name, int value) {
    GL20 gl = Gdx.gl20;
    checkManaged();
    int location = fetchUniformLocation(name);
    gl.glUniform1i(location, value);
}
Also used : GL20(com.badlogic.gdx.graphics.GL20)

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