/** Draws a triangle in x/y plane with colored corners using {@link ShapeType#Line} or {@link ShapeType#Filled}. */ public void triangle (float x1, float y1, float x2, float y2, float x3, float y3, Color col1, Color col2, Color col3) { check(ShapeType.Line, ShapeType.Filled, 6); if (shapeType == ShapeType.Line) { renderer.color(col1.r, col1.g, col1.b, col1.a); renderer.vertex(x1, y1, 0); renderer.color(col2.r, col2.g, col2.b, col2.a); renderer.vertex(x2, y2, 0); renderer.color(col2.r, col2.g, col2.b, col2.a); renderer.vertex(x2, y2, 0); renderer.color(col3.r, col3.g, col3.b, col3.a); renderer.vertex(x3, y3, 0); renderer.color(col3.r, col3.g, col3.b, col3.a); renderer.vertex(x3, y3, 0); renderer.color(col1.r, col1.g, col1.b, col1.a); renderer.vertex(x1, y1, 0); } else { renderer.color(col1.r, col1.g, col1.b, col1.a); renderer.vertex(x1, y1, 0); renderer.color(col2.r, col2.g, col2.b, col2.a); renderer.vertex(x2, y2, 0); renderer.color(col3.r, col3.g, col3.b, col3.a); renderer.vertex(x3, y3, 0); } }
@Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glEnable(GL20.GL_TEXTURE_2D); texture.bind(); renderer.begin(projMatrix, GL20.GL_TRIANGLES); renderer.texCoord(0, 0); renderer.color(1, 0, 0, 1); renderer.vertex(-0.5f, -0.5f, 0); renderer.texCoord(1, 0); renderer.color(0, 1, 0, 1); renderer.vertex(0.5f, -0.5f, 0); renderer.texCoord(0.5f, 1); renderer.color(0, 0, 1, 1); renderer.vertex(0f, 0.5f, 0); renderer.end(); }
public void dispose () { renderer.dispose(); } }
/** @param other May be null. */ private void check (ShapeType preferred, ShapeType other, int newVertices) { if (shapeType == null) throw new IllegalStateException("begin must be called first."); if (shapeType != preferred && shapeType != other) { // Shape type is not valid. if (!autoShapeType) { if (other == null) throw new IllegalStateException("Must call begin(ShapeType." + preferred + ")."); else throw new IllegalStateException("Must call begin(ShapeType." + preferred + ") or begin(ShapeType." + other + ")."); } end(); begin(preferred); } else if (matrixDirty) { // Matrix has been changed. ShapeType type = shapeType; end(); begin(type); } else if (renderer.getMaxVertices() - renderer.getNumVertices() < newVertices) { // Not enough space. ShapeType type = shapeType; end(); begin(type); } }
/** Finishes the batch of shapes and ensures they get rendered. */ public void end () { renderer.end(); shapeType = null; }
/** Starts a new batch of shapes. Shapes drawn within the batch will attempt to use the type specified. The call to this method * must be paired with a call to {@link #end()}. * @see #setAutoShapeType(boolean) */ public void begin (ShapeType type) { if (shapeType != null) throw new IllegalStateException("Call end() before beginning a new shape batch."); shapeType = type; if (matrixDirty) { combinedMatrix.set(projectionMatrix); Matrix4.mul(combinedMatrix.val, transformMatrix.val); matrixDirty = false; } renderer.begin(combinedMatrix, shapeType.getGlType()); }
/** @param other May be null. */ private void check (ShapeType preferred, ShapeType other, int newVertices) { if (shapeType == null) throw new IllegalStateException("begin must be called first."); if (shapeType != preferred && shapeType != other) { // Shape type is not valid. if (!autoShapeType) { if (other == null) throw new IllegalStateException("Must call begin(ShapeType." + preferred + ")."); else throw new IllegalStateException("Must call begin(ShapeType." + preferred + ") or begin(ShapeType." + other + ")."); } end(); begin(preferred); } else if (matrixDirty) { // Matrix has been changed. ShapeType type = shapeType; end(); begin(type); } else if (renderer.getMaxVertices() - renderer.getNumVertices() < newVertices) { // Not enough space. ShapeType type = shapeType; end(); begin(type); } }
/** Finishes the batch of shapes and ensures they get rendered. */ public void end () { renderer.end(); shapeType = null; }
/** Starts a new batch of shapes. Shapes drawn within the batch will attempt to use the type specified. The call to this method * must be paired with a call to {@link #end()}. * @see #setAutoShapeType(boolean) */ public void begin (ShapeType type) { if (shapeType != null) throw new IllegalStateException("Call end() before beginning a new shape batch."); shapeType = type; if (matrixDirty) { combinedMatrix.set(projectionMatrix); Matrix4.mul(combinedMatrix.val, transformMatrix.val); matrixDirty = false; } renderer.begin(combinedMatrix, shapeType.getGlType()); }
/** Draws a triangle in x/y plane with colored corners using {@link ShapeType#Line} or {@link ShapeType#Filled}. */ public void triangle (float x1, float y1, float x2, float y2, float x3, float y3, Color col1, Color col2, Color col3) { check(ShapeType.Line, ShapeType.Filled, 6); if (shapeType == ShapeType.Line) { renderer.color(col1.r, col1.g, col1.b, col1.a); renderer.vertex(x1, y1, 0); renderer.color(col2.r, col2.g, col2.b, col2.a); renderer.vertex(x2, y2, 0); renderer.color(col2.r, col2.g, col2.b, col2.a); renderer.vertex(x2, y2, 0); renderer.color(col3.r, col3.g, col3.b, col3.a); renderer.vertex(x3, y3, 0); renderer.color(col3.r, col3.g, col3.b, col3.a); renderer.vertex(x3, y3, 0); renderer.color(col1.r, col1.g, col1.b, col1.a); renderer.vertex(x1, y1, 0); } else { renderer.color(col1.r, col1.g, col1.b, col1.a); renderer.vertex(x1, y1, 0); renderer.color(col2.r, col2.g, col2.b, col2.a); renderer.vertex(x2, y2, 0); renderer.color(col3.r, col3.g, col3.b, col3.a); renderer.vertex(x3, y3, 0); } }
/** @param other May be null. */ private void check (ShapeType preferred, ShapeType other, int newVertices) { if (shapeType == null) throw new IllegalStateException("begin must be called first."); if (shapeType != preferred && shapeType != other) { // Shape type is not valid. if (!autoShapeType) { if (other == null) throw new IllegalStateException("Must call begin(ShapeType." + preferred + ")."); else throw new IllegalStateException("Must call begin(ShapeType." + preferred + ") or begin(ShapeType." + other + ")."); } end(); begin(preferred); } else if (matrixDirty) { // Matrix has been changed. ShapeType type = shapeType; end(); begin(type); } else if (renderer.getMaxVertices() - renderer.getNumVertices() < newVertices) { // Not enough space. ShapeType type = shapeType; end(); begin(type); } }
/** Finishes the batch of shapes and ensures they get rendered. */ public void end () { renderer.end(); shapeType = null; }
/** Starts a new batch of shapes. Shapes drawn within the batch will attempt to use the type specified. The call to this method * must be paired with a call to {@link #end()}. * @see #setAutoShapeType(boolean) */ public void begin (ShapeType type) { if (shapeType != null) throw new IllegalStateException("Call end() before beginning a new shape batch."); shapeType = type; if (matrixDirty) { combinedMatrix.set(projectionMatrix); Matrix4.mul(combinedMatrix.val, transformMatrix.val); matrixDirty = false; } renderer.begin(combinedMatrix, shapeType.getGlType()); }
public void dispose () { renderer.dispose(); } }
/** Draws a triangle in x/y plane using {@link ShapeType#Line} or {@link ShapeType#Filled}. */ public void triangle (float x1, float y1, float x2, float y2, float x3, float y3) { check(ShapeType.Line, ShapeType.Filled, 6); float colorBits = color.toFloatBits(); if (shapeType == ShapeType.Line) { renderer.color(colorBits); renderer.vertex(x1, y1, 0); renderer.color(colorBits); renderer.vertex(x2, y2, 0); renderer.color(colorBits); renderer.vertex(x2, y2, 0); renderer.color(colorBits); renderer.vertex(x3, y3, 0); renderer.color(colorBits); renderer.vertex(x3, y3, 0); renderer.color(colorBits); renderer.vertex(x1, y1, 0); } else { renderer.color(colorBits); renderer.vertex(x1, y1, 0); renderer.color(colorBits); renderer.vertex(x2, y2, 0); renderer.color(colorBits); renderer.vertex(x3, y3, 0); } }
/** @param other May be null. */ private void check(ShapeType preferred, ShapeType other, int newVertices) { if (shapeType == null) throw new IllegalStateException("begin must be called first."); if (shapeType != preferred && shapeType != other) { // Shape type is not valid. if (!autoShapeType) { if (other == null) throw new IllegalStateException("Must call begin(ShapeType." + preferred + ")."); else throw new IllegalStateException("Must call begin(ShapeType." + preferred + ") or begin(ShapeType." + other + ")."); } end(); begin(preferred); } else if (matrixDirty) { // Matrix has been changed. ShapeType type = shapeType; end(); begin(type); } else if (renderer.getMaxVertices() - renderer.getNumVertices() < newVertices) { // Not enough space. ShapeType type = shapeType; end(); begin(type); } }
/** Finishes the batch of shapes and ensures they get rendered. */ public void end() { renderer.end(); shapeType = null; }
/** Starts a new batch of shapes. Shapes drawn within the batch will attempt to use the type specified. The call to this method * must be paired with a call to {@link #end()}. * @see #setAutoShapeType(boolean) */ public void begin(ShapeType type) { if (shapeType != null) throw new IllegalStateException("Call end() before beginning a new shape batch."); shapeType = type; if (matrixDirty) { combinedMatrix.set(projectionMatrix); Matrix4.mul(combinedMatrix.val, transformMatrix.val); matrixDirty = false; } renderer.begin(combinedMatrix, shapeType.getGlType()); }
public void dispose () { renderer.dispose(); } }
/** Draws a triangle in x/y plane using {@link ShapeType#Line} or {@link ShapeType#Filled}. */ public void triangle (float x1, float y1, float x2, float y2, float x3, float y3) { check(ShapeType.Line, ShapeType.Filled, 6); float colorBits = color.toFloatBits(); if (shapeType == ShapeType.Line) { renderer.color(colorBits); renderer.vertex(x1, y1, 0); renderer.color(colorBits); renderer.vertex(x2, y2, 0); renderer.color(colorBits); renderer.vertex(x2, y2, 0); renderer.color(colorBits); renderer.vertex(x3, y3, 0); renderer.color(colorBits); renderer.vertex(x3, y3, 0); renderer.color(colorBits); renderer.vertex(x1, y1, 0); } else { renderer.color(colorBits); renderer.vertex(x1, y1, 0); renderer.color(colorBits); renderer.vertex(x2, y2, 0); renderer.color(colorBits); renderer.vertex(x3, y3, 0); } }