Java Code Examples for com.badlogic.gdx.graphics.g2d.Batch#flush()
The following examples show how to use
com.badlogic.gdx.graphics.g2d.Batch#flush() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VfxWidgetGroup.java From gdx-vfx with Apache License 2.0 | 6 votes |
@Override protected void drawChildren(Batch batch, float parentAlpha) { boolean capturing = vfxManager.isCapturing(); if (capturing) { // Imitate "transform" child drawing for when capturing into VfxManager. super.setTransform(true); } if (!capturing) { // Clip children to VfxWidget area when not capturing into FBO. clipBegin(); } super.drawChildren(batch, parentAlpha); batch.flush(); if (capturing) { super.setTransform(false); } if (!capturing) { clipEnd(); } }
Example 2
Source File: BusyBar.java From vis-ui with Apache License 2.0 | 6 votes |
@Override public void draw (Batch batch, float parentAlpha) { batch.flush(); if (clipBegin()) { Color c = getColor(); batch.setColor(c.r, c.g, c.b, c.a * parentAlpha); segmentX += getSegmentDeltaX(); style.segment.draw(batch, getX() + segmentX, getY(), style.segmentWidth, style.height); if (segmentX > getWidth() + style.segmentOverflow) { resetSegment(); } if (isVisible()) Gdx.graphics.requestRendering(); batch.flush(); clipEnd(); } }
Example 3
Source File: StringSpin.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { batch.flush(); if (clipBegin(getX(), getY() + 2, getWidth(), getHeight())) { super.draw(batch, parentAlpha); batch.flush(); clipEnd(); } }
Example 4
Source File: PagePreviewCanvas.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { batch.flush(); getStage().calculateScissors(widgetAreaBounds.set(getX(), getY(), getWidth(), getHeight()), scissorBounds); if (ScissorStack.pushScissors(scissorBounds)) { super.draw(batch, parentAlpha); batch.flush(); ScissorStack.popScissors(); } }
Example 5
Source File: BusyBar.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); batch.flush(); if (clipBegin()) { Color c = getColor(); batch.setColor(c.r, c.g, c.b, c.a * parentAlpha); patternDrawable.draw(batch, getX() - shift, getY(), getWidth() + shift, getHeight()); if (isVisible()) Gdx.graphics.requestRendering(); batch.flush(); clipEnd(); } }
Example 6
Source File: ScrollPane.java From riiablo with Apache License 2.0 | 5 votes |
@Override public void draw (Batch batch, float parentAlpha) { if (widget == null) return; validate(); // Setup transform for this group. applyTransform(batch, computeTransform()); if (scrollX) hKnobBounds.x = hScrollBounds.x + (int)((hScrollBounds.width - hKnobBounds.width) * getVisualScrollPercentX()); if (scrollY) vKnobBounds.y = vScrollBounds.y + (int)((vScrollBounds.height - vKnobBounds.height) * (1 - getVisualScrollPercentY())); updateWidgetPosition(); // Draw the background ninepatch. Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); if (style.background != null) style.background.draw(batch, 0, 0, getWidth(), getHeight()); // Caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to // project those to screen coordinates for OpenGL ES to consume. getStage().calculateScissors(widgetAreaBounds, scissorBounds); // Enable scissors for widget area and draw the widget. batch.flush(); if (ScissorStack.pushScissors(scissorBounds)) { drawChildren(batch, parentAlpha); batch.flush(); ScissorStack.popScissors(); } // Render scrollbars and knobs on top if they will be visible float alpha = color.a * parentAlpha * Interpolation.fade.apply(fadeAlpha / fadeAlphaSeconds); drawScrollBars(batch, color.r, color.g, color.b, alpha); resetTransform(batch); }
Example 7
Source File: MundusSplitPane.java From Mundus with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { validate(); Color color = getColor(); applyTransform(batch, computeTransform()); // Matrix4 transform = batch.getTransformMatrix(); if (firstWidget != null) { getStage().calculateScissors(firstWidgetBounds, firstScissors); if (ScissorStack.pushScissors(firstScissors)) { if (firstWidget.isVisible()) firstWidget.draw(batch, parentAlpha * color.a); batch.flush(); ScissorStack.popScissors(); } } if (secondWidget != null) { getStage().calculateScissors(secondWidgetBounds, secondScissors); if (ScissorStack.pushScissors(secondScissors)) { if (secondWidget.isVisible()) secondWidget.draw(batch, parentAlpha * color.a); batch.flush(); ScissorStack.popScissors(); } } Drawable handle = style.handle; if (mouseOnHandle && isTouchable() && style.handleOver != null) handle = style.handleOver; batch.setColor(color.r, color.g, color.b, parentAlpha * color.a); handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height); resetTransform(batch); }
Example 8
Source File: CollapseWidget.java From Mundus with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { if (currentHeight > 1) { batch.flush(); boolean clipEnabled = clipBegin(getX(), getY(), getWidth(), currentHeight); super.draw(batch, parentAlpha); batch.flush(); if (clipEnabled) clipEnd(); } }
Example 9
Source File: MundusMultiSplitPane.java From Mundus with Apache License 2.0 | 5 votes |
@Override public void draw(Batch batch, float parentAlpha) { validate(); Color color = getColor(); applyTransform(batch, computeTransform()); SnapshotArray<Actor> actors = getChildren(); for (int i = 0; i < actors.size; i++) { Actor actor = actors.get(i); Rectangle bounds = widgetBounds.get(i); Rectangle scissor = scissors.get(i); getStage().calculateScissors(bounds, scissor); if (ScissorStack.pushScissors(scissor)) { if (actor.isVisible()) actor.draw(batch, parentAlpha * color.a); batch.flush(); ScissorStack.popScissors(); } } batch.setColor(color.r, color.g, color.b, parentAlpha * color.a); Drawable handle = style.handle; Drawable handleOver = style.handle; if (isTouchable() && style.handleOver != null) handleOver = style.handleOver; for (Rectangle rect : handleBounds) { if (this.handleOver == rect) { handleOver.draw(batch, rect.x, rect.y, rect.width, rect.height); } else { handle.draw(batch, rect.x, rect.y, rect.width, rect.height); } } resetTransform(batch); }
Example 10
Source File: CollapsibleWidget.java From vis-ui with Apache License 2.0 | 5 votes |
@Override public void draw (Batch batch, float parentAlpha) { if (currentHeight > 1) { batch.flush(); boolean clipEnabled = clipBegin(getX(), getY(), getWidth(), currentHeight); super.draw(batch, parentAlpha); batch.flush(); if (clipEnabled) clipEnd(); } }
Example 11
Source File: MultiSplitPane.java From vis-ui with Apache License 2.0 | 5 votes |
@Override public void draw (Batch batch, float parentAlpha) { validate(); Color color = getColor(); applyTransform(batch, computeTransform()); SnapshotArray<Actor> actors = getChildren(); for (int i = 0; i < actors.size; i++) { Actor actor = actors.get(i); Rectangle bounds = widgetBounds.get(i); Rectangle scissor = scissors.get(i); getStage().calculateScissors(bounds, scissor); if (ScissorStack.pushScissors(scissor)) { if (actor.isVisible()) actor.draw(batch, parentAlpha * color.a); batch.flush(); ScissorStack.popScissors(); } } batch.setColor(color.r, color.g, color.b, parentAlpha * color.a); Drawable handle = style.handle; Drawable handleOver = style.handle; if (isTouchable() && style.handleOver != null) handleOver = style.handleOver; for (Rectangle rect : handleBounds) { if (this.handleOver == rect) { handleOver.draw(batch, rect.x, rect.y, rect.width, rect.height); } else { handle.draw(batch, rect.x, rect.y, rect.width, rect.height); } } resetTransform(batch); }
Example 12
Source File: VisSplitPane.java From vis-ui with Apache License 2.0 | 5 votes |
@Override public void draw (Batch batch, float parentAlpha) { validate(); Color color = getColor(); applyTransform(batch, computeTransform()); // Matrix4 transform = batch.getTransformMatrix(); if (firstWidget != null) { getStage().calculateScissors(firstWidgetBounds, firstScissors); if (ScissorStack.pushScissors(firstScissors)) { if (firstWidget.isVisible()) firstWidget.draw(batch, parentAlpha * color.a); batch.flush(); ScissorStack.popScissors(); } } if (secondWidget != null) { getStage().calculateScissors(secondWidgetBounds, secondScissors); if (ScissorStack.pushScissors(secondScissors)) { if (secondWidget.isVisible()) secondWidget.draw(batch, parentAlpha * color.a); batch.flush(); ScissorStack.popScissors(); } } Drawable handle = style.handle; if (mouseOnHandle && isTouchable() && style.handleOver != null) handle = style.handleOver; batch.setColor(color.r, color.g, color.b, parentAlpha * color.a); handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height); resetTransform(batch); }
Example 13
Source File: HorizontalCollapsibleWidget.java From vis-ui with Apache License 2.0 | 5 votes |
@Override public void draw (Batch batch, float parentAlpha) { if (currentWidth > 1) { batch.flush(); boolean clipEnabled = clipBegin(getX(), getY(), currentWidth, getHeight()); super.draw(batch, parentAlpha); batch.flush(); if (clipEnabled) clipEnd(); } }
Example 14
Source File: PreviewWidget.java From talos with Apache License 2.0 | 4 votes |
@Override public void drawContent(Batch batch, float parentAlpha) { batch.end(); drawGrid(batch, parentAlpha * 0.5f); batch.begin(); mid.set(0, 0); float imagePrefWidth = previewImage.getPrefWidth(); float imagePrefHeight = previewImage.getPrefHeight(); float scale = imagePrefHeight / imagePrefWidth; float imageWidth = previewController.getImageWidth(); float imageHeight = imageWidth * scale; previewController.getPreviewBoxWidth(); previewImage.setPosition(mid.x - imageWidth / 2, mid.y - imageHeight / 2); previewImage.setSize(imageWidth, imageHeight); if (previewController.isBackground()) { previewImage.draw(batch, parentAlpha); } spriteBatchParticleRenderer.setBatch(batch); batch.flush(); glProfiler.enable(); long timeBefore = TimeUtils.nanoTime(); final ParticleEffectInstance particleEffect = TalosMain.Instance().TalosProject().getParticleEffect(); particleEffect.render(particleRenderer); batch.flush(); renderTime.put(TimeUtils.timeSinceNanos(timeBefore)); trisCount = (int) (glProfiler.getVertexCount().value / 3f); glProfiler.disable(); if (!previewController.isBackground()) { previewImage.draw(batch, parentAlpha); } // now for the drag points if(dragPoints.size > 0) { batch.end(); tmpColor.set(Color.ORANGE); tmpColor.a = 0.8f; Gdx.gl.glLineWidth(1f); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix()); shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); shapeRenderer.setColor(tmpColor); for (DragPoint point : dragPoints) { shapeRenderer.circle(point.position.x, point.position.y, 0.1f * camera.zoom, 15); } shapeRenderer.end(); batch.begin(); } }