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

The following examples show how to use com.badlogic.gdx.graphics.Texture#dispose() . 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: Art.java    From uracer-kotd with 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
Source File: SourceImage.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@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
Source File: LoadSaveScreen.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
@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 File: SceneAsset.java    From gdx-gltf with 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
Source File: BGImageProcessor.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
/**
 * リソースを開放する
 */
public void dispose() {
	for (Texture bga : bgacache) {
		if (bga != null) {
			bga.dispose();
		}
	}
	bgacache = new Texture[0];

	cache.dispose();
}
 
Example 6
Source File: GameRenderer.java    From Radix with 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 File: MPQViewer.java    From riiablo with 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 File: DC6.java    From riiablo with 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 File: DCC.java    From riiablo with 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
Source File: CreditsScreen.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
@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
Source File: ShareChallenge.java    From Klooni1010 with GNU General Public License v3.0 4 votes vote down vote up
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 File: DT1.java    From riiablo with 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
Source File: LibgdxTextureAtlasWrapper.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
/** 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();
}