OSDN Git Service

301e927ba978830234e04494ce7446fd6a2e16ff
[mikumikustudio/libgdx-mikumikustudio.git] / tests / gdx-tests / src / com / badlogic / gdx / tests / PixelPerfectTest.java
1 package com.badlogic.gdx.tests;
2
3 import com.badlogic.gdx.Gdx;
4 import com.badlogic.gdx.graphics.Color;
5 import com.badlogic.gdx.graphics.GL20;
6 import com.badlogic.gdx.graphics.OrthographicCamera;
7 import com.badlogic.gdx.graphics.Pixmap;
8 import com.badlogic.gdx.graphics.Texture;
9 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
10 import com.badlogic.gdx.tests.utils.GdxTest;
11
12 public class PixelPerfectTest extends GdxTest {
13         SpriteBatch batch;
14         OrthographicCamera cam;
15         Texture tex;
16
17         @Override
18         public void create () {
19                 Pixmap pixmap = new Pixmap(16, 16, Pixmap.Format.RGBA8888);
20                 pixmap.setColor(Color.BLUE);
21                 pixmap.fill();
22                 pixmap.setColor(Color.RED);
23                 pixmap.drawLine(0, 0, 15, 15);
24                 pixmap.drawLine(0, 15, 15, 0);
25                 
26                 tex = new Texture(pixmap);
27                 batch = new SpriteBatch();
28                 cam = new OrthographicCamera();
29                 cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
30         }
31
32         @Override
33         public void resize (int width, int height) {
34                 cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
35         }
36
37         @Override
38         public void render () {
39                 Gdx.gl.glClearColor(1, 0, 1, 1);
40                 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
41                 cam.update();
42                 batch.setProjectionMatrix(cam.combined);
43                 batch.begin();
44                 batch.draw(tex, 1, 1);
45                 batch.end();
46         }
47 }