OSDN Git Service

(no commit message)
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Wed, 26 Jan 2011 17:21:11 +0000 (17:21 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Wed, 26 Jan 2011 17:21:11 +0000 (17:21 +0000)
gdx/jni/gdx2d/gdx2d.c
gdx/src/com/badlogic/gdx/graphics/g2d/Gdx2DPixmap.java
tests/gdx-tests-jogl/src/com/badlogic/gdx/tests/jogl/JoglDebugStarter.java
tests/gdx-tests/src/com/badlogic/gdx/tests/Gdx2DTest.java

index 412be0a..f794b64 100644 (file)
@@ -57,11 +57,11 @@ inline uint32_t to_format(uint32_t format, uint32_t color) {
                        return color & 0xff;\r
                case GDX2D_FORMAT_LUMINANCE_ALPHA: \r
                        r = (color & 0xff000000) >> 24;\r
-                       g = (color & 0xff000000) >> 16;\r
-                       b = (color & 0xff000000) >> 8;\r
+                       g = (color & 0xff0000) >> 16;\r
+                       b = (color & 0xff00) >> 8;\r
                        a = (color & 0xff);\r
                        l = ((uint32_t)(0.2126f * r + 0.7152 * g + 0.0722 * b) & 0xff) << 8;\r
-                       return l | a;\r
+                       return (l & 0xffffff00) | a;\r
                case GDX2D_FORMAT_RGB888:\r
                        return color >> 8;\r
                case GDX2D_FORMAT_RGBA8888:\r
@@ -101,7 +101,7 @@ inline uint32_t to_RGBA8888(uint32_t format, uint32_t color) {
 \r
        switch(format) {\r
                case GDX2D_FORMAT_ALPHA: \r
-                       return (color & 0xff) | (color & 0xff) << 8 | ((color & 0xff) << 16) | ((color & 0xff) << 24);\r
+                       return (color & 0xff) | 0xffffff00;\r
                case GDX2D_FORMAT_LUMINANCE_ALPHA: \r
                        return ((color & 0xff00) << 16) | ((color & 0xff00) << 8) | (color & 0xffff);\r
                case GDX2D_FORMAT_RGB888:\r
@@ -388,7 +388,7 @@ inline int32_t in_pixmap(const gdx2d_pixmap* pixmap, int32_t x, int32_t y) {
 \r
 inline void set_pixel(unsigned char* pixels, uint32_t width, uint32_t height, uint32_t bpp, set_pixel_func pixel_func, int32_t x, int32_t y, uint32_t col) {\r
        if(x < 0 || y < 0) return;\r
-       if(x >= width || y >= height) return;\r
+       if(x >= (int32_t)width || y >= (int32_t)height) return;\r
        pixels = pixels + (x + height * y) * bpp;\r
        pixel_func(pixels, col);\r
 }\r
@@ -432,7 +432,8 @@ void gdx2d_draw_line(const gdx2d_pixmap* pixmap, int32_t x0, int32_t y0, int32_t
     if(gdx2d_blend) {\r
        col_format = to_format(pixmap->format, blend(col, to_RGBA8888(pixmap->format, pget(addr))));\r
     }\r
-       pset(addr, col_format);\r
+    if(in_pixmap(pixmap, x0, y0))\r
+       pset(addr, col_format);\r
     if (dx > dy) {\r
         fraction = dy - (dx >> 1);\r
         while (x0 != x1) {\r
@@ -478,7 +479,7 @@ inline void hline(const gdx2d_pixmap* pixmap, int32_t x1, int32_t x2, int32_t y,
        uint32_t bpp = bytes_per_pixel(pixmap->format);\r
        uint32_t col_format = to_format(pixmap->format, col);\r
 \r
-       if(y < 0 || y >= pixmap->height) return;\r
+       if(y < 0 || y >= (int32_t)pixmap->height) return;\r
 \r
        if(x1 > x2) {\r
                tmp = x1;\r
@@ -486,11 +487,11 @@ inline void hline(const gdx2d_pixmap* pixmap, int32_t x1, int32_t x2, int32_t y,
                x2 = tmp;\r
        }\r
 \r
-       if(x1 >= pixmap->width) return;\r
-       if(x2 < 0) return;\r
+       if(x1 >= (int32_t)pixmap->width) return;\r
+       if(x2 < 0)  return;\r
 \r
        if(x1 < 0) x1 = 0;\r
-       if(x2 >= pixmap->width) x2 = pixmap->width - 1; \r
+       if(x2 >= (int32_t)pixmap->width) x2 = pixmap->width - 1;\r
        x2 += 1;\r
        \r
        ptr += (x1 + y * pixmap->width) * bpp;\r
@@ -522,11 +523,11 @@ inline void vline(const gdx2d_pixmap* pixmap, int32_t y1, int32_t y2, int32_t x,
                y2 = tmp;\r
        }\r
 \r
-       if(y1 >= pixmap->height) return;\r
+       if(y1 >= (int32_t)pixmap->height) return;\r
        if(y2 < 0) return;\r
 \r
        if(y1 < 0) y1 = 0;\r
-       if(y2 >= pixmap->height) y2 = pixmap->height - 1;       \r
+       if(y2 >= (int32_t)pixmap->height) y2 = pixmap->height - 1;\r
        y2 += 1;\r
 \r
        ptr += (x + y1 * pixmap->width) * bpp;\r
@@ -601,15 +602,15 @@ void gdx2d_fill_rect(const gdx2d_pixmap* pixmap, int32_t x, int32_t y, uint32_t
        int32_t x2 = x + width - 1;\r
        int32_t y2 = y + height - 1;\r
 \r
-       if(x >= pixmap->width) return;\r
-       if(y >= pixmap->height) return;\r
+       if(x >= (int32_t)pixmap->width) return;\r
+       if(y >= (int32_t)pixmap->height) return;\r
        if(x2 < 0) return;\r
        if(y2 < 0) return;\r
 \r
        if(x < 0) x = 0;\r
        if(y < 0) y = 0;\r
-       if(x2 >= pixmap->width) x2 = pixmap->width - 1;\r
-       if(y2 >= pixmap->height) y2 = pixmap->height - 1;\r
+       if(x2 >= (int32_t)pixmap->width) x2 = pixmap->width - 1;\r
+       if(y2 >= (int32_t)pixmap->height) y2 = pixmap->height - 1;\r
 \r
        y2++;\r
        while(y!=y2) {\r
index 5b8bf4c..43e18c7 100644 (file)
@@ -36,12 +36,20 @@ public class Gdx2DPixmap {
        public static final int GDX2D_SCALE_NEAREST = 0;\r
        public static final int GDX2D_SCALE_LINEAR = 1;\r
        \r
+       public static final int GDX2D_BLEND_NONE = 0;\r
+       public static final int GDX2D_BLEND_SRC_OVER = 1;\r
+       \r
        final long basePtr;\r
        final int width;\r
        final int height;\r
        final int format;       \r
        final ByteBuffer pixelPtr;\r
-       static final long[] nativeData = new long[4];\r
+       static final long[] nativeData = new long[4]; \r
+       \r
+       static {\r
+               setBlend(GDX2D_BLEND_SRC_OVER);\r
+               setScale(GDX2D_SCALE_LINEAR);\r
+       }\r
        \r
        public Gdx2DPixmap(InputStream in, int requestedFormat) throws IOException {\r
                ByteArrayOutputStream bytes = new ByteArrayOutputStream();\r
index e77305b..7b3feef 100644 (file)
@@ -18,6 +18,6 @@ import com.badlogic.gdx.backends.jogl.JoglApplication;
 public class JoglDebugStarter {\r
 \r
        public static void main (String[] argv) {\r
-               new JoglApplication(new com.badlogic.gdx.tests.Gdx2DTest(), "Debug Test", 280, 100, false);\r
+               new JoglApplication(new com.badlogic.gdx.tests.Gdx2DTest(), "Debug Test", 480, 320, false);\r
        }\r
 }\r
index 27dd353..1132bd7 100644 (file)
@@ -20,11 +20,7 @@ import com.badlogic.gdx.tests.utils.GdxTest;
 \r
 public class Gdx2DTest extends GdxTest {       \r
        SpriteBatch batch;\r
-       List<Sprite> sprites;   \r
-       \r
-       Gdx2DPixmap createPixmap(int width, int height, int format) {\r
-               return Gdx2DPixmap.newPixmap(width, height, format);\r
-       }\r
+       List<Sprite> sprites;           \r
        \r
        Texture textureFromPixmap(Gdx2DPixmap pixmap) {\r
                Texture texture = Gdx.graphics.newUnmanagedTexture(pixmap.getWidth(), pixmap.getHeight(), Format.RGB565, TextureFilter.Nearest, TextureFilter.Nearest, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
@@ -34,158 +30,109 @@ public class Gdx2DTest extends GdxTest {
                return texture;\r
        }\r
        \r
-       @Override public void create () {       \r
-               batch = new SpriteBatch();\r
-               sprites = new ArrayList<Sprite>();\r
-               Gdx2DPixmap alpha = createPixmap(32, 32, Gdx2DPixmap.GDX2D_FORMAT_ALPHA);                               \r
-               Gdx2DPixmap luminanceAlpha = createPixmap(32, 32, Gdx2DPixmap.GDX2D_FORMAT_LUMINANCE_ALPHA);                                    \r
-               Gdx2DPixmap rgb565 = createPixmap(32, 32, Gdx2DPixmap.GDX2D_FORMAT_RGB565);\r
-               Gdx2DPixmap rgba4444 = createPixmap(32, 32, Gdx2DPixmap.GDX2D_FORMAT_RGBA4444);         \r
-               Gdx2DPixmap rgb888 = createPixmap(32, 32, Gdx2DPixmap.GDX2D_FORMAT_RGB888);             \r
-               Gdx2DPixmap rgba8888 = createPixmap(32, 32, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888);\r
-               Gdx2DPixmap composite = createPixmap(256, 64, Gdx2DPixmap.GDX2D_FORMAT_RGB565);\r
-               \r
-               Gdx2DPixmap.setBlend(1);\r
-               \r
-               alpha.clear(Color.rgba8888(1, 1, 1, 0.1f));\r
-               alpha.setPixel(16, 16, Color.rgba8888(1, 1, 1, 1));             \r
-//             if(alpha.getPixel(16, 16) != Color.rgba8888(1, 1, 1, 1f)) throw new RuntimeException("alpha error");\r
-//             if(alpha.getPixel(15, 16) != Color.rgba8888(1, 1, 1, 0.1f)) throw new RuntimeException("alpha error");\r
-               alpha.drawLine(0, 0, 31, 31, Color.rgba8888(1, 1, 1, 1));\r
-               alpha.drawRect(10, 10, 5, 7, Color.rgba8888(1, 1, 1, 0.5f));            \r
-               alpha.fillRect(20, 10, 5, 7, Color.rgba8888(1, 1, 1, 0.5f));\r
-               alpha.drawCircle(16, 16, 10, Color.rgba8888(1, 1, 1, 1));\r
-               alpha.fillCircle(16, 16, 6, Color.rgba8888(1, 1, 1, 1));\r
-               \r
-               luminanceAlpha.clear(Color.rgba8888(1, 1, 1, 0.1f));\r
-               luminanceAlpha.setPixel(16, 16, Color.rgba8888(1, 1, 1.0f, 1.0f));\r
-//             if(luminanceAlpha.getPixel(16, 16) != Color.rgba8888(1, 1, 1, 1)) throw new RuntimeException("luminance alpha error");\r
-//             if(luminanceAlpha.getPixel(15, 16) != Color.rgba8888(1, 1, 1, 0.1f)) throw new RuntimeException("luminance alpha error");\r
-               luminanceAlpha.drawLine(0, 0, 31, 31, Color.rgba8888(1, 1, 1, 1));\r
-               luminanceAlpha.drawRect(10, 10, 5, 7, Color.rgba8888(1, 1, 1, 0.5f));\r
-               luminanceAlpha.fillRect(20, 10, 5, 7, Color.rgba8888(1, 1, 1, 0.5f));\r
-               luminanceAlpha.drawCircle(16, 16, 10, Color.rgba8888(1, 1, 1, 1));\r
-               luminanceAlpha.fillCircle(16, 16, 6, Color.rgba8888(1, 1, 1, 1));\r
-               \r
-               rgb565.clear(Color.rgba8888(1, 0, 0, 1));\r
-               rgb565.setPixel(16, 16, Color.rgba8888(0, 0, 1, 1));\r
-//             if(rgb565.getPixel(16, 16) != Color.rgba8888(0, 0, 1, 1)) throw new RuntimeException("rgb565 error");\r
-//             if(rgb565.getPixel(31, 31) != Color.rgba8888(1, 0, 0, 1)) throw new RuntimeException("rgb565 error");\r
-               rgb565.drawLine(0,0,32,32, Color.rgba8888(0, 1, 0, 1));\r
-               rgb565.drawRect(10, 10, 5, 7, Color.rgba8888(1, 1, 0, 0.5f));\r
-               rgb565.fillRect(20, 10, 5, 7, Color.rgba8888(0, 1, 1, 0.5f));\r
-               rgb565.drawCircle(16, 16, 10, Color.rgba8888(1, 0, 1, 1));\r
-               rgb565.fillCircle(16, 16, 6, Color.rgba8888(1, 0, 1, 1));\r
+       void drawToPixmap(Gdx2DPixmap pixmap) {\r
+               pixmap.clear(Color.rgba8888(1, 0, 0, 0.1f));\r
+               pixmap.setPixel(16, 16, Color.rgba8888(0, 0, 1, 1));\r
+               int clearColor = 0;\r
+               int pixelColor = 0;\r
+               switch(pixmap.getFormat()) {\r
+                       case Gdx2DPixmap.GDX2D_FORMAT_ALPHA:\r
+                               clearColor = Color.rgba8888(1, 1, 1, 0.1f);\r
+                               pixelColor = Color.rgba8888(1, 1, 1, 1);\r
+                               break;\r
+                       case Gdx2DPixmap.GDX2D_FORMAT_LUMINANCE_ALPHA:\r
+                               clearColor = 0x36363619; //Color.rgba8888(1, 1, 1, 0.1f);\r
+                               pixelColor = 0xffffff12;\r
+                               break;\r
+                       case Gdx2DPixmap.GDX2D_FORMAT_RGB565:\r
+                               clearColor = Color.rgba8888(1, 0, 0, 1); \r
+                               pixelColor = Color.rgba8888(0, 0, 1, 1);\r
+                               break;\r
+                       case Gdx2DPixmap.GDX2D_FORMAT_RGB888:\r
+                               clearColor = Color.rgba8888(1, 0, 0, 1); \r
+                               pixelColor = Color.rgba8888(0, 0, 1, 1);\r
+                               break;\r
+                       case Gdx2DPixmap.GDX2D_FORMAT_RGBA4444:\r
+                               clearColor = 0xff000011; \r
+                               pixelColor = Color.rgba8888(0, 0, 1, 1);\r
+                               break;\r
+                       case Gdx2DPixmap.GDX2D_FORMAT_RGBA8888:\r
+                               clearColor = Color.rgba8888(1, 0, 0, 0.1f);\r
+                               pixelColor = Color.rgba8888(0, 0, 1, 1);\r
+                               \r
+               }               \r
+               if(pixmap.getPixel(15, 16) != clearColor) throw new RuntimeException("error clear: " + pixmap.getFormatString());               \r
+               if(pixmap.getPixel(16, 16) != pixelColor) throw new RuntimeException("error pixel: " + pixmap.getFormatString());               \r
+               pixmap.drawLine(0,0,31,31,Color.rgba8888(1, 1, 1, 1));\r
+               pixmap.drawRect(10, 10, 5, 7, Color.rgba8888(1, 1, 0, 0.5f));\r
+               pixmap.fillRect(20, 10, 5, 7, Color.rgba8888(0, 1, 1, 0.5f));\r
+               pixmap.drawCircle(16, 16, 10, Color.rgba8888(1, 0, 1, 1));\r
+               pixmap.fillCircle(16, 16, 6, Color.rgba8888(0, 1, 0, 0.5f));\r
+               pixmap.drawLine(-10, -10, 0, 0, Color.rgba8888(1, 1, 0, 1));\r
+               pixmap.drawLine(41, -10, 31, 0, Color.rgba8888(1, 1, 0, 1));\r
+               pixmap.drawLine(10, 41, 0, 31, Color.rgba8888(0, 1, 1, 1));\r
+               pixmap.drawLine(41, 41, 31, 31, Color.rgba8888(0, 1, 1, 1));            \r
                \r
-               rgba4444.clear(Color.rgba8888(1, 0, 0, 1));\r
-               rgba4444.setPixel(16, 16, Color.rgba8888(0, 0, 1, 1));\r
-//             if(rgba4444.getPixel(16, 16) != Color.rgba8888(0, 0, 1, 1)) throw new RuntimeException("rgba4444 error");\r
-//             if(rgba4444.getPixel(15, 16) != 0xff0000ff) throw new RuntimeException("rgba4444 error"); // lut will not be 100% correct\r
-               rgba4444.drawLine(0,0,31,31, Color.rgba8888(0, 1, 0, 1));\r
-               rgba4444.drawRect(10, 10, 5, 7, Color.rgba8888(1, 1, 0, 0.5f));\r
-               rgba4444.fillRect(20, 10, 5, 7, Color.rgba8888(0, 1, 1, 0.5f));\r
-               rgba4444.drawCircle(16, 16, 10, Color.rgba8888(1, 0, 1, 1));\r
-               rgba4444.fillCircle(16, 16, 6, Color.rgba8888(1, 0, 1, 0.5f));\r
+               pixmap.drawRect(-10, -10, 20, 20, Color.rgba8888(0, 1, 1, 1));          \r
+               pixmap.drawRect(21, -10, 20, 20, Color.rgba8888(0, 1, 1, 1));\r
+               pixmap.drawRect(-10, 21, 20, 20, Color.rgba8888(0, 1, 1, 1));\r
+               pixmap.drawRect(21, 21, 20, 20, Color.rgba8888(0, 1, 1, 1));\r
                \r
-               rgb888.clear(Color.rgba8888(1, 0, 0, 1));\r
-               rgb888.setPixel(16, 16, Color.rgba8888(0, 0, 1, 1));\r
-//             if(rgb888.getPixel(16, 16) != Color.rgba8888(0, 0, 1, 1)) throw new RuntimeException("rgb888 error");\r
-//             if(rgb888.getPixel(15, 16) != Color.rgba8888(1, 0, 0, 1)) throw new RuntimeException("rgb888 error");\r
-               rgb888.drawLine(0,0,31,31, Color.rgba8888(0, 1, 0, 1));\r
-               rgb888.drawRect(10, 10, 5, 7, Color.rgba8888(1, 1, 0, 0.5f));\r
-               rgb888.fillRect(20, 10, 5, 7, Color.rgba8888(0, 1, 1, 0.5f));\r
-               rgb888.drawCircle(16, 16, 10, Color.rgba8888(1, 0, 1, 1));\r
-               rgb888.fillCircle(16, 16, 6, Color.rgba8888(1, 0, 1, 1));\r
-               \r
-               rgba8888.clear(Color.rgba8888(1, 0, 0, 1));\r
-               rgba8888.setPixel(16, 16, Color.rgba8888(0, 0, 1, 1));\r
-//             if(rgba8888.getPixel(16, 16) != Color.rgba8888(0, 0, 1, 1)) throw new RuntimeException("rgba8888 error");\r
-//             if(rgba8888.getPixel(15, 16) != Color.rgba8888(1, 0, 0, 1)) throw new RuntimeException("rgba8888 error");\r
-               rgba8888.drawLine(0,0,31,31,Color.rgba8888(0, 1, 0, 1));\r
-               rgba8888.drawRect(10, 10, 5, 7, Color.rgba8888(1, 1, 0, 0.5f));\r
-               rgba8888.fillRect(20, 10, 5, 7, Color.rgba8888(0, 1, 1, 0.5f));\r
-               rgba8888.drawCircle(16, 16, 10, Color.rgba8888(1, 0, 1, 1));\r
-               rgba8888.fillCircle(16, 16, 6, Color.rgba8888(1, 0, 1, 0.5f));\r
+               pixmap.fillRect(-10, -10, 20, 20, Color.rgba8888(0, 1, 1, 0.5f));               \r
+               pixmap.fillRect(21, -10, 20, 20, Color.rgba8888(0, 1, 1, 0.5f));\r
+               pixmap.fillRect(-10, 21, 20, 20, Color.rgba8888(0, 1, 1, 0.5f));\r
+               pixmap.fillRect(21, 21, 20, 20, Color.rgba8888(0, 1, 1, 0.5f));\r
+       }\r
+       \r
+       Gdx2DPixmap[] testPixmaps() {\r
+               int[] formats = { Gdx2DPixmap.GDX2D_FORMAT_ALPHA, \r
+                                                 Gdx2DPixmap.GDX2D_FORMAT_LUMINANCE_ALPHA,\r
+                                                 Gdx2DPixmap.GDX2D_FORMAT_RGB565,\r
+                                                 Gdx2DPixmap.GDX2D_FORMAT_RGB888,\r
+                                                 Gdx2DPixmap.GDX2D_FORMAT_RGBA4444,\r
+                                                 Gdx2DPixmap.GDX2D_FORMAT_RGBA8888 };\r
                \r
-               Gdx2DPixmap.setBlend(0);\r
-               Gdx2DPixmap.setScale(Gdx2DPixmap.GDX2D_SCALE_LINEAR);\r
-               composite.clear(Color.rgba8888(1, 1, 1, 1));\r
-               composite.drawPixmap(alpha, 0, 0, 0, 0, 32, 32);\r
-               composite.drawPixmap(luminanceAlpha, 0, 0, 32, 0, 32, 32);\r
-               composite.drawPixmap(rgb565, 0, 0, 64, 0, 32, 32);\r
-               composite.drawPixmap(rgba4444, 0, 0, 96, 0, 32, 32);\r
-               composite.drawPixmap(rgb888, 0, 0, 128, 0, 32, 32);\r
-               composite.drawPixmap(rgba8888, 0, 0, 160, 0, 32, 32);\r
-               composite.drawPixmap(rgb888, 0, 0, 32, 32, 192, 0, 64, 64);\r
-               composite.drawPixmap(alpha, 0, 0, 32, 32, 192, 0, 16, 16);\r
-               composite.drawPixmap(luminanceAlpha, 0, 0, 32, 32, 256 - 16, 0, 16, 16);\r
-               composite.drawPixmap(rgb565, 0, 0, 32, 32, 192, 64 - 16, 16, 16);\r
-               composite.drawPixmap(rgba4444, 0, 0, 32, 32, 256 - 16, 64 - 16, 16, 16);\r
-                       \r
-//             Format[] formats = { Format.Alpha, Format.RGB565, Format.RGBA4444, Format.RGBA8888 };\r
-//             int[] gdxFormats = { Gdx2DPixmap.GDX2D_FORMAT_ALPHA, Gdx2DPixmap.GDX2D_FORMAT_RGB565, Gdx2DPixmap.GDX2D_FORMAT_RGBA4444, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888 };\r
-//             for(int format = 0; format < formats.length; format++) {\r
-//                     Gdx2DPixmap gdxPixmap = Gdx2DPixmap.newPixmap(256, 256, gdxFormats[format]);\r
-//                     Pixmap pixmap = Gdx.graphics.newPixmap(256, 256, formats[format]);\r
-//                     Random rand = new Random(0);\r
-//                     Random rand2 = new Random(0);\r
-//                     final int RUNS = 1000;\r
-//                     long startTime = System.nanoTime();             \r
-//                     for(int i = 0; i < RUNS; i++) {\r
-////                           gdxPixmap.clear(0xffffffff);\r
-//                             gdxPixmap.drawLine((int)(rand.nextFloat()*256), ((int)rand.nextFloat()*256), \r
-//                                                                              (int)(rand.nextFloat()*256), ((int)rand.nextFloat()*256), 0xffffffff);\r
-//                             gdxPixmap.drawCircle(((int)rand.nextFloat()*256), ((int)rand.nextFloat()*256), ((int)rand.nextFloat() * 128), 0xffffffff);\r
-//                             gdxPixmap.drawRect((int)(rand.nextFloat()*256), ((int)rand.nextFloat()*256), \r
-//                                                                              (int)(rand.nextFloat()*256), ((int)rand.nextFloat()*256), 0xffffffff);\r
-//                             gdxPixmap.fillCircle(((int)rand.nextFloat()*256), ((int)rand.nextFloat()*256), ((int)rand.nextFloat() * 128), 0xffffffff);\r
-//                             gdxPixmap.fillRect((int)(rand.nextFloat()*256), ((int)rand.nextFloat()*256), \r
-//                                                                              (int)(rand.nextFloat()*256), ((int)rand.nextFloat()*256), 0xffffffff);\r
-//                     }\r
-//                     Gdx.app.log("Gdx2DTest", "format: " + gdxPixmap.getFormatString());\r
-//                     Gdx.app.log("Gdx2DTest", "gdx2d: " + (System.nanoTime()-startTime) / 1000000000.0f);\r
-//     \r
-//                     startTime = System.nanoTime();          \r
-//                     for(int i = 0; i < RUNS; i++) {\r
-//                             pixmap.setColor(1, 1, 1, 1);\r
-////                           pixmap.fill();\r
-//                             pixmap.setColor(1, 1, 1, 1);\r
-//                             pixmap.drawLine((int)(rand2.nextFloat()*256), ((int)rand2.nextFloat()*256), \r
-//                                                                              (int)(rand2.nextFloat()*256), ((int)rand2.nextFloat()*256));\r
-//                             pixmap.drawCircle(((int)rand2.nextFloat()*256), ((int)rand2.nextFloat()*256), ((int)rand2.nextFloat() * 128));\r
-//                             pixmap.drawRectangle((int)(rand2.nextFloat()*256), ((int)rand2.nextFloat()*256), \r
-//                                                                              (int)(rand2.nextFloat()*256), ((int)rand2.nextFloat()*256));\r
-//                             pixmap.fillCircle(((int)rand2.nextFloat()*256), ((int)rand2.nextFloat()*256), ((int)rand2.nextFloat() * 128));\r
-//                             pixmap.fillRectangle((int)(rand2.nextFloat()*256), ((int)rand2.nextFloat()*256), \r
-//                                                                              (int)(rand2.nextFloat()*256), ((int)rand2.nextFloat()*256));\r
-//                     }\r
-//                     Gdx.app.log("Gdx2DTest", "native: " + (System.nanoTime()-startTime) / 1000000000.0f);\r
-//                     pixmap.dispose();\r
-//                     gdxPixmap.dispose();\r
-//             }\r
+               Gdx2DPixmap[] pixmaps = new Gdx2DPixmap[formats.length];\r
+               for(int i = 0; i < pixmaps.length; i++) {\r
+                       Gdx2DPixmap pixmap = new Gdx2DPixmap(32, 32, formats[i]);\r
+                       drawToPixmap(pixmap);\r
+                       pixmaps[i] = pixmap;\r
+               }\r
+               return pixmaps;\r
+       }\r
+       \r
+       @Override public void create () {       \r
+               batch = new SpriteBatch();\r
+               sprites = new ArrayList<Sprite>();                      \r
+               Gdx2DPixmap[] pixmaps = testPixmaps();\r
                \r
-               sprites.add(new Sprite(textureFromPixmap(alpha)));              \r
-               sprites.add(new Sprite(textureFromPixmap(luminanceAlpha)));\r
-               sprites.add(new Sprite(textureFromPixmap(rgb565)));\r
-               sprites.add(new Sprite(textureFromPixmap(rgba4444)));\r
-               sprites.add(new Sprite(textureFromPixmap(rgb888)));\r
-               sprites.add(new Sprite(textureFromPixmap(rgba8888)));\r
-               sprites.add(new Sprite(textureFromPixmap(composite)));          \r
+               Gdx2DPixmap composite = new Gdx2DPixmap(512, 256, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888);\r
                \r
+               Gdx2DPixmap.setBlend(Gdx2DPixmap.GDX2D_BLEND_NONE);\r
+               for(int i = 0; i < pixmaps.length; i++) {\r
+                       Gdx2DPixmap.setScale(Gdx2DPixmap.GDX2D_SCALE_NEAREST);                  \r
+                       composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 0, 64, 64);                      \r
+                       composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 64, 16, 16);\r
+                       composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 0, 64, 64);\r
+                       composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 64, 16, 16);\r
+                       Gdx2DPixmap.setScale(Gdx2DPixmap.GDX2D_SCALE_LINEAR);\r
+                       composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 100, 64, 64);                    \r
+                       composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 164, 16, 16);\r
+                       composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 100, 64, 64);\r
+                       composite.drawPixmap(pixmaps[i], 0, 0, 32, 32, i * 64, 164, 16, 16);\r
+                       Sprite sprite = new Sprite(textureFromPixmap(pixmaps[i]));\r
+                       sprite.setPosition(10 + i * 32, 10);\r
+                       sprites.add(sprite);\r
+               }                               \r
                \r
-               sprites.get(0).setPosition(10, 10);\r
-               sprites.get(1).setPosition(50, 10);\r
-               sprites.get(2).setPosition(90, 10);\r
-               sprites.get(3).setPosition(130, 10);\r
-               sprites.get(4).setPosition(170, 10);\r
-               sprites.get(5).setPosition(210, 10);\r
-               sprites.get(6).setPosition(10, 50);\r
+               Sprite sprite = new Sprite(textureFromPixmap(composite));\r
+               sprite.setPosition(10, 50);\r
+               sprites.add(sprite);\r
        }\r
 \r
        @Override public void render() {\r
                Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f);\r
-               Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);\r
-               batch.disableBlending();\r
+               Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);                       \r
                batch.begin();\r
                for(int i = 0; i < sprites.size(); i++) {\r
                        sprites.get(i).draw(batch);\r