• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 package com.badlogic.gdx.tests;
18 
19 import com.badlogic.gdx.Gdx;
20 import com.badlogic.gdx.graphics.GL20;
21 import com.badlogic.gdx.graphics.g2d.BitmapFont;
22 import com.badlogic.gdx.graphics.g2d.Sprite;
23 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
24 import com.badlogic.gdx.graphics.g2d.TextureAtlas;
25 import com.badlogic.gdx.math.Matrix4;
26 import com.badlogic.gdx.tests.utils.GdxTest;
27 
28 public class AtlasIssueTest extends GdxTest {
29 	SpriteBatch batch;
30 	Sprite sprite;
31 	TextureAtlas atlas;
32 	BitmapFont font;
33 
create()34 	public void create () {
35 		batch = new SpriteBatch();
36 		batch.setProjectionMatrix(new Matrix4().setToOrtho2D(0, 0, 855, 480));
37 		atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/"));
38 		sprite = atlas.createSprite("map");
39 		font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);
40 		Gdx.gl.glClearColor(0, 1, 0, 1);
41 	}
42 
render()43 	public void render () {
44 		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
45 		batch.begin();
46 		sprite.draw(batch);
47 		font.draw(batch, "fps:" + Gdx.graphics.getFramesPerSecond(), 26, 65);
48 		batch.end();
49 	}
50 
needsGL20()51 	public boolean needsGL20 () {
52 		return false;
53 	}
54 
55 	@Override
dispose()56 	public void dispose () {
57 		batch.dispose();
58 		atlas.dispose();
59 		font.dispose();
60 	}
61 }
62