Java Code Examples for com.badlogic.gdx.graphics.Texture#dispose()

The following examples show how to use com.badlogic.gdx.graphics.Texture#dispose() . These examples are extracted from open source projects. 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 Project: uracer-kotd   File: Art.java    License: Apache License 2.0 6 votes vote down vote up
private static void disposeMeshesGraphics () {
	meshMissing.dispose();
	meshTrackWall.dispose();

	// car textures
	for (Texture t : meshCar.values()) {
		t.dispose();
	}
	meshCar.clear();

	// trees
	for (int i = 0; i < 7; i++) {
		meshTreeLeavesSpring[i].dispose();
	}

	meshTreeTrunk.dispose();
}
 
Example 2
@Override
protected void setStage(Stage stage) {
    super.setStage(stage);

    if (!initialized && stage != null) {
        initialized = true;
        texture = new Texture(pixmap);
        image.setDrawable(new TextureRegionDrawable(new TextureRegion(texture)));
    }
    if (initialized && stage == null) {
        initialized = false;
        texture.dispose();
        texture = null;
        image.setDrawable(null);
    }
}
 
Example 3
@Override
public void dispose() {
	if (stage != null) {
		stage.dispose();
		stage = null;

		if (bgTexFile != null) {
			bgTexFile.dispose();
		}

		bgTexFile = null;

		for (Texture t : textureList)
			t.dispose();
	}
}
 
Example 4
Source Project: gdx-gltf   File: SceneAsset.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void dispose() {
	if(scenes != null){
		for(SceneModel scene : scenes){
			scene.dispose();
		}
	}
	if(textures != null){
		for(Texture texture : textures){
			texture.dispose();
		}
	}
}
 
Example 5
/**
 * リソースを開放する
 */
public void dispose() {
	for (Texture bga : bgacache) {
		if (bga != null) {
			bga.dispose();
		}
	}
	bgacache = new Texture[0];

	cache.dispose();
}
 
Example 6
Source Project: Radix   File: GameRenderer.java    License: MIT License 5 votes vote down vote up
@Override
public void cleanup() {
    debugTextRenderer.dispose();

    for (Texture t : blockBreakStages) {
        t.dispose();
    }

    if (blockBreakModel != null) {
        blockBreakModel.dispose();
    }

    initted = false;
}
 
Example 7
Source Project: riiablo   File: MPQViewer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void dispose() {
  Gdx.app.debug(TAG, "disposing...");
  prefs.flush();
  stage.dispose();
  Gdx.app.debug(TAG, "disposing palettes...");
  for (Texture palette : palettes.values()) palette.dispose();
}
 
Example 8
Source Project: riiablo   File: DC6.java    License: Apache License 2.0 5 votes vote down vote up
private void disposeTextures() {
  if (textures == null) return;
  final int numDirections = header.directions;
  for (int d = 0; d < numDirections; d++) {
    Texture[] frames = textures[d];
    if (frames != null) for (Texture frame : frames) frame.dispose();
  }

  textures = null;
}
 
Example 9
Source Project: riiablo   File: DCC.java    License: Apache License 2.0 5 votes vote down vote up
private void disposeTextures() {
  if (textures == null) return;
  final int numDirections = header.directions;
  for (int d = 0; d < numDirections; d++) {
    Texture[] frames = textures[d];
    if (frames != null) for (Texture frame : frames) frame.dispose();
  }

  textures = null;
}
 
Example 10
@Override
public void dispose() {
	for (Texture t : images.values())
		t.dispose();

	images.clear();
	credits.clear();

	if (music != null) {
		music.stop();
		music.dispose();
		music = null;
	}
}
 
Example 11
public boolean saveChallengeImage(final int score, final boolean timeMode) {
    final File saveAt = getShareImageFilePath();
    if (!saveAt.getParentFile().isDirectory())
        if (!saveAt.mkdirs())
            return false;

    final FileHandle output = new FileHandle(saveAt);

    final Texture shareBase = new Texture(Gdx.files.internal("share.png"));
    final int width = shareBase.getWidth();
    final int height = shareBase.getHeight();

    final FrameBuffer frameBuffer = new FrameBuffer(Pixmap.Format.RGB888, width, height, false);
    frameBuffer.begin();

    // Render the base share texture
    final SpriteBatch batch = new SpriteBatch();
    final Matrix4 matrix = new Matrix4();
    matrix.setToOrtho2D(0, 0, width, height);
    batch.setProjectionMatrix(matrix);

    Gdx.gl.glClearColor(Color.GOLD.r, Color.GOLD.g, Color.GOLD.b, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();
    batch.draw(shareBase, 0, 0);

    // Render the achieved score
    final Label.LabelStyle style = new Label.LabelStyle();
    style.font = new BitmapFont(Gdx.files.internal("font/x1.0/geosans-light64.fnt"));
    Label label = new Label("just scored " + score + " on", style);
    label.setColor(Color.BLACK);
    label.setPosition(40, 500);
    label.draw(batch, 1);

    label.setText("try to beat me if you can");
    label.setPosition(40, 40);
    label.draw(batch, 1);

    if (timeMode) {
        Texture timeModeTexture = new Texture("ui/x1.5/stopwatch.png");
        batch.setColor(Color.BLACK);
        batch.draw(timeModeTexture, 200, 340);
    }

    batch.end();

    // Get the framebuffer pixels and write them to a local file
    final byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, width, height, true);

    final Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);

    BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
    PixmapIO.writePNG(output, pixmap);

    // Dispose everything
    pixmap.dispose();
    shareBase.dispose();
    batch.dispose();
    frameBuffer.end();

    return true;
}
 
Example 12
Source Project: riiablo   File: DT1.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void dispose() {
  if (!loadData) return;
  if (textures == null) return;
  for (Texture texture : textures) texture.dispose();
}
 
Example 13
/** 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. */
public void dispose () {
	for (Texture texture : textures)
		texture.dispose();
	textures.clear();
}