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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
Source File: CreditsScreen.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
private void retrieveAssets() {
	style = ui.getSkin().get(CreditScreenStyle.class);

	final Locale locale = Locale.getDefault();

	String localeFilename = MessageFormat.format("{0}_{1}.txt", CREDITS_FILENAME, locale.getLanguage());

	if (!EngineAssetManager.getInstance().assetExists(localeFilename))
		localeFilename = MessageFormat.format("{0}.txt", CREDITS_FILENAME);

	BufferedReader reader = EngineAssetManager.getInstance().getAsset(localeFilename).reader(4096, "utf-8");

	try {
		String line;
		while ((line = reader.readLine()) != null) {
			credits.add(line);
		}
	} catch (Exception e) {
		EngineLogger.error(e.getMessage());

		ui.setCurrentScreen(Screens.MENU_SCREEN);
	}

	scrollY += style.titleFont.getLineHeight();

	// Load IMAGES
	for (String s : credits) {
		if (s.indexOf('#') != -1 && s.charAt(0) == 'i') {
			s = s.substring(2);

			Texture tex = new Texture(EngineAssetManager.getInstance().getResAsset("ui/" + s));
			tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);

			images.put(s, tex);
		}
	}
}
 
Example #11
Source File: PaletteIndexedBatch.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public void setPalette(Texture palette) {
  this.palette = palette;
  if (isDrawing()) {
    flush();
    applyPalette();
  }
}
 
Example #12
Source File: Vignetting.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
/** Sets the texture with which gradient mapping will be performed. */
public void setLut (Texture texture) {
	texLut = texture;
	dolut = (texLut != null);

	if (dolut) {
		lutStep = 1f / (float)texture.getHeight();
		lutStepOffset = lutStep / 2f; // center texel
		setParams(Param.TexLUT, u_texture1);
		setParams(Param.LutStep, lutStep);
		setParams(Param.LutStepOffset, lutStepOffset).endParams();
	}
}
 
Example #13
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 #14
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 #15
Source File: Splash.java    From Skyland with MIT License 5 votes vote down vote up
@Override
public void show() {
    queueAssets();

    splashImage = new Image(new Texture(Gdx.files.internal(Textures.TEXTURE_TOXSICK_LOGO)));
    splashImage.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, Align.center);
    Skyland.STAGE.addActor(splashImage);

    addSplashAnimation();
}
 
Example #16
Source File: DebugStatistics.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
private void init (int width, int height, float updateHz) {
	// assert (width < 256 && height < 256);

	final float oneOnUpdHz = 1f / updateHz;

	PanelWidth = width;
	PanelHeight = height;
	intervalNs = (long)(1000000000L * oneOnUpdHz);

	pixels = new Pixmap(PanelWidth, PanelHeight, Format.RGBA8888);
	texture = new Texture(width, height, Format.RGBA8888);
	texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
	region = new TextureRegion(texture, 0, 0, pixels.getWidth(), pixels.getHeight());

	// create data
	dataRenderTime = new float[PanelWidth];
	dataFps = new float[PanelWidth];
	dataPhysicsTime = new float[PanelWidth];
	dataTimeAliasing = new float[PanelWidth];

	// precompute constants
	ratio_rtime = ((float)PanelHeight / 2f) * Config.Physics.TimestepHz;
	ratio_ptime = ((float)PanelHeight / 2f) * Config.Physics.TimestepHz;
	ratio_fps = ((float)PanelHeight / 2f) * oneOnUpdHz;

	reset();
}
 
Example #17
Source File: GlyphPage.java    From gdx-skineditor with Apache License 2.0 5 votes vote down vote up
/** @param pageWidth The width of the backing texture.
 * @param pageHeight The height of the backing texture. */
GlyphPage (UnicodeFont unicodeFont, int pageWidth, int pageHeight) {
	this.unicodeFont = unicodeFont;
	this.pageWidth = pageWidth;
	this.pageHeight = pageHeight;

	texture = new Texture(pageWidth, pageHeight, Format.RGBA8888);
}
 
Example #18
Source File: VfxFrameBufferRenderer.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
public void renderToFbo(Texture srcTexture, VfxFrameBuffer dstBuf) {
    srcTexture.bind(0);

    // Viewport will be set from VfxFrameBuffer#begin() method.

    dstBuf.begin();
    shader.begin();
    mesh.render(shader);
    shader.end();
    dstBuf.end();
}
 
Example #19
Source File: RunicBindingPower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public RunicBindingPower(AbstractCreature owner, int amount, boolean upgraded) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    this.upgraded = upgraded;
    updateDescription();
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #20
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 #21
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 #22
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 #23
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 #24
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 #25
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 #26
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 #27
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 #28
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 #29
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 #30
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);
}