OSDN Git Service

pixmap screencap is now y-up
authorbadlogic <badlogicgames@gmail.com>
Sun, 6 Oct 2013 14:39:20 +0000 (16:39 +0200)
committerbadlogic <badlogicgames@gmail.com>
Sun, 6 Oct 2013 14:39:20 +0000 (16:39 +0200)
gdx/src/com/badlogic/gdx/utils/ScreenUtils.java
tests/gdx-tests-lwjgl/src/com/badlogic/gdx/tests/lwjgl/Test2.java

index fce4228..286c7df 100644 (file)
@@ -73,9 +73,7 @@ public class ScreenUtils {
 \r
                final Pixmap pixmap = new Pixmap(w, h, Format.RGBA8888);\r
                ByteBuffer pixels = pixmap.getPixels();\r
-               byte[] bytes = getFrameBufferPixels(true);\r
-               pixels.put(bytes);\r
-               pixels.flip();\r
+               Gdx.gl.glReadPixels(x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixels);\r
 \r
                return pixmap;\r
        }\r
index cd3eddf..03c8aa5 100644 (file)
@@ -19,15 +19,15 @@ public class Test2 extends ApplicationAdapter {
        TextureRegion region;
        Pixmap screenCap;
        Texture screenCapTex;
+       private int size = 2;
 
        public void create () {
-               int size =1;
 
                batch = new SpriteBatch();
                Pixmap p = new Pixmap(64, 64, Format.RGBA8888);
                p.setColor(Color.RED);
-               p.fillRectangle(32, 32, size, size);
-               region = new TextureRegion(new Texture(p), 32, 32, size, size);
+               p.fillRectangle(32, 32, size , size );
+               region = new TextureRegion(new Texture(p), 32, 32, size , size );
 
                Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
                Gdx.gl.glClearColor(0, 0, 0, 1);
@@ -36,6 +36,7 @@ public class Test2 extends ApplicationAdapter {
                batch.end();
                screenCap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
                screenCapTex = new Texture(screenCap);
+               System.out.println("size: " + size);
                System.out.println(Integer.toHexString(screenCap.getPixel(0, 0)));
                System.out.println(Integer.toHexString(screenCap.getPixel(1, 1)));
                System.out.println(Integer.toHexString(screenCap.getPixel(256, 256)));