List of usage examples for com.badlogic.gdx.graphics.g2d Batch flush
public void flush();
From source file:CB_UI_Base.GL_UI.Controls.Dialog.java
License:Open Source License
@Override public void renderChilds(final Batch batch, ParentInfo parentInfo) { if (this.isDisposed()) return;/*ww w.j av a 2s .co m*/ batch.flush(); try { if (mHeader9patch != null && !dontRenderDialogBackground) { mHeader9patch.draw(batch, 0, this.getHeight() - mTitleHeight - mHeaderHeight, this.getWidth(), mHeaderHeight); } if (mFooter9patch != null && !dontRenderDialogBackground) { mFooter9patch.draw(batch, 0, 0, this.getWidth(), mFooterHeight + 2); } if (mCenter9patch != null && !dontRenderDialogBackground) { mCenter9patch.draw(batch, 0, mFooterHeight, this.getWidth(), (this.getHeight() - mFooterHeight - mHeaderHeight - mTitleHeight) + 3.5f); } if (mHasTitle) { if (mTitleWidth < this.getWidth()) { if (mTitle9patch != null && !dontRenderDialogBackground) { mTitle9patch.draw(batch, 0, this.getHeight() - mTitleHeight - mTitleVersatz, mTitleWidth, mTitleHeight); } } else { if (mHeader9patch != null && !dontRenderDialogBackground) { mHeader9patch.draw(batch, 0, this.getHeight() - mTitleHeight - mTitleVersatz, mTitleWidth, mTitleHeight); } } } batch.flush(); } catch (Exception e1) { } if (this.isDisposed()) return; super.renderChilds(batch, parentInfo); try { if (overlay != null) { for (Iterator<GL_View_Base> iterator = overlay.iterator(); iterator.hasNext();) { // alle renderChilds() der in dieser GL_View_Base // enthaltenen Childs auf rufen. GL_View_Base view; try { view = iterator.next(); // hier nicht view.render(batch) aufrufen, da sonnst die in der // view enthaldenen Childs nicht aufgerufen werden. if (view != null && view.isVisible()) { if (childsInvalidate) view.invalidate(); getMyInfoForChild().setParentInfo(myParentInfo); getMyInfoForChild().setWorldDrawRec(intersectRec); getMyInfoForChild().add(view.getX(), view.getY()); batch.setProjectionMatrix(getMyInfoForChild().Matrix()); nDepthCounter++; view.renderChilds(batch, getMyInfoForChild()); nDepthCounter--; batch.setProjectionMatrix(myParentInfo.Matrix()); } } catch (java.util.ConcurrentModificationException e) { // da die Liste nicht mehr gltig ist, brechen wir hier den Iterator ab break; } } } } catch (Exception e) { } }
From source file:CB_UI_Base.GL_UI.GL_View_Base.java
License:Open Source License
/** * Die renderChilds() Methode wird vom GL_Listener bei jedem Render-Vorgang aufgerufen. * Hier wird dann zuerst die render() Methode dieser View aufgerufen. * Danach werden alle Childs iteriert und deren renderChilds() Methode aufgerufen, wenn die View sichtbar ist (Visibility). * * @param batch/*from w w w . java2 s . c o m*/ */ public void renderChilds(final Batch batch, ParentInfo parentInfo) { if (myParentInfo == null) return; if (this.isDisposed) return; if (thisInvalidate) { myParentInfo.setParentInfo(parentInfo); CalcMyInfoForChild(); } if (!withoutScissor) { if (intersectRec == null || intersectRec.getHeight() + 1 < 0 || intersectRec.getWidth() + 1 < 0) return; // hier gibt es nichts zu rendern if (!disableScissor) Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST); Gdx.gl.glScissor((int) intersectRec.getX(), (int) intersectRec.getY(), (int) intersectRec.getWidth() + 1, (int) intersectRec.getHeight() + 1); } float A = 0, R = 0, G = 0, B = 0; // Farbwerte der batch um diese wieder einzustellen, wenn ein ColorFilter angewandt wurde! boolean ColorFilterSeted = false; // Wir benutzen hier dieses Boolean um am ende dieser Methode zu entscheiden, ob wir die alte // Farbe des Batches wieder herstellen mssen. Wir verlassen uns hier nicht darauf, das // mColorFilter!= null ist, da dies in der zwichenzeit passiert sein kann. // Set Colorfilter ? if (mColorFilter != null) { ColorFilterSeted = true; // zuerst alte Farbe abspeichern, um sie Wieder Herstellen zu knnen // hier muss jeder Wert einzeln abgespeichert werden, da bei getColor() // nur eine Referenz zurck gegeben wird Color c = batch.getColor(); A = c.a; R = c.r; G = c.g; B = c.b; batch.setColor(mColorFilter); } // first Draw Background? if (drawableBackground != null) { drawableBackground.draw(batch, 0, 0, getWidth(), getHeight()); } // set rotation boolean isRotated = false; if (mRotate != 0 || mScale != 1) { isRotated = true; rotateMatrix.idt(); rotateMatrix.translate(mOriginX, mOriginY, 0); rotateMatrix.rotate(0, 0, 1, mRotate); rotateMatrix.scale(mScale, mScale, 1); rotateMatrix.translate(-mOriginX, -mOriginY, 0); batch.setTransformMatrix(rotateMatrix); } try { this.render(batch); } catch (IllegalStateException e) { e.printStackTrace(); // reset Colorfilter ? if (ColorFilterSeted) { // alte abgespeicherte Farbe des Batches wieder herstellen! batch.setColor(R, G, B, A); } return; } // reverse rotation if (isRotated) { rotateMatrix.idt(); // rotateMatrix.rotate(0, 0, 1, 0); // rotateMatrix.scale(1, 1, 1); batch.setTransformMatrix(rotateMatrix); } if (childs != null && childs.size() > 0) { for (int i = 0, n = childs.size(); i < n; i++) { if (i >= childs.size()) { break; // ConcurrentModificationException } // alle renderChilds() der in dieser GL_View_Base // enthaltenen Childs auf rufen. try { GL_View_Base view = childs.get(i); // hier nicht view.render(batch) aufrufen, da sonnst die in der // view enthaldenen Childs nicht aufgerufen werden. try { if (view != null && !view.isDisposed() && view.isVisible()) { synchronized (view) { if (childsInvalidate) view.invalidate(); getMyInfoForChild().setParentInfo(myParentInfo); getMyInfoForChild().setWorldDrawRec(intersectRec); getMyInfoForChild().add(view.getX(), view.getY()); batch.setProjectionMatrix(getMyInfoForChild().Matrix()); nDepthCounter++; view.renderChilds(batch, getMyInfoForChild()); nDepthCounter--; } } else { if (view != null && view.isDisposed()) { // Remove disposedView from child list this.removeChild(view); } } } catch (java.lang.IllegalStateException e) { if (view != null && view.isDisposed()) { // Remove disposedView from child list this.removeChild(view); } } } catch (java.util.NoSuchElementException e) { break; // da die Liste nicht mehr gltig ist, brechen wir hier den Iterator ab } catch (java.util.ConcurrentModificationException e) { break; // da die Liste nicht mehr gltig ist, brechen wir hier den Iterator ab } catch (java.lang.IndexOutOfBoundsException e) { break; // da die Liste nicht mehr gltig ist, brechen wir hier den Iterator ab } } childsInvalidate = false; } // Draw Debug REC if (debug) { if (DebugSprite != null) { batch.flush(); DebugSprite.draw(batch); } } // reset Colorfilter ? if (ColorFilterSeted) { // alte abgespeicherte Farbe des Batches wieder herstellen! batch.setColor(R, G, B, A); } }
From source file:CB_UI_Base.graphics.PolygonDrawable.java
License:Open Source License
@Override public boolean draw(Batch batch, float x, float y, float width, float height, float rotate) { synchronized (isDisposed) { if (isDisposed.get()) return true; if (po == null) { if (this.PAINT.getBitmapShader() == null) { if (texReg == null) createTexRegFromPixMap(); po = new PolygonRegion(texReg, VERTICES, TRIANGLES); } else { Texture inputTex = this.PAINT.getBitmapShader().getTexture(); if (inputTex != null) { inputTex.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); po = new PolygonRegion(new TextureRegion(inputTex, (int) this.WIDTH, (int) this.HEIGHT), VERTICES, TRIANGLES); }//from w w w. j ava2s . c om } } Color c = batch.getColor(); float a = c.a; float r = c.r; float g = c.g; float b = c.b; if (po == null) return true; if (this.PAINT.getBitmapShader() == null) { GL.setBatchColor(PAINT.getGlColor()); } else { batch.setColor(new Color(Color.WHITE)); } batch.flush(); try { ((PolygonSpriteBatch) batch).draw(po, x, y, width, height); } catch (Exception e) { e.printStackTrace(); } batch.flush(); // reset color batch.setColor(r, g, b, a); } return true; }
From source file:com.idp.engine.ui.graphics.actors.listview.ListView.java
@Override public void drawChildren(Batch batch, float parentAlpha) { ScissorStack.calculateScissors(getStage().getCamera(), batch.getTransformMatrix(), bounds, scissors); batch.flush(); boolean pushed = ScissorStack.pushScissors(scissors); super.drawChildren(batch, parentAlpha); if (pushed) { batch.flush();/*from w ww .j a v a2s . c o m*/ ScissorStack.popScissors(); } }
From source file:com.kotcrab.vis.runtime.entity.TextEntity.java
License:Apache License
@Override public void render(Batch spriteBatch) { spriteBatch.setTransformMatrix(translationMatrix); cache.draw(spriteBatch);/* www .j a v a 2s. c o m*/ spriteBatch.flush(); spriteBatch.setTransformMatrix(idtMatrix); }
From source file:com.kotcrab.vis.ui.widget.BusyBar.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { batch.flush(); if (clipBegin()) { Color c = getColor();/*from w ww . j ava2 s.co m*/ 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(); } }
From source file:com.kotcrab.vis.ui.widget.CollapsibleWidget.java
License:Apache License
@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();// w w w . j av a 2 s .c o m if (clipEnabled) clipEnd(); } }
From source file:com.kotcrab.vis.ui.widget.HorizontalCollapsibleWidget.java
License:Apache License
@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();/* w w w. ja v a 2 s . c o m*/ if (clipEnabled) clipEnd(); } }
From source file:com.kotcrab.vis.ui.widget.MultiSplitPane.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { validate();/* w w w .j av a 2 s. c o m*/ 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); }
From source file:com.kotcrab.vis.ui.widget.VisSplitPane.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { validate();//from w ww .j a v a 2 s. c o m 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); }