public void draw(float delta) { Gdx.gl.glEnable(GL10.GL_BLEND); Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); clear(); if (debug) { debugRenderer.draw(CAM); } else { defaultRenderer.draw(CAM, delta); } uiRenderer.draw(delta); }
/** * Draw the edges defined by {@link #setVertices(Array)}. If {@link * OutlineMerger#mergeOutlines(Array)} has been used on this {@link OutlinePolygon} then the draw * method may just be redirected to this outlinePolygon's parents. * * @param batch Accumulates data and sends it in large portions to the gpu, instead of sending * small portions more often. * @return this for chaining. */ public OutlinePolygon draw(PrettyPolygonBatch batch) { if (myParents.size > 0) { // if i have a parent i will not be drawn for (OutlinePolygon outlinePolygon : myParents) { outlinePolygon.draw(batch); } return this; } drawInvocations++; if (myChildren.size == 0 || drawInvocations >= myChildren.size) { if (!visible) return this; debugRenderer.queueIfEnabled(batch); timeOfLastDrawCall = System.currentTimeMillis(); // if i don't have any children i will just attempt to draw right away // also if all my children has had their draw method called i will attempt to draw drawInvocations = 0; if (halfWidth <= 0) return this; if (color.a <= 0) return this; if (weight <= 0) return this; if (scale <= 0) return this; if (!drawInside && !drawOutside) return this; Rectangle frustum = this.frustum.set(batch.frustum); tmpColor.set(color).a *= opacity; updateStripAndCulling(); for (BoundingBox box : boundingBoxes) { Rectangle cullingArea = getCullingArea(tmpRectangle, box.rectangle, angleRad, position, scale); if (frustum.overlaps(cullingArea)) { // if we reached here we can draw the vertices within this particular BoundingBox if (drawInside) { batch.drawOutline( vertexDataArray, closedPolygon, true, box.begin, box.begin + box.count + 1, box.dataCount, tmpColor, scale, angleRad, position.x, position.y, weight); } if (drawOutside) { batch.drawOutline( vertexDataArray, closedPolygon, false, box.begin, box.begin + box.count + 1, box.dataCount, tmpColor, scale, angleRad, position.x, position.y, weight); } } } } return this; }
/** For debugging. */ public OutlinePolygon setDrawTriangleStrips(boolean drawTriangleStrips) { this.drawTriangleStrips = drawTriangleStrips; debugRenderer.update(); return this; }
/** For debugging. */ public OutlinePolygon setDrawLineFromFirstToLast(boolean drawLineFromFirstToLast) { this.drawLineFromFirstToLast = drawLineFromFirstToLast; debugRenderer.update(); return this; }
/** For debugging. */ public OutlinePolygon setDrawCullingRectangles(boolean drawCullingRectangles) { this.drawCullingRectangles = drawCullingRectangles; debugRenderer.update(); return this; }