public void setStyle (LabelStyle style) { if (style == null) throw new IllegalArgumentException("style cannot be null."); if (style.font == null) throw new IllegalArgumentException("Missing LabelStyle font."); this.style = style; cache = style.font.newFontCache(); invalidateHierarchy(); }
public void setStyle (LabelStyle style) { if (style == null) throw new IllegalArgumentException("style cannot be null."); if (style.font == null) throw new IllegalArgumentException("Missing LabelStyle font."); this.style = style; cache = style.font.newFontCache(); invalidateHierarchy(); }
@Override public void create () { Gdx.input.setInputProcessor(new InputAdapter() { public boolean touchDown (int x, int y, int pointer, int newParam) { renderMode = (renderMode + 1) % 4; return false; } }); spriteBatch = new SpriteBatch(); spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1)); texture = new Texture(Gdx.files.internal("data/badlogic.jpg")); logoSprite = new Sprite(texture); logoSprite.flip(false, true); logoSprite.setPosition(0, 320 - 256); logoSprite.setColor(1, 1, 1, 0.5f); font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), Gdx.files.internal("data/verdana39.png"), true); cache1 = font.newFontCache(); cache2 = font.newFontCache(); cache3 = font.newFontCache(); cache4 = font.newFontCache(); cache5 = font.newFontCache(); createCaches("cached", cache1, cache2, cache3, cache4, cache5); font.getData().setScale(1.33f); cacheScaled1 = font.newFontCache(); cacheScaled2 = font.newFontCache(); cacheScaled3 = font.newFontCache(); cacheScaled4 = font.newFontCache(); cacheScaled5 = font.newFontCache(); createCaches("cache scaled", cacheScaled1, cacheScaled2, cacheScaled3, cacheScaled4, cacheScaled5); }
/** Constructs a new BitmapFont from the given {@link BitmapFontData} and array of {@link TextureRegion}. If the TextureRegion * is null or empty, the image path(s) will be read from the BitmapFontData. The dispose() method will not dispose the texture * of the region(s) if the regions array is != null and not empty. * @param integer If true, rendering positions will be at integer values to avoid filtering artifacts. */ public BitmapFont (BitmapFontData data, Array<TextureRegion> pageRegions, boolean integer) { this.flipped = data.flipped; this.data = data; this.integer = integer; if (pageRegions == null || pageRegions.size == 0) { if (data.imagePaths == null) throw new IllegalArgumentException("If no regions are specified, the font data must have an images path."); // Load each path. int n = data.imagePaths.length; regions = new Array(n); for (int i = 0; i < n; i++) { FileHandle file; if (data.fontFile == null) file = Gdx.files.internal(data.imagePaths[i]); else file = Gdx.files.getFileHandle(data.imagePaths[i], data.fontFile.type()); regions.add(new TextureRegion(new Texture(file, false))); } ownsTexture = true; } else { regions = pageRegions; ownsTexture = false; } cache = newFontCache(); load(data); }
/** Constructs a new BitmapFont from the given {@link BitmapFontData} and array of {@link TextureRegion}. If the TextureRegion * is null or empty, the image path(s) will be read from the BitmapFontData. The dispose() method will not dispose the texture * of the region(s) if the regions array is != null and not empty. * @param integer If true, rendering positions will be at integer values to avoid filtering artifacts. */ public BitmapFont (BitmapFontData data, Array<TextureRegion> pageRegions, boolean integer) { this.flipped = data.flipped; this.data = data; this.integer = integer; if (pageRegions == null || pageRegions.size == 0) { if (data.imagePaths == null) throw new IllegalArgumentException("If no regions are specified, the font data must have an images path."); // Load each path. int n = data.imagePaths.length; regions = new Array(n); for (int i = 0; i < n; i++) { FileHandle file; if (data.fontFile == null) file = Gdx.files.internal(data.imagePaths[i]); else file = Gdx.files.getFileHandle(data.imagePaths[i], data.fontFile.type()); regions.add(new TextureRegion(new Texture(file, false))); } ownsTexture = true; } else { regions = pageRegions; ownsTexture = false; } cache = newFontCache(); load(data); }
public void setRenderType (RenderType renderType) { this.renderType = renderType; if (renderType != RenderType.FreeType) { if (bitmapFont != null) { bitmapFont.dispose(); generator.dispose(); } } else { String fontFile = getFontFile(); if (fontFile != null) { generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontFile)); FreeTypeFontParameter param = new FreeTypeFontParameter(); param.size = font.getSize(); param.incremental = true; param.flip = true; param.mono = mono; param.gamma = gamma; bitmapFont = generator.generateFont(param); if (bitmapFont.getData().missingGlyph == null) bitmapFont.getData().missingGlyph = bitmapFont.getData().getGlyph('\ufffd'); cache = bitmapFont.newFontCache(); layout = new GlyphLayout(); } } }
public void setRenderType (RenderType renderType) { this.renderType = renderType; if (renderType != RenderType.FreeType) { if (bitmapFont != null) { bitmapFont.dispose(); generator.dispose(); } } else { String fontFile = getFontFile(); if (fontFile != null) { generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontFile)); FreeTypeFontParameter param = new FreeTypeFontParameter(); param.size = font.getSize(); param.incremental = true; param.flip = true; param.mono = mono; param.gamma = gamma; bitmapFont = generator.generateFont(param); if (bitmapFont.getData().missingGlyph == null) bitmapFont.getData().missingGlyph = bitmapFont.getData().getGlyph('\ufffd'); cache = bitmapFont.newFontCache(); layout = new GlyphLayout(); } } }
@Override public void create () { Gdx.input.setInputProcessor(new InputAdapter() { public boolean touchDown (int x, int y, int pointer, int newParam) { renderMode = (renderMode + 1) % 6; return false; } }); spriteBatch = new SpriteBatch(); texture = new Texture(Gdx.files.internal("data/badlogic.jpg")); logoSprite = new Sprite(texture); logoSprite.setColor(1, 1, 1, 0.6f); logoSprite.setBounds(50, 100, 400, 100); font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle( "data/verdana39.png", FileType.Internal), false); cache = font.newFontCache(); layout = new GlyphLayout(); }
@Override public void create () { Preferences pref = Gdx.app.getPreferences("test"); boolean resultb = pref.getBoolean("test"); int resulti = pref.getInteger("test"); shader = new ShaderProgram(Gdx.files.internal("data/shaders/shader-vs.glsl"), Gdx.files.internal("data/shaders/shader-fs.glsl")); if (!shader.isCompiled()) throw new GdxRuntimeException(shader.getLog()); mesh = new Mesh(VertexDataType.VertexBufferObject, true, 6, 0, VertexAttribute.Position(), VertexAttribute.TexCoords(0)); mesh.setVertices(new float[] {-0.5f, -0.5f, 0, 0, 1, 0.5f, -0.5f, 0, 1, 1, 0.5f, 0.5f, 0, 1, 0, 0.5f, 0.5f, 0, 1, 0, -0.5f, 0.5f, 0, 0, 0, -0.5f, -0.5f, 0, 0, 1}); texture = new Texture(new Pixmap(Gdx.files.internal("data/badlogic.jpg")), true); texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); String params = Gdx.files.internal("data/gwttestparams.txt").readString(); numSprites = Integer.parseInt(params); batch = new SpriteBatch(); positions = new ArrayList<Vector2>(); for (int i = 0; i < numSprites; i++) { positions.add(new Vector2(MathUtils.random() * Gdx.graphics.getWidth(), MathUtils.random() * Gdx.graphics.getHeight())); } sprite = new Sprite(texture); sprite.setSize(64, 64); sprite.setOrigin(32, 32); font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false); cache = font.newFontCache(); cache.setColor(Color.RED); cache.setText("This is a Test", 0, 0); atlas = new TextureAtlas(Gdx.files.internal("data/pack")); }
public void setStyle (LabelStyle style) { if (style == null) throw new IllegalArgumentException("style cannot be null."); if (style.font == null) throw new IllegalArgumentException("Missing LabelStyle font."); this.style = style; cache = style.font.newFontCache(); invalidateHierarchy(); }
@Override public void init() { initted = true; frustum = game.getCamera().frustum; debugTextRenderer = new BitmapFont(); fpsRender = debugTextRenderer.newFontCache(); awrtRender = debugTextRenderer.newFontCache(); glInfoRender = debugTextRenderer.newFontCache(); positionRender = debugTextRenderer.newFontCache(); headingRender = debugTextRenderer.newFontCache(); chunkposRender = debugTextRenderer.newFontCache(); lightlevelRender = debugTextRenderer.newFontCache(); activeThreadsRender = debugTextRenderer.newFontCache(); selectedBlockRender = debugTextRenderer.newFontCache(); glDebugRender = debugTextRenderer.newFontCache(); blockOverlayBatch = new ModelBatch(Gdx.files.internal("shaders/gdx/world.vert.glsl"), Gdx.files.internal("shaders/gdx/world.frag.glsl")); entityBatch = new ModelBatch(Gdx.files.internal("shaders/gdx/world.vert.glsl"), Gdx.files.internal("shaders/gdx/world.frag.glsl")); String destroyStageFmt = "textures/block/overlay/destroy_stage_%d.png"; for (int stage = 0; stage < 10; stage++) { blockBreakStages[stage] = new Texture(Gdx.files.internal(String.format(destroyStageFmt, stage))); } }
public ChatGUI() { font = new BitmapFont(); fontCache = font.newFontCache(); chatBackground = new Texture(Gdx.files.internal("textures/gui/chatbackground.png")); }
public void setRenderType (RenderType renderType) { this.renderType = renderType; if (renderType != RenderType.FreeType) { if (bitmapFont != null) { bitmapFont.dispose(); generator.dispose(); } } else { String fontFile = getFontFile(); if (fontFile != null) { generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontFile)); FreeTypeFontParameter param = new FreeTypeFontParameter(); param.size = font.getSize(); param.incremental = true; param.flip = true; param.mono = mono; param.gamma = gamma; bitmapFont = generator.generateFont(param); if (bitmapFont.getData().missingGlyph == null) bitmapFont.getData().missingGlyph = bitmapFont.getData().getGlyph('\ufffd'); cache = bitmapFont.newFontCache(); layout = new GlyphLayout(); } } }
/** Constructs a new BitmapFont from the given {@link BitmapFontData} and array of {@link TextureRegion}. If the TextureRegion * is null or empty, the image path(s) will be read from the BitmapFontData. The dispose() method will not dispose the texture * of the region(s) if the regions array is != null and not empty. * @param integer If true, rendering positions will be at integer values to avoid filtering artifacts. */ public BitmapFont (BitmapFontData data, Array<TextureRegion> pageRegions, boolean integer) { this.flipped = data.flipped; this.data = data; this.integer = integer; if (pageRegions == null || pageRegions.size == 0) { // Load each path. int n = data.imagePaths.length; regions = new Array(n); for (int i = 0; i < n; i++) { FileHandle file; if (data.fontFile == null) file = Gdx.files.internal(data.imagePaths[i]); else file = Gdx.files.getFileHandle(data.imagePaths[i], data.fontFile.type()); regions.add(new TextureRegion(new Texture(file, false))); } ownsTexture = true; } else { regions = pageRegions; ownsTexture = false; } cache = newFontCache(); load(data); }