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);
}
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();
}
use of com.badlogic.gdx.graphics.GL20 in project libgdx by libgdx.
the class IndexBufferObject method dispose.
/** Disposes this IndexBufferObject and all its associated OpenGL resources. */
public void dispose() {
GL20 gl = Gdx.gl20;
gl.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
gl.glDeleteBuffer(bufferHandle);
bufferHandle = 0;
}
use of com.badlogic.gdx.graphics.GL20 in project libgdx by libgdx.
the class PolygonSpriteBatch method end.
@Override
public void end() {
if (!drawing)
throw new IllegalStateException("PolygonSpriteBatch.begin must be called before end.");
if (vertexIndex > 0)
flush();
lastTexture = null;
drawing = false;
GL20 gl = Gdx.gl;
gl.glDepthMask(true);
if (isBlendingEnabled())
gl.glDisable(GL20.GL_BLEND);
if (customShader != null)
customShader.end();
else
shader.end();
}
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, int offset) {
GL20 gl = Gdx.gl20;
checkManaged();
gl.glVertexAttribPointer(location, size, type, normalize, stride, offset);
}
Aggregations