List of usage examples for com.badlogic.gdx.graphics Texture dispose
public void dispose()
From source file:base.MyGdxGame.java
License:Open Source License
@Override public void render() { ArrayList<Texture> textures = new ArrayList<>(); Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT); // clears the buffer batch.begin();/*from ww w .j a v a2s . c o m*/ LinkedList<PatternInstance> newList = new LinkedList<>(); int x = Gdx.input.getX(); int y = Gdx.input.getY(); if (Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) willStep = !willStep; if (Gdx.input.isKeyJustPressed(Input.Keys.TAB)) oneStep = true; if (Gdx.input.isTouched()) { if (Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT)) currentPatterns.add(new FrozenPatternInstance( new PatternInstance(x, y - Gdx.graphics.getHeight() + 1, ONE_CELL, knownPatterns))); else currentPatterns .add(new PatternInstance(x, y - Gdx.graphics.getHeight() + 1, ONE_CELL, knownPatterns)); } for (ListIterator<PatternInstance> iter = currentPatterns.listIterator(); iter.hasNext();) { PatternInstance currentPatternInstance = iter.next(); if (Gdx.input.isKeyJustPressed(Input.Keys.A)) currentPatternInstance = new PatternInstance(currentPatternInstance.getX(), currentPatternInstance.getY(), currentPatternInstance.getEntry()); Texture tx = null; if (currentPatternInstance instanceof FrozenPatternInstance) tx = Engine.generatePatternTexture(currentPatternInstance.getEntry(), Color.CYAN); else tx = Engine.generatePatternTexture(currentPatternInstance.getEntry(), Color.YELLOW); if (currentPatternInstance.getRectangle().contains(x, y - Gdx.graphics.getHeight() + 1)) { tx = Engine.generatePatternTexture(currentPatternInstance.getEntry(), Color.MAGENTA); if (Gdx.input.isKeyJustPressed(Input.Keys.BACKSPACE)) { iter.remove(); continue; } } if (willStep || oneStep) { PatternInstance[] successors = currentPatternInstance.step(actingRule, knownPatterns); for (PatternInstance i : successors) newList.add(i); batch.draw(tx, currentPatternInstance.getX(), -currentPatternInstance.getY() - currentPatternInstance.getRectangle().getHeight() + 1); } else { newList.add(currentPatternInstance); batch.draw(tx, currentPatternInstance.getX(), -currentPatternInstance.getY() - currentPatternInstance.getRectangle().getHeight() + 1); } textures.add(tx); } batch.end(); Set<TreeSet<PatternInstance>> collisionSet = Engine.findCollisions(newList, 5); currentPatterns = Engine.cleanList(Engine.massMerge(collisionSet, newList, knownPatterns, actingRule)); oneStep = false; for (Texture t : textures) { if (t != null) t.dispose(); } }
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.AbstractScreen.java
License:Open Source License
@Override public void dispose() { // as the collaborators are lazily loaded, they may be null if (font != null) font.dispose();/*from ww w . j a v a 2 s.co m*/ if (batch != null) batch.dispose(); if (skin != null) skin.dispose(); if (fadeBatch != null) fadeBatch.dispose(); for (Texture texture : textureList) { texture.dispose(); } }
From source file:br.com.raphaelbruno.game.zombieinvaders.vr.screen.SplashScreen.java
License:Apache License
@Override public void dispose() { game.spriteBatch.dispose();//from www .j ava2s . c om game.modelBatch.dispose(); for (Texture item : logos) item.dispose(); }
From source file:com.badlogic.gdx.rube.test.SpriteRenderer.java
public void dispose() { Values<Texture> textures = textureMap.values(); while (textures.hasNext()) { Texture texture = textures.next(); texture.dispose(); }//from www . jav a 2 s. c o m }
From source file:com.badlogic.gdx.tests.PremultiplyAlpha.java
private void gpuPremultiplyAlpha(String in, String out) { Texture texture = new Texture(Gdx.files.absolute(in)); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); FrameBuffer buffer = new FrameBuffer(Format.RGBA8888, texture.getWidth(), texture.getHeight(), false); buffer.getColorBufferTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest); ShaderProgram shader = new ShaderProgram(VERTEX_SHADER, FRAG_SHADER); Gdx.app.log("Log", shader.getLog()); SpriteBatch batch = new SpriteBatch(10); batch.getProjectionMatrix().setToOrtho2D(0, 0, texture.getWidth(), texture.getHeight()); batch.disableBlending();// w w w . j a v a2 s. c om batch.setShader(shader); //Premultiply buffer.begin(); Gdx.gl.glClearColor(0, 0, 0, 0); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); batch.draw(texture, 0, 0); batch.end(); Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, texture.getWidth(), texture.getHeight()); buffer.end(); //Save PixmapIO.writePNG(Gdx.files.absolute(out), pixmap); buffer.dispose(); texture.dispose(); pixmap.dispose(); Gdx.app.exit(); }
From source file:com.bladecoder.engine.ui.CreditsScreen.java
License:Apache License
@Override public void dispose() { for (Texture t : images.values()) t.dispose(); images.clear();// w ww . j a v a 2 s .c om credits.clear(); if (music != null) { music.stop(); music.dispose(); } }
From source file:com.bladecoder.engine.ui.LoadSaveScreen.java
License:Apache License
@Override public void dispose() { stage.dispose();//from w w w . j av a 2s .c o m stage = null; if (bgTexFile != null) { bgTexFile.dispose(); } bgTexFile = null; for (Texture t : textureList) t.dispose(); }
From source file:com.blindtigergames.werescrewed.graphics.TextureAtlas.java
License:Apache License
/** * Releases all resources associated with this TextureAtlas instance. This * releases all the textures backing all TextureRegions and Sprites, which * should no longer be used after calling dispose. *//*from w ww.ja va 2s. c o m*/ public void dispose() { for (Texture texture : textures) texture.dispose(); textures.clear(); }
From source file:com.github.skittishSloth.openSkies.maps.PlanetScreen.java
@Override public void dispose() { for (final Texture t : textures) { t.dispose(); }/*from ww w . j a va 2s . c om*/ textures.clear(); batch.dispose(); }
From source file:com.iLoong.launcher.UI3DEngine.TextField3D.java
License:Open Source License
private void updateDisplayText() { if (passwordMode) { if (passwordBuffer == null) passwordBuffer = new StringBuilder(text.length()); if (passwordBuffer.length() > text.length()) // passwordBuffer.setLength(text.length()); else {// w w w . j av a2s . c om for (int i = passwordBuffer.length(), n = text.length(); i < n; i++) passwordBuffer.append(passwordCharacter); } displayText = passwordBuffer.toString(); } else { displayText = text; } displayText = textFormater.formatDisplayTitle(displayText, (int) ((int) width - 1 * 30 * UtilsBase.getScreenWidth() / 720f), (int) height); displayOffsetX = (this.width - paint.measureText(displayText)) / 2; if (displayOffsetX < 0) { displayOffsetX = 0; } calculateOffsets(); this.inputText_X = mediate ? displayOffsetX : 0; Texture oldTexture = null; if (this.displayTextTexture != null && displayTextTexture.getTexture() != null) { oldTexture = displayTextTexture.getTexture(); TextureRegion newRegion = textFormater.getDisplayTexture(displayText, (int) width, (int) height); displayTextTexture.setRegion(newRegion); if (oldTexture != null) { oldTexture.dispose(); } } else { displayTextTexture = textFormater.getDisplayTexture(displayText, (int) width, (int) height); } }