• 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.files.FileHandle;
21 import com.badlogic.gdx.graphics.GL20;
22 import com.badlogic.gdx.graphics.Pixmap.Format;
23 import com.badlogic.gdx.graphics.Texture;
24 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
25 import com.badlogic.gdx.tests.utils.GdxTest;
26 
27 public class TextureFormatTest extends GdxTest {
28 
29 	Texture[] nonMipMapped = new Texture[6];
30 	Texture[] mipMapped = new Texture[6];
31 	SpriteBatch batch;
32 
33 	@Override
create()34 	public void create () {
35 		FileHandle file = Gdx.files.internal("data/bobargb8888-32x32.png");
36 		nonMipMapped[0] = new Texture(file, Format.Alpha, false);
37 		nonMipMapped[1] = new Texture(file, Format.LuminanceAlpha, false);
38 		nonMipMapped[2] = new Texture(file, Format.RGB888, false);
39 		nonMipMapped[3] = new Texture(file, Format.RGB565, false);
40 		nonMipMapped[4] = new Texture(file, Format.RGBA8888, false);
41 		nonMipMapped[5] = new Texture(file, Format.RGBA4444, false);
42 
43 		mipMapped[0] = new Texture(file, Format.Alpha, true);
44 		mipMapped[1] = new Texture(file, Format.LuminanceAlpha, true);
45 		mipMapped[2] = new Texture(file, Format.RGB888, true);
46 		mipMapped[3] = new Texture(file, Format.RGB565, true);
47 		mipMapped[4] = new Texture(file, Format.RGBA8888, true);
48 		mipMapped[5] = new Texture(file, Format.RGBA4444, true);
49 
50 		batch = new SpriteBatch();
51 	}
52 
53 	@Override
render()54 	public void render () {
55 		Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
56 		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
57 		batch.begin();
58 		for (int i = 0; i < 6; i++) {
59 			batch.draw(nonMipMapped[i], i * 32, 0);
60 		}
61 		for (int i = 0; i < 6; i++) {
62 			batch.draw(mipMapped[i], i * 32, 32);
63 		}
64 		batch.end();
65 	}
66 }
67