-GDX_SRC_FILES += gdx2d/gdx2d.c
\ No newline at end of file
+GDX_SRC_FILES += gdx2d/gdx2d.c \\r
+ gdx2d/Gdx2DPixmap.cpp
\ No newline at end of file
--- /dev/null
+#include "Gdx2DPixmap.h"\r
+#include "gdx2d.h"\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: load\r
+ * Signature: ([J[BII)Ljava/nio/ByteBuffer;\r
+ */\r
+JNIEXPORT jobject JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_load\r
+ (JNIEnv *, jclass, jlongArray, jbyteArray, jint, jint) {\r
+\r
+}\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: newPixmap\r
+ * Signature: ([JIII)Ljava/nio/ByteBuffer;\r
+ */\r
+JNIEXPORT jobject JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_newPixmap\r
+ (JNIEnv *, jclass, jlongArray, jint, jint, jint) {\r
+\r
+}\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: free\r
+ * Signature: (J)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_free\r
+ (JNIEnv *, jclass, jlong) {\r
+\r
+}\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: clear\r
+ * Signature: (JI)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_clear\r
+ (JNIEnv *, jclass, jlong, jint) {\r
+\r
+}\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: setPixel\r
+ * Signature: (JIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_setPixel\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint) {\r
+\r
+}\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: drawLine\r
+ * Signature: (JIIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_drawLine\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint, jint, jint) {\r
+\r
+}\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: drawRect\r
+ * Signature: (JIIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_drawRect\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint, jint, jint) {\r
+\r
+}\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: drawCircle\r
+ * Signature: (JIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_drawCircle\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint, jint) {\r
+\r
+}\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: fillRect\r
+ * Signature: (JIIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_fillRect\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint, jint, jint) {\r
+\r
+}\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: fillCircle\r
+ * Signature: (JIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_fillCircle\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint, jint) {\r
+\r
+}\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: drawPixmap\r
+ * Signature: (JJIIIIIIIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_drawPixmap\r
+ (JNIEnv *, jclass, jlong, jlong, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint) {\r
+\r
+}\r
--- /dev/null
+/* DO NOT EDIT THIS FILE - it is machine generated */\r
+#include <jni.h>\r
+/* Header for class com_badlogic_gdx_graphics_Gdx2DPixmap */\r
+\r
+#ifndef _Included_com_badlogic_gdx_graphics_Gdx2DPixmap\r
+#define _Included_com_badlogic_gdx_graphics_Gdx2DPixmap\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+#undef com_badlogic_gdx_graphics_Gdx2DPixmap_GDX2D_FORMAT_ALPHA\r
+#define com_badlogic_gdx_graphics_Gdx2DPixmap_GDX2D_FORMAT_ALPHA 1L\r
+#undef com_badlogic_gdx_graphics_Gdx2DPixmap_GDX2D_FORMAT_ALPHA_LUMINANCE\r
+#define com_badlogic_gdx_graphics_Gdx2DPixmap_GDX2D_FORMAT_ALPHA_LUMINANCE 2L\r
+#undef com_badlogic_gdx_graphics_Gdx2DPixmap_GDX2D_FORMAT_RGB\r
+#define com_badlogic_gdx_graphics_Gdx2DPixmap_GDX2D_FORMAT_RGB 3L\r
+#undef com_badlogic_gdx_graphics_Gdx2DPixmap_GDX2D_FORMAT_RGBA\r
+#define com_badlogic_gdx_graphics_Gdx2DPixmap_GDX2D_FORMAT_RGBA 4L\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: load\r
+ * Signature: ([J[BII)Ljava/nio/ByteBuffer;\r
+ */\r
+JNIEXPORT jobject JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_load\r
+ (JNIEnv *, jclass, jlongArray, jbyteArray, jint, jint);\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: newPixmap\r
+ * Signature: ([JIII)Ljava/nio/ByteBuffer;\r
+ */\r
+JNIEXPORT jobject JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_newPixmap\r
+ (JNIEnv *, jclass, jlongArray, jint, jint, jint);\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: free\r
+ * Signature: (J)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_free\r
+ (JNIEnv *, jclass, jlong);\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: clear\r
+ * Signature: (JI)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_clear\r
+ (JNIEnv *, jclass, jlong, jint);\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: setPixel\r
+ * Signature: (JIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_setPixel\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint);\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: drawLine\r
+ * Signature: (JIIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_drawLine\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint, jint, jint);\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: drawRect\r
+ * Signature: (JIIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_drawRect\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint, jint, jint);\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: drawCircle\r
+ * Signature: (JIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_drawCircle\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint, jint);\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: fillRect\r
+ * Signature: (JIIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_fillRect\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint, jint, jint);\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: fillCircle\r
+ * Signature: (JIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_fillCircle\r
+ (JNIEnv *, jclass, jlong, jint, jint, jint, jint);\r
+\r
+/*\r
+ * Class: com_badlogic_gdx_graphics_Gdx2DPixmap\r
+ * Method: drawPixmap\r
+ * Signature: (JJIIIIIIIIII)V\r
+ */\r
+JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_Gdx2DPixmap_drawPixmap\r
+ (JNIEnv *, jclass, jlong, jlong, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif\r
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language\r
* governing permissions and limitations under the License.\r
*/\r
+#include "gdx2d.h"\r
#define STB_TRUETYPE_IMPLEMENTATION\r
#define STBI_HEADER_FILE_ONLY\r
#include "stb_image.c"\r
--- /dev/null
+/*\r
+ * Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the\r
+ * License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"\r
+ * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ */\r
+#ifndef __GDX2D__\r
+#define __GDX2D__\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/**\r
+ * pixmap formats, components are laid out in memory\r
+ * in the order they appear in the constant name. E.g.\r
+ * GDX_FORMAT_RGB => pixmap[0] = r, pixmap[1] = g, pixmap[2] = b.\r
+ * Components are 8-bit each.\r
+ */\r
+#define GDX2D_FORMAT_ALPHA 1\r
+#define GDX2D_FORMAT_ALPHA_LUMINANCE 2\r
+#define GDX2D_FORMAT_RGB 3\r
+#define GDX2D_FORMAT_RGBA 4\r
+\r
+/**\r
+ * blending modes, to be extended\r
+ */\r
+#define GDX2D_BLEND_NONE 0\r
+#define GDX2D_BLEND_SRC_OVER 1\r
+\r
+/**\r
+ * scaling modes, to be extended\r
+ */\r
+#define GDX2D_SCALE_NEAREST 0\r
+#define GDX2D_SCALE_BILINEAR 1\r
+\r
+/**\r
+ * simple pixmap struct holding the pixel data,\r
+ * the dimensions and the format of the pixmap.\r
+ * the format is one of the GDX2D_FORMAT_XXX constants.\r
+ */\r
+struct {\r
+ int width;\r
+ int height;\r
+ int format;\r
+ const char* pixels;\r
+} gdx2d_pixmap_struct;\r
+typedef struct gdx2d_pixmap_struct gdx2d_pixmap;\r
+\r
+\r
+gdx2d_pixmap* gdx2d_load_buffer (const char *buffer, int len, int req_format);\r
+gdx2d_pixmap* gdx2d_load_file (const char *filename, int req_format);\r
+gdx2d_pixmap* gdx2d_new (int width, int height, int format);\r
+void gdx2d_free (const gdx2d_pixmap* pixmap);\r
+\r
+void gdx2d_clear (const gdx2d_pixmap* pixmap, int col);\r
+void gdx2d_set_pixel (const gdx2d_pixmap* pixmap, int x, int y, int col);\r
+void gdx2d_draw_line (const gdx2d_pixmap* pixmap, int x, int y, int x2, int y2, int col);\r
+void gdx2d_draw_rect (const gdx2d_pixmap* pixmap, int x, int y, int width, int height, int col);\r
+void gdx2d_draw_circle (const gdx2d_pixmap* pixmap, int x, int y, int radius, int col);\r
+void gdx2d_fill_rect (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, int col);\r
+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
+ int dst_x, int dst_y, int dst_width, int dst_height,\r
+ int blend, int scale);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ * Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the\r
+ * License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"\r
+ * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ */\r
+package com.badlogic.gdx.graphics;\r
+\r
+import java.io.ByteArrayOutputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.nio.ByteBuffer;\r
+\r
+/**\r
+ * Experimental. Do not use!\r
+ * @author mzechner\r
+ *\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
+ \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
+ \r
+ private Gdx2DPixmap(InputStream in, int requestedFormat) throws IOException {\r
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();\r
+ byte[] buffer = new byte[1024];\r
+ int readBytes = 0;\r
+ \r
+ while((readBytes = in.read(buffer)) != -1) {\r
+ bytes.write(buffer);\r
+ }\r
+ \r
+ buffer = bytes.toByteArray();\r
+ pixelPtr = load(nativeData, buffer, buffer.length, requestedFormat);\r
+ if(pixelPtr == null)\r
+ throw new IOException("couldn't load pixmap");\r
+ \r
+ basePtr = nativeData[0];\r
+ width = (int)nativeData[1];\r
+ height = (int)nativeData[2];\r
+ format = (int)nativeData[3]; \r
+ }\r
+ \r
+ private 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
+ \r
+ this.basePtr = nativeData[0];\r
+ this.width = (int)nativeData[1];\r
+ this.height = (int)nativeData[2];\r
+ this.format = (int)nativeData[3];\r
+ }\r
+ \r
+ public void dispose() {\r
+ free(basePtr);\r
+ }\r
+ \r
+ public void clear(int color) {\r
+ clear(basePtr, color);\r
+ }\r
+ \r
+ public void setPixel(int x, int y, int color) {\r
+ setPixel(basePtr, x, y, color);\r
+ }\r
+ \r
+ public void drawLine(int x, int y, int x2, int y2, int color) {\r
+ drawLine(basePtr, x, y, x2, y2, color);\r
+ }\r
+ \r
+ public void drawRect(int x, int y, int width, int height, int color) {\r
+ drawRect(basePtr, x, y, width, height, color);\r
+ }\r
+ \r
+ public void drawCircle(int x, int y, int radius, int color) {\r
+ drawCircle(basePtr, x, y, radius, color);\r
+ }\r
+ \r
+ public void fillRect(int x, int y, int width, int height, int color) {\r
+ drawRect(basePtr, x, y, width, height, color);\r
+ }\r
+ \r
+ public void fillCircle(int x, int y, int radius, int color) {\r
+ drawCircle(basePtr, x, y, radius, color);\r
+ }\r
+ \r
+ private void drawPixmap(Gdx2DPixmap src, \r
+ int srcX, int srcY, int srcWidth, int srcHeight, \r
+ int dstX, int dstY, int dstWidth, int dstHeight, \r
+ int blend, int scale) {\r
+ drawPixmap(src.basePtr, basePtr, srcX, srcY, srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight, blend, scale);\r
+ }\r
+ \r
+ \r
+ public static Gdx2DPixmap newPixmap(InputStream in, int requestedFormat) {\r
+ try {\r
+ return new Gdx2DPixmap(in, requestedFormat);\r
+ } catch(IOException e) {\r
+ return null;\r
+ }\r
+ }\r
+ \r
+ public static Gdx2DPixmap newPixmap(int width, int height, int format) {\r
+ try {\r
+ return new Gdx2DPixmap(width, height, format);\r
+ } catch(IllegalArgumentException e) {\r
+ return null;\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
+ private static native void free(long basePtr);\r
+ private static native void clear(long pixmap, int color);\r
+ private static native void setPixel(long pixmap, int x, int y, int color);\r
+ private static native void drawLine(long pixmap, int x, int y, int x2, int y2, int color);\r
+ private static native void drawRect(long pixmap, int x, int y, int width, int height, int color);\r
+ private static native void drawCircle(long pixmap, int x, int y, int radius, int color);\r
+ private static native void fillRect(long pixmap, int x, int y, int width, int height, int color);\r
+ private static native void fillCircle(long pixmap, int x, int y, int radius, int color);\r
+ private static native void drawPixmap(long src, long dst, int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight, int blend, int scale);\r
+}\r