2 package com.badlogic.gdx.tests.lwjgl;
4 import com.badlogic.gdx.ApplicationAdapter;
5 import com.badlogic.gdx.Gdx;
6 import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
7 import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
8 import com.badlogic.gdx.graphics.Color;
9 import com.badlogic.gdx.graphics.GL10;
10 import com.badlogic.gdx.graphics.Pixmap;
11 import com.badlogic.gdx.graphics.Pixmap.Format;
12 import com.badlogic.gdx.graphics.Texture;
13 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
14 import com.badlogic.gdx.graphics.g2d.TextureRegion;
15 import com.badlogic.gdx.utils.ScreenUtils;
17 public class Test2 extends ApplicationAdapter {
24 public void create () {
26 batch = new SpriteBatch();
27 Pixmap p = new Pixmap(64, 64, Format.RGBA8888);
28 p.setColor(Color.RED);
29 p.fillRectangle(32, 32, size , size );
30 region = new TextureRegion(new Texture(p), 32, 32, 1 , 1);
32 Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
33 Gdx.gl.glClearColor(0, 0, 0, 1);
35 batch.draw(region, 1, 1, 256, 256);
38 screenCap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
39 screenCapTex = new Texture(screenCap);
40 System.out.println("size: " + size);
41 System.out.println(Integer.toHexString(screenCap.getPixel(0, 0)));
42 System.out.println(Integer.toHexString(screenCap.getPixel(1, 1)));
43 System.out.println(Integer.toHexString(screenCap.getPixel(256, 256)));
44 System.out.println(Integer.toHexString(screenCap.getPixel(257, 257)));
47 public void render () {
48 Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
49 Gdx.gl.glClearColor(0, 0, 0, 1);
51 batch.draw(screenCapTex, 0, 0);
55 public static void main (String[] args) {
56 LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
57 config.useGL20 = true;
58 new LwjglApplication(new Test2(), config);