OSDN Git Service

[added] Gdx2DPixmap, don't use this yet, it's a WIP.
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Thu, 30 Dec 2010 13:27:27 +0000 (13:27 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Thu, 30 Dec 2010 13:27:27 +0000 (13:27 +0000)
[fixed] #####libgdx.so issue on Android.

gdx/jni/gdx2d/gdx2d.c
gdx/jni/gdx2d/gdx2d.h
gdx/src/com/badlogic/gdx/Version.java
gdx/src/com/badlogic/gdx/graphics/Gdx2DPixmap.java

index 0fb015e..66014f4 100644 (file)
@@ -20,9 +20,9 @@
 static int gdx2d_blend = GDX2D_BLEND_NONE;\r
 static int gdx2d_scale = GDX2D_SCALE_NEAREST;\r
 \r
-gdx2d_pixmap* gdx2d_load(const char *buffer, int len, int req_format) {\r
+gdx2d_pixmap* gdx2d_load(const unsigned char *buffer, int len, int req_format) {\r
        int width, height, format;\r
-       const char* pixels = stbi_load_from_memory(buffer, len, &width, &height, &format, req_format);\r
+       const unsigned char* pixels = stbi_load_from_memory(buffer, len, &width, &height, &format, req_format);\r
        if(pixels == NULL)\r
                return NULL;\r
 \r
@@ -39,7 +39,7 @@ gdx2d_pixmap* gdx2d_new(int width, int height, int format) {
        pixmap->width = width;\r
        pixmap->height = height;\r
        pixmap->format = format;\r
-       pixmap->pixels = (char*)malloc(width * height * format);\r
+       pixmap->pixels = (unsigned char*)malloc(width * height * format);\r
        return pixmap;\r
 }\r
 void gdx2d_free(const gdx2d_pixmap* pixmap) {\r
@@ -55,31 +55,31 @@ void gdx2d_set_scale (int scale) {
        gdx2d_scale = scale;\r
 }\r
 \r
-void gdx2d_clear(const gdx2d_pixmap* pixmap, int col) {\r
-\r
+void gdx2d_clear(const gdx2d_pixmap* pixmap, uint32_t col) {\r
+       \r
 }\r
 \r
-void gdx2d_set_pixel(const gdx2d_pixmap* pixmap, int x, int y, int col) {\r
+void gdx2d_set_pixel(const gdx2d_pixmap* pixmap, int x, int y, uint32_t col) {\r
 \r
 }\r
 \r
-void gdx2d_draw_line(const gdx2d_pixmap* pixmap, int x, int y, int x2, int y2, int col) {\r
+void gdx2d_draw_line(const gdx2d_pixmap* pixmap, int x, int y, int x2, int y2, uint32_t col) {\r
 \r
 }\r
 \r
-void gdx2d_draw_rect(const gdx2d_pixmap* pixmap, int x, int y, int width, int height, int col) {\r
+void gdx2d_draw_rect(const gdx2d_pixmap* pixmap, int x, int y, int width, int height, uint32_t col) {\r
 \r
 }\r
 \r
-void gdx2d_draw_circle(const gdx2d_pixmap* pixmap, int x, int y, int radius, int col) {\r
+void gdx2d_draw_circle(const gdx2d_pixmap* pixmap, int x, int y, int radius, uint32_t col) {\r
 \r
 }\r
 \r
-void gdx2d_fill_rect(const gdx2d_pixmap* pixmap, int x, int y, int width, int height, int col) {\r
+void gdx2d_fill_rect(const gdx2d_pixmap* pixmap, int x, int y, int width, int height, uint32_t col) {\r
 \r
 }\r
 \r
-void gdx2d_fill_circle(const gdx2d_pixmap* pixmap, int x, int y, int radius, int col) {\r
+void gdx2d_fill_circle(const gdx2d_pixmap* pixmap, int x, int y, int radius, uint32_t col) {\r
 \r
 }\r
 \r
index 5270af5..02d7542 100644 (file)
@@ -13,6 +13,8 @@
 #ifndef __GDX2D__\r
 #define __GDX2D__\r
 \r
+#include <stdint.h>\r
+\r
 #ifdef __cplusplus\r
 extern "C" {\r
 #endif\r
@@ -49,23 +51,23 @@ typedef struct {
        int width;\r
        int height;\r
        int format;\r
-       const char* pixels;\r
+       const unsigned char* pixels;\r
 } gdx2d_pixmap;\r
 \r
-extern gdx2d_pixmap* gdx2d_load (const char *buffer, int len, int req_format);\r
+extern gdx2d_pixmap* gdx2d_load (const unsigned char *buffer, int len, int req_format);\r
 extern gdx2d_pixmap* gdx2d_new  (int width, int height, int format);\r
 extern void             gdx2d_free (const gdx2d_pixmap* pixmap);\r
 \r
 extern void gdx2d_set_blend      (int blend);\r
 extern void gdx2d_set_scale      (int scale);\r
 \r
-extern void gdx2d_clear                  (const gdx2d_pixmap* pixmap, int col);\r
-extern void gdx2d_set_pixel   (const gdx2d_pixmap* pixmap, int x, int y, int col);\r
-extern void gdx2d_draw_line   (const gdx2d_pixmap* pixmap, int x, int y, int x2, int y2, int col);\r
-extern void gdx2d_draw_rect   (const gdx2d_pixmap* pixmap, int x, int y, int width, int height, int col);\r
-extern void gdx2d_draw_circle (const gdx2d_pixmap* pixmap, int x, int y, int radius, int col);\r
-extern void gdx2d_fill_rect   (const gdx2d_pixmap* pixmap, int x, int y, int width, int height, int col);\r
-extern void gdx2d_fill_circle (const gdx2d_pixmap* pixmap, int x, int y, int radius, int col);\r
+extern void gdx2d_clear                  (const gdx2d_pixmap* pixmap, uint32_t col);\r
+extern void gdx2d_set_pixel   (const gdx2d_pixmap* pixmap, int x, int y, uint32_t col);\r
+extern void gdx2d_draw_line   (const gdx2d_pixmap* pixmap, int x, int y, int x2, int y2, uint32_t col);\r
+extern void gdx2d_draw_rect   (const gdx2d_pixmap* pixmap, int x, int y, int width, int height, uint32_t col);\r
+extern void gdx2d_draw_circle (const gdx2d_pixmap* pixmap, int x, int y, int radius, uint32_t col);\r
+extern void gdx2d_fill_rect   (const gdx2d_pixmap* pixmap, int x, int y, int width, int height, uint32_t col);\r
+extern void gdx2d_fill_circle (const gdx2d_pixmap* pixmap, int x, int y, int radius, uint32_t col);\r
 extern void gdx2d_draw_pixmap (const gdx2d_pixmap* src_pixmap,\r
                                                           const gdx2d_pixmap* dst_pixmap,\r
                                                           int src_x, int src_y, int src_width, int src_height,\r
index 9cd0611..a865d90 100644 (file)
@@ -25,11 +25,13 @@ public class Version {
        /** the current version of libgdx in the major.minor format **/\r
        public static String VERSION = "0.81";\r
 \r
-       public static void loadLibrary () {\r
-               if (GdxNativesLoader.loadLibraries()) return;\r
-\r
+       public static void loadLibrary () {             \r
                String os = System.getProperty("os.name");\r
                String arch = System.getProperty("os.arch");\r
+               String vm = System.getProperty("java.vm.name");\r
+               \r
+               if(!(vm != null && vm.contains("Dalvik")))\r
+                       if (GdxNativesLoader.loadLibraries()) return;\r
 \r
                if (!arch.equals("amd64") || os.contains("Mac")) {\r
                        System.loadLibrary("gdx");\r
index fac5451..5aa82e4 100644 (file)
@@ -15,6 +15,7 @@ package com.badlogic.gdx.graphics;
 import java.io.ByteArrayOutputStream;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
+import java.nio.Buffer;\r
 import java.nio.ByteBuffer;\r
 \r
 /**\r
@@ -23,10 +24,10 @@ import java.nio.ByteBuffer;
  *\r
  */\r
 public class Gdx2DPixmap {\r
-       static final int GDX2D_FORMAT_ALPHA = 1;\r
-       static final int GDX2D_FORMAT_ALPHA_LUMINANCE = 2;\r
-       static final int GDX2D_FORMAT_RGB = 3;\r
-       static final int GDX2D_FORMAT_RGBA = 4;\r
+       public static final int GDX2D_FORMAT_ALPHA = 1;\r
+       public static final int GDX2D_FORMAT_ALPHA_LUMINANCE = 2;\r
+       public static final int GDX2D_FORMAT_RGB = 3;\r
+       public static final int GDX2D_FORMAT_RGBA = 4;\r
        \r
        final long basePtr;\r
        final int width;\r
@@ -35,7 +36,7 @@ public class Gdx2DPixmap {
        final ByteBuffer pixelPtr;\r
        static final long[] nativeData = new long[4];\r
        \r
-       private Gdx2DPixmap(InputStream in, int requestedFormat) throws IOException {\r
+       public Gdx2DPixmap(InputStream in, int requestedFormat) throws IOException {\r
                ByteArrayOutputStream bytes = new ByteArrayOutputStream();\r
                byte[] buffer = new byte[1024];\r
                int readBytes = 0;\r
@@ -55,7 +56,7 @@ public class Gdx2DPixmap {
                format = (int)nativeData[3];            \r
        }\r
        \r
-       private Gdx2DPixmap(int width, int height, int format) throws IllegalArgumentException {\r
+       public Gdx2DPixmap(int width, int height, int format) throws IllegalArgumentException {\r
                pixelPtr = newPixmap(nativeData, width, height, format);\r
                if(pixelPtr == null)\r
                        throw new IllegalArgumentException("couldn't load pixmap");\r
@@ -119,7 +120,7 @@ public class Gdx2DPixmap {
                } catch(IllegalArgumentException e) {\r
                        return null;\r
                }\r
-       }\r
+       }       \r
        \r
        private static native ByteBuffer load(long[] nativeData, byte[] buffer, int len, int requestedFormat);\r
        private static native ByteBuffer newPixmap(long[] nativeData, int width, int height, int format);\r
@@ -135,4 +136,20 @@ public class Gdx2DPixmap {
        \r
        public static native void setBlend(int blend);\r
        public static native void setScale(int scale);\r
+\r
+       public ByteBuffer getPixels () {\r
+               return pixelPtr;\r
+       }\r
+\r
+       public int getHeight () {\r
+               return height;\r
+       }\r
+       \r
+       public int getWidth () {\r
+               return width;\r
+       }\r
+       \r
+       public int getFormat() {\r
+               return format;\r
+       }\r
 }\r