com.badlogic.gdx.graphics.Texture Java Examples

The following examples show how to use com.badlogic.gdx.graphics.Texture. 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: PL2.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public Texture render() {
  Pixmap pl2Pixmap = new Pixmap(Palette.COLORS, size, Pixmap.Format.RGBA8888);
  ByteBuffer buffer = pl2Pixmap.getPixels();
  for (int i = 0, j = 0; i < size; i++) {
    //buffer.put(colormaps[i]);
    for (int k = 0; k < Palette.COLORS; k++, j += 4) {
      buffer.put(j, colormaps[i][k]);
    }
  }

  buffer.rewind();
  Texture texture = new Texture(pl2Pixmap);
  //texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
  texture.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);
  pl2Pixmap.dispose();
  return texture;
}
 
Example #3
Source File: MainMenu.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
public MainMenu (Invaders invaders) {
	super(invaders);

	spriteBatch = new SpriteBatch();
	background = new Texture(Gdx.files.internal("data/planet.jpg"));
	background.setFilter(TextureFilter.Linear, TextureFilter.Linear);

	logo = new Texture(Gdx.files.internal("data/title.png"));
	logo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

	font = new BitmapFont(Gdx.files.internal("data/font16.fnt"), Gdx.files.internal("data/font16.png"), false);

	if (invaders.getController() != null) {
		invaders.getController().addListener(new ControllerAdapter() {
			@Override
			public boolean buttonUp(Controller controller, int buttonIndex) {
				controller.removeListener(this);
				isDone = true;
				return false;
			}
		});
	}
}
 
Example #4
Source File: GLTFBinaryExporter.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
public void export(GLTFImage image, Texture texture, String baseName) {
	String fileName = baseName + ".png";
	image.uri = fileName;
	FileHandle file = folder.child(fileName);
	FrameBuffer fbo = new FrameBuffer(texture.getTextureData().getFormat(), texture.getWidth(), texture.getHeight(), false);
	fbo.begin();
	Gdx.gl.glClearColor(0, 0, 0, 0);
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	SpriteBatch batch = new SpriteBatch();
	batch.getProjectionMatrix().setToOrtho2D(0, 0, 1, 1);
	batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE);
	batch.begin();
	batch.draw(texture, 0, 0, 1, 1, 0, 0, 1, 1);
	batch.end();
	Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, texture.getWidth(), texture.getHeight());
	fbo.end();
	batch.dispose();
	fbo.dispose();
	savePNG(file, pixmap);
	pixmap.dispose();
}
 
Example #5
Source File: SkinLoader.java    From Klooni1010 with GNU General Public License v3.0 6 votes vote down vote up
static Skin loadSkin() {
    String folder = "ui/x" + bestMultiplier + "/";

    // Base skin
    Skin skin = new Skin(Gdx.files.internal("skin/uiskin.json"));

    // Nine patches
    final int border = (int) (28 * bestMultiplier);
    skin.add("button_up", new NinePatch(new Texture(
            Gdx.files.internal(folder + "button_up.png")), border, border, border, border));

    skin.add("button_down", new NinePatch(new Texture(
            Gdx.files.internal(folder + "button_down.png")), border, border, border, border));

    for (String id : ids) {
        skin.add(id + "_texture", new Texture(Gdx.files.internal(folder + id + ".png")));
    }

    folder = "font/x" + bestMultiplier + "/";
    skin.add("font", new BitmapFont(Gdx.files.internal(folder + "geosans-light64.fnt")));
    skin.add("font_small", new BitmapFont(Gdx.files.internal(folder + "geosans-light32.fnt")));
    skin.add("font_bonus", new BitmapFont(Gdx.files.internal(folder + "the-next-font.fnt")));

    return skin;
}
 
Example #6
Source File: DesktopLauncher.java    From skin-composer with MIT License 6 votes vote down vote up
@Override
public void packFontImages(Array<FileHandle> files, FileHandle saveFile) {
    var settings = new TexturePacker.Settings();
    settings.pot = false;
    settings.duplicatePadding = true;
    settings.filterMin = Texture.TextureFilter.Linear;
    settings.filterMag = Texture.TextureFilter.Linear;
    settings.ignoreBlankImages = false;
    settings.useIndexes = false;
    settings.limitMemory = false;
    settings.maxWidth = 2048;
    settings.maxHeight = 2048;
    settings.flattenPaths = true;
    settings.silent = true;
    var texturePacker = new TexturePacker(settings);

    for (FileHandle file : files) {
        if (file.exists()) {
            texturePacker.addImage(file.file());
        }
    }

    texturePacker.pack(saveFile.parent().file(), saveFile.nameWithoutExtension());
}
 
Example #7
Source File: Sky.java    From gdx-proto with Apache License 2.0 6 votes vote down vote up
public static void createSkyBox (Texture xpos, Texture xneg, Texture ypos, Texture yneg, Texture zpos, Texture zneg) {
	modelInstance = new ModelInstance(model, "Skycube");
	
	// Set material textures
	modelInstance.materials.get(0).set(TextureAttribute.createDiffuse(xpos));
	modelInstance.materials.get(1).set(TextureAttribute.createDiffuse(xneg));
	modelInstance.materials.get(2).set(TextureAttribute.createDiffuse(ypos));
	modelInstance.materials.get(3).set(TextureAttribute.createDiffuse(yneg));
	modelInstance.materials.get(5).set(TextureAttribute.createDiffuse(zpos));
	modelInstance.materials.get(4).set(TextureAttribute.createDiffuse(zneg));
	
	//Disable depth test
	modelInstance.materials.get(0).set(new DepthTestAttribute(0));
	modelInstance.materials.get(1).set(new DepthTestAttribute(0));
	modelInstance.materials.get(2).set(new DepthTestAttribute(0));
	modelInstance.materials.get(3).set(new DepthTestAttribute(0));
	modelInstance.materials.get(4).set(new DepthTestAttribute(0));
	modelInstance.materials.get(5).set(new DepthTestAttribute(0));
	
	enabled = true;
}
 
Example #8
Source File: NoiseImage.java    From talos with Apache License 2.0 6 votes vote down vote up
/**
 * @deprecated
 *
 * WARNING THIS IS FOR TESTING PURPOSES ONLY,
 * DO NOT USE AS THIS HAS HORRIBLE PERFORMANCE
 *
 * @param batch
 * @param parentAlpha
 */
public void drawPixmap(Batch batch, float parentAlpha) {
    SimplexNoise simplexNoise = new SimplexNoise();
    pixmap.setColor(0, 0, 0, 1f);
    pixmap.fill();
    for(int x = 0; x < 165; x++) {
        for(int y = 0; y < 100; y++) {
            float v = simplexNoise.query(x/165f, y/100f, frequency) *0.5f + 0.5f;
            pixmap.setColor(v, v, v, 1f);
            pixmap.drawPixel(x, y);
        }
    }

    Texture texture = new Texture(pixmap, Pixmap.Format.RGB888, false);
    batch.draw(texture, getX(), getY());
}
 
Example #9
Source File: SplashState.java    From Entitas-Java with MIT License 6 votes vote down vote up
@Override
public void initialize() {
    // Input
    Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera();
    Batch batch = engine.getManager(BaseSceneManager.class).getBatch();
    BitmapFont font = engine.getManager(BaseGUIManager.class).getDefaultFont();
    systems.add(new DelaySystem(context.core))
            .add(new RendererSystem(context.core, engine.sr, camera, batch, font));

    Texture texture = assetsManager.getTexture(splash);

    context.core.createEntity()
            .addTextureView("Pong", new TextureRegion(texture, 0, 0, texture.getWidth(), texture.getHeight()), new Vector2(),
                    0, Pong.SCREEN_HEIGHT, Pong.SCREEN_WIDTH)
            .addDelay(3);
}
 
Example #10
Source File: Program.java    From INFDEV02-4 with MIT License 5 votes vote down vote up
@Override
public void create() {
    this.batch = new SpriteBatch();
    this.backgroundImage = new Texture("coffee.jpg");

    GUIConstructor guiConstructor = new GUIConstructor();
    this.guiManager = guiConstructor.instantiate("1", () -> {
        Gdx.app.exit();
    });
    this.inputManager = new GDXMouse();
    this.drawingManager = new GDXDrawingAdapter(this.batch);
    this.drawVisitor = new DefaultDrawVisitor(this.drawingManager);
    this.updateVisitor = new DefaultUpdateVisitor(this.inputManager);
}
 
Example #11
Source File: VfxManager.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
/** Sets up a (captured?) source scene that will be used later as an input for effect processing.
 * Updates the effect chain src buffer with the data provided. */
public void useAsInput(Texture texture) {
    if (capturing) {
        throw new IllegalStateException("Cannot set captured input when capture helper is currently capturing.");
    }
    if (applyingEffects) {
        throw new IllegalStateException("Cannot update the input buffer when applying effects.");
    }

    context.getBufferRenderer().renderToFbo(texture, pingPongWrapper.getDstBuffer());
}
 
Example #12
Source File: ClientBlob.java    From killingspree with MIT License 5 votes vote down vote up
public ClientBlob(short id, float x, float y, WorldRenderer renderer) {
    super(id, x, y, renderer);
    markForDispose = false;
    Texture texture = AssetLoader.instance.getTexture("sprites/blob.png");
    sprite = new Sprite(texture);
    walk = new Animation(0.25f, TextureRegion.split(texture,
            texture.getWidth()/2, texture.getHeight())[0]);
    walk.setPlayMode(Animation.PlayMode.LOOP);
    sprite.setSize(ServerBlob.WIDTH + 5f, ServerBlob.HEIGHT);
    deadTimer = 2f;
}
 
Example #13
Source File: ClientFly.java    From killingspree with MIT License 5 votes vote down vote up
public ClientFly(short id, float x, float y, WorldRenderer renderer) {
    super(id, x, y, renderer);
    markForDispose = false;
    Texture texture = AssetLoader.instance.getTexture("sprites/fly.png");
    sprite = new Sprite(texture);
    walk = new Animation(0.25f, TextureRegion.split(texture,
            texture.getWidth()/2, texture.getHeight())[0]);
    walk.setPlayMode(Animation.PlayMode.LOOP);
    sprite.setSize(ServerBlob.WIDTH + 5f, ServerFly.HEIGHT);
}
 
Example #14
Source File: CocoStudioUIEditor.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
public Texture findTexture(ObjectData option, FileData fileData) {
    //显示Default
    if (fileData == null) {// 默认值不显示
        return null;
    }

    return new Texture(dirName + fileData.getPath());
}
 
Example #15
Source File: FadingTexture.java    From TerraLegion with MIT License 5 votes vote down vote up
public FadingTexture(Texture texture, float x, float y, float minAmount, float maxAmount, float subAmount, float speed, float alpha) {
	super(x, y);
	this.texture = texture;
	this.minAmount = minAmount;
	this.maxAmount = maxAmount;
	this.subAmount = subAmount;
	this.speed = speed;
	this.alpha = alpha;
}
 
Example #16
Source File: VfxFrameBufferPool.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
/** Called when a buffer is freed to clear the state of the buffer for possible later reuse. */
protected void resetBuffer(VfxFrameBuffer buffer) {
    buffer.clearRenderers();

    // Reset texture params to the default ones.
    Texture texture = buffer.getTexture();
    texture.setWrap(textureWrapU, textureWrapV);
    texture.setFilter(textureFilterMin, textureFilterMag);
}
 
Example #17
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 #18
Source File: ColorFadeTransition.java    From libgdx-transitions with Apache License 2.0 5 votes vote down vote up
/** @param color the {@link Color} to fade to
 * @param interpolation the {@link Interpolation} method */
public ColorFadeTransition (Color color, Interpolation interpolation) {
	this.color = new Color(Color.WHITE);
	this.interpolation = interpolation;

	texture = new Texture(1, 1, Format.RGBA8888);
	Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888);
	pixmap.setColor(color);
	pixmap.fillRectangle(0, 0, 1, 1);
	texture.draw(pixmap, 0, 0);
}
 
Example #19
Source File: Theme.java    From Klooni1010 with GNU General Public License v3.0 5 votes vote down vote up
public static Texture getBlankTexture() {
    final Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    final Texture result = new Texture(pixmap);
    pixmap.dispose();
    return result;
}
 
Example #20
Source File: Ssao.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
private void dbgTextureW (SpriteBatch batch, float width, Texture tex, int index) {
	if (tex == null) return;

	float h = width / ScaleUtils.RefAspect;
	float x = Config.Graphics.ReferenceScreenWidth - width - 10;
	float y = index * 10;
	batch.draw(tex, x, y, width, h);
}
 
Example #21
Source File: EnigmaPower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public EnigmaPower(AbstractCreature owner, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    this.type = AbstractPower.PowerType.BUFF;
    this.isTurnBased = false;
    this.priority = 90;
    updateDescription();
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #22
Source File: Program.java    From INFDEV02-4 with MIT License 5 votes vote down vote up
@Override
   public void create () {
this.batch = new SpriteBatch();
this.backgroundImage = new Texture("coffee.jpg");

GUIConstructor guiConstructor = new GUIConstructor();
this.guiManager = guiConstructor.instantiate("1", () -> {
           Gdx.app.exit();
       });
       this.inputManager = new GDXMouse();
       this.drawingManager = new GDXDrawingAdapter(this.batch);
       this.drawVisitor = new DefaultDrawVisitor(this.drawingManager);
       this.updateVisitor = new DefaultUpdateVisitor(this.inputManager);
   }
 
Example #23
Source File: ArcanospherePower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public ArcanospherePower(AbstractCreature owner, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    this.updateDescription();
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #24
Source File: Program.java    From INFDEV02-4 with MIT License 5 votes vote down vote up
@Override
public void create() {
    this.batch = new SpriteBatch();
    this.backgroundImage = new Texture("coffee.jpg");

    this.guiManager = new GUIManager(() -> {
        Gdx.app.exit();
    });
    this.drawingManager = new GDXDrawingAdapter(this.batch);
    this.drawVisitor = new DefaultDrawVisitor(this.drawingManager);
    this.inputManager = new GDXMouse();
    this.updateVisitor = new DefaultUpdateVisitor(this.inputManager);
}
 
Example #25
Source File: PaletteIndexedBatch.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public void setColormap(Texture colormap, int id) {
  if (id == 0 || colormap == null) {
    resetColormap();
    return;
  }

  this.colormap = colormap;
  this.colormapId = id;
  if (isDrawing()) {
    flush();
    applyColormap();
  }
}
 
Example #26
Source File: BGDrawer.java    From libGDX-Path-Editor with Apache License 2.0 5 votes vote down vote up
public BGDrawer() {
	renderer = new ShapeRenderer();
	
	Pixmap p = new Pixmap(4, 4, Format.RGBA4444);
	p.setColor(0.698f, 0.698f, 0.698f, 1f);
	p.fill();
	overlay = new Texture(p);
	p.dispose();
	
	t = new Sprite(overlay);
	b = new Sprite(overlay);
	l = new Sprite(overlay);
	r = new Sprite(overlay);
}
 
Example #27
Source File: SplashScreen.java    From libgdx-utils with MIT License 5 votes vote down vote up
@Override
public void show() {
	LibgdxUtils.assets.load("textures/splash.png", Texture.class);
	LibgdxUtils.assets.finishLoading();
	splash = LibgdxUtils.assets.get("textures/splash.png", Texture.class);

	LibgdxUtils.assets.load("skins/uiskin.json", Skin.class);
	LibgdxUtils.assets.load("icons/icons.atlas", TextureAtlas.class);

	camera = new OrthographicCamera();
	viewport = new FitViewport(splash.getWidth(), splash.getHeight(), camera);
}
 
Example #28
Source File: GLTFDemoUI.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public void setImage(Texture texture){
	if(texture != null){
		Image img = new Image(texture);
		img.setScaling(Scaling.fit);
		screenshotsTable.add(img).height(100);
	}
}
 
Example #29
Source File: GLTFExample.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	
	// create scene
	sceneAsset = new GLTFLoader().load(Gdx.files.internal("models/BoomBox/glTF/BoomBox.gltf"));
	scene = new Scene(sceneAsset.scene);
	sceneManager = new SceneManager();
	sceneManager.addScene(scene);
	
	// setup camera
	camera = new PerspectiveCamera(60f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	float d = .02f;
	camera.near = d / 1000f;
	camera.far = d * 4;
	sceneManager.setCamera(camera);
	
	// setup IBL (image based lighting)
	environmentCubemap = EnvironmentUtil.createCubemap(new InternalFileHandleResolver(), 
			"textures/environment/environment_", "_0.png", EnvironmentUtil.FACE_NAMES_FULL);
	diffuseCubemap = EnvironmentUtil.createCubemap(new InternalFileHandleResolver(), 
			"textures/diffuse/diffuse_", "_0.jpg", EnvironmentUtil.FACE_NAMES_FULL);
	specularCubemap = EnvironmentUtil.createCubemap(new InternalFileHandleResolver(), 
			"textures/specular/specular_", "_", ".jpg", 10, EnvironmentUtil.FACE_NAMES_FULL);
	brdfLUT = new Texture(Gdx.files.classpath("net/mgsx/gltf/shaders/brdfLUT.png"));
	
	sceneManager.setAmbientLight(1f);
	sceneManager.environment.set(new PBRTextureAttribute(PBRTextureAttribute.BRDFLUTTexture, brdfLUT));
	sceneManager.environment.set(PBRCubemapAttribute.createSpecularEnv(specularCubemap));
	sceneManager.environment.set(PBRCubemapAttribute.createDiffuseEnv(diffuseCubemap));
	
	// setup skybox
	skybox = new SceneSkybox(environmentCubemap);
	sceneManager.setSkyBox(skybox);
}
 
Example #30
Source File: FadingTexture.java    From TerraLegion with MIT License 5 votes vote down vote up
public FadingTexture(Texture texture, float x, float y, float minAmount, float maxAmount, float subAmount, float speed) {
	super(x, y);
	this.texture = texture;
	this.minAmount = minAmount;
	this.maxAmount = maxAmount;
	this.subAmount = subAmount;
	this.speed = speed;
	alpha = 1f;
}