OSDN Git Service

[changed] gdx2d_blitter works now. only same size splits. it's the dumbest implementa...
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Tue, 25 Jan 2011 17:38:58 +0000 (17:38 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Tue, 25 Jan 2011 17:38:58 +0000 (17:38 +0000)
gdx/jni/gdx2d/gdx2d.c
gdx/libs/windows/gdx.dll
tests/gdx-tests-jogl/.classpath
tests/gdx-tests/src/com/badlogic/gdx/tests/Gdx2DTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/SoundTest.java

index 0d4725d..a01088c 100644 (file)
@@ -639,45 +639,39 @@ void gdx2d_fill_circle(const gdx2d_pixmap* pixmap, int32_t x0, int32_t y0, uint3
 void blit_same_size(const gdx2d_pixmap* src_pixmap, const gdx2d_pixmap* dst_pixmap, \r
                                                                         int32_t src_x, int32_t src_y, \r
                                                                         int32_t dst_x, int32_t dst_y, \r
-                                                                        uint32_t width, uint32_t height) {\r
-/*     if(src_x >= src_pixmap->width) return;\r
-       if(src_y >= src_pixmap->height) return;\r
-       if(dst_x >= dst_pixmap->width) return;\r
-       if(dst_y >= dst_pixmap->height) return;\r
-\r
-       if(src_x + width - 1 < 0) return;\r
-       if(src_y + height - 1 < 0) return;\r
-       if(dst_x + width - 1 < 0) return;\r
-       if(dst_y + height - 1 < 0) return;*/\r
-\r
+                                                                        uint32_t width, uint32_t height) {     \r
        set_pixel_func pset = set_pixel_func_ptr(dst_pixmap->format);\r
        get_pixel_func pget = get_pixel_func_ptr(src_pixmap->format);\r
        get_pixel_func dpget = get_pixel_func_ptr(dst_pixmap->format);\r
-       uint32_t spitch = bytes_per_pixel(src_pixmap->format) * src_pixmap->width;\r
-       uint32_t dpitch = bytes_per_pixel(dst_pixmap->format) * dst_pixmap->width;\r
+       uint32_t sbpp = bytes_per_pixel(src_pixmap->format);\r
+       uint32_t dbpp = bytes_per_pixel(dst_pixmap->format);\r
+       uint32_t spitch = sbpp * src_pixmap->width;\r
+       uint32_t dpitch = dbpp * dst_pixmap->width;\r
 \r
        int sx = src_x;\r
        int sy = src_y;\r
        int dx = dst_x;\r
        int dy = dst_y;\r
 \r
-       for(sx = src_x ;sy < src_y + height - 1; sy++, dy++) {\r
-               //if(sy < 0 || dy < 0) continue;\r
-               //if(sy >= src_pixmap->height || dy >= dst_pixmap->height) break;\r
-\r
-               for(;sx < src_x + width - 1; sx++, dx++) {\r
-                       //if(sx < 0 || dx < 0) continue;\r
-                       //if(sx >= src_pixmap->width || dx >= dst_pixmap->width) break;\r
+       for(;sy < src_y + height; sy++, dy++) {\r
+               if(sy < 0 || dy < 0) continue;\r
+               if(sy >= src_pixmap->height || dy >= dst_pixmap->height) break;\r
+               \r
+               for(sx = src_x, dx = dst_x; sx < src_x + width; sx++, dx++) {\r
+                       if(sx < 0 || dx < 0) continue;\r
+                       if(sx >= src_pixmap->width || dx >= dst_pixmap->width) break;\r
 \r
-                       const void* src_ptr = src_pixmap->pixels + sx + sy * spitch;\r
-                       const void* dst_ptr = dst_pixmap->pixels + dx + dy * dpitch;\r
+                       const void* src_ptr = src_pixmap->pixels + sx * sbpp + sy * spitch;\r
+                       const void* dst_ptr = dst_pixmap->pixels + dx * dbpp + dy * dpitch;\r
                        uint32_t src_col = to_RGBA8888(src_pixmap->format, pget((void*)src_ptr));\r
+\r
                        if(gdx2d_blend) {\r
                                uint32_t dst_col = to_RGBA8888(dst_pixmap->format, dpget((void*)dst_ptr));\r
                                src_col = to_format(dst_pixmap->format, blend(src_col, dst_col));\r
                        } else {\r
-                               src_col = to_format(dst_pixmap->format, src_col);\r
+                               src_col = to_format(dst_pixmap->format, src_col); \r
                        }\r
+                       \r
                        pset((void*)dst_ptr, src_col);\r
                }\r
        }\r
index 6fc007f..070c554 100644 (file)
Binary files a/gdx/libs/windows/gdx.dll and b/gdx/libs/windows/gdx.dll differ
index cca9a9c..98d265c 100644 (file)
@@ -9,6 +9,5 @@
        </classpathentry>\r
        <classpathentry combineaccessrules="false" kind="src" path="/gdx-backend-jogl"/>\r
        <classpathentry combineaccessrules="false" kind="src" path="/gdx-tests"/>\r
-       <classpathentry kind="lib" path="/gdx/libs/gdx-natives.jar"/>\r
        <classpathentry kind="output" path="bin"/>\r
 </classpath>\r
index b80df11..a5bc243 100644 (file)
@@ -43,7 +43,7 @@ public class Gdx2DTest extends GdxTest {
                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, 32, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888);\r
+               Gdx2DPixmap composite = createPixmap(256, 32, Gdx2DPixmap.GDX2D_FORMAT_RGB565);\r
                \r
                Gdx2DPixmap.setBlend(1);\r
                \r
@@ -70,7 +70,7 @@ public class Gdx2DTest extends GdxTest {
                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
+//             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
@@ -80,7 +80,7 @@ public class Gdx2DTest extends GdxTest {
                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
+//             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
@@ -90,7 +90,7 @@ public class Gdx2DTest extends GdxTest {
                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
+//             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
@@ -100,7 +100,7 @@ public class Gdx2DTest extends GdxTest {
                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
+//             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
@@ -113,48 +113,50 @@ public class Gdx2DTest extends GdxTest {
                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
                        \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
+//             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
                \r
                sprites.add(new Sprite(textureFromPixmap(alpha)));              \r
                sprites.add(new Sprite(textureFromPixmap(luminanceAlpha)));\r
@@ -177,6 +179,7 @@ public class Gdx2DTest extends GdxTest {
        @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
                batch.begin();\r
                for(int i = 0; i < sprites.size(); i++) {\r
                        sprites.get(i).draw(batch);\r
index 595980c..e8ed819 100644 (file)
@@ -32,6 +32,7 @@ public class SoundTest extends GdxTest implements InputProcessor {
 //             sound = Gdx.audio.newSound(Gdx.files.getFileHandle("data/shotgun.wav", FileType.Internal));\r
                sound = Gdx.audio.newSound(Gdx.files.getFileHandle("data/sell_buy_item.wav", FileType.Internal));\r
 \r
+//             music = Gdx.audio.newMusic(Gdx.files.internal("data/cloudconnected.ogg"));\r
                music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/threeofaperfectpair.mp3", FileType.Internal));\r
                music.setVolume(volume);\r
                music.play();\r