add jni build instructions and remove build files
This commit is contained in:
parent
36a721a8e1
commit
131876463a
20
vtm/BUILD_JNI.txt
Normal file
20
vtm/BUILD_JNI.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Build native libraries:
|
||||||
|
|
||||||
|
* modify jni/builder/JniBuilder.java for your platform.
|
||||||
|
|
||||||
|
* get gdx-jnigen, then run:
|
||||||
|
|
||||||
|
javac -cp gdx-jnigen.jar jni/builder/JniBuilder.java
|
||||||
|
java -cp gdx-jnigen.jar:jni/builder JniBuilder
|
||||||
|
|
||||||
|
* to build android:
|
||||||
|
export NDK_HOME=/your_android_ndk_path
|
||||||
|
|
||||||
|
* compile
|
||||||
|
cd jni
|
||||||
|
ant -v
|
||||||
|
|
||||||
|
* copy vtm/libs/armeabi* to vtm-android/libs
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
|||||||
LOCAL_PATH:= $(call my-dir)
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
LOCAL_MODULE := vtm-jni
|
|
||||||
LOCAL_C_INCLUDES := .
|
|
||||||
|
|
||||||
LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -std=c99 -O2 -DTRILIBRARY -DREDUCED -DCDT_ONLY -DNO_TIMER
|
|
||||||
LOCAL_CPPFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -std=c99 -O2 -DTRILIBRARY -DREDUCED -DCDT_ONLY -DNO_TIMER
|
|
||||||
LOCAL_LDLIBS := -lm -llog
|
|
||||||
LOCAL_ARM_MODE := arm
|
|
||||||
|
|
||||||
LOCAL_SRC_FILES := gl/utils.c\
|
|
||||||
triangle/triangle_dbg.c\
|
|
||||||
triangle/TriangleJni.c\
|
|
||||||
triangle/triangle.c
|
|
||||||
|
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
|
@ -1 +0,0 @@
|
|||||||
APP_ABI := armeabi armeabi-v7a
|
|
@ -1,33 +0,0 @@
|
|||||||
<project name="android-natives" basedir="." default="postcompile">
|
|
||||||
<property environment="env" />
|
|
||||||
<!-- the suffix ndk-build executable -->
|
|
||||||
<property name="ndkSuffix" value="" />
|
|
||||||
|
|
||||||
<target name="clean" depends="check-for-ndk" if="has-ndk-build">
|
|
||||||
<exec executable="${env.NDK_HOME}/ndk-build${ndkSuffix}" failonerror="true">
|
|
||||||
<arg value="clean"/>
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="precompile" depends="check-for-ndk">
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="compile-natives" depends="precompile" if="has-ndk-build">
|
|
||||||
<echo>ndk_home: ${env.NDK_HOME}</echo>
|
|
||||||
<exec executable="${env.NDK_HOME}/ndk-build${ndkSuffix}" failonerror="true"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="postcompile" depends="compile-natives">
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="check-for-ndk">
|
|
||||||
<condition property="ndk-build-found">
|
|
||||||
<available file="ndk-build${ndkSuffix}" filepath="${env.NDK_HOME}"/>
|
|
||||||
</condition>
|
|
||||||
<condition property="has-ndk-build">
|
|
||||||
<equals arg1="${ndk-build-found}" arg2="true"/>
|
|
||||||
</condition>
|
|
||||||
</target>
|
|
||||||
</project>
|
|
@ -1,147 +0,0 @@
|
|||||||
<project name="vtm-jni-Linux-64" basedir="." default="postcompile">
|
|
||||||
<!-- include the environment -->
|
|
||||||
<property environment="env"/>
|
|
||||||
<!-- output directory for temporary object files -->
|
|
||||||
<property name="buildDir" value="target/linux64" />
|
|
||||||
<!-- output directory for the shared library -->
|
|
||||||
<property name="libsDir" value="../libs/linux64" />
|
|
||||||
<!-- the name of the shared library -->
|
|
||||||
<property name="libName" value="libvtm-jni64.so"/>
|
|
||||||
<!-- the jni header jniPlatform to use -->
|
|
||||||
<property name="jniPlatform" value="linux"/>
|
|
||||||
<!-- the compilerPrefix for the C & C++ compilers -->
|
|
||||||
<property name="compilerPrefix" value=""/>
|
|
||||||
<!-- the compilerSuffix for the C & C++ compilers -->
|
|
||||||
<property name="compilerSuffix" value="" />
|
|
||||||
|
|
||||||
<!-- define gcc compiler, options and files to compile -->
|
|
||||||
<property name="gcc" value="${compilerPrefix}gcc${compilerSuffix}"/>
|
|
||||||
<property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m64 -fPIC -Wall -std=c99 -O2 -DTRILIBRARY -DREDUCED -DCDT_ONLY -DNO_TIMER"/>
|
|
||||||
<fileset id="gcc-files" dir="./">
|
|
||||||
<exclude name="target/"/>
|
|
||||||
<include name="memcpy_wrap.c"/>
|
|
||||||
<include name="gl/utils.c"/>
|
|
||||||
<include name="triangle/TriangleJni.c"/>
|
|
||||||
<include name="triangle/triangle.c"/>
|
|
||||||
<include name="triangle/triangle_dbg.c"/>
|
|
||||||
|
|
||||||
|
|
||||||
</fileset>
|
|
||||||
|
|
||||||
<!-- define g++ compiler, options and files to compile -->
|
|
||||||
<property name="g++" value="${compilerPrefix}g++${compilerSuffix}"/>
|
|
||||||
<property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m64 -fPIC -Wall -std=c99 -O2 -DTRILIBRARY -DREDUCED -DCDT_ONLY -DNO_TIMER"/>
|
|
||||||
<fileset id="g++-files" dir="./">
|
|
||||||
<exclude name="target/"/>
|
|
||||||
<include name="**/*.cpp"/>
|
|
||||||
|
|
||||||
|
|
||||||
</fileset>
|
|
||||||
|
|
||||||
<!-- define linker and options -->
|
|
||||||
<property name="linker" value="${compilerPrefix}g++${compilerSuffix}"/>
|
|
||||||
<property name="linker-opts" value="-shared -m64 -Wl,-wrap,memcpy"/>
|
|
||||||
<property name="libraries" value=""/>
|
|
||||||
|
|
||||||
<!-- cleans the build directory, removes all object files and shared libs -->
|
|
||||||
<target name="clean">
|
|
||||||
<delete includeemptydirs="true" quiet="true">
|
|
||||||
<fileset dir="${buildDir}"/>
|
|
||||||
<fileset dir="${libsDir}" includes="**/*" excludes="**/.svn"/>
|
|
||||||
</delete>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="precompile">
|
|
||||||
<condition property="compiler-found">
|
|
||||||
<and>
|
|
||||||
<or>
|
|
||||||
<!-- Include both b/c Windows might be either -->
|
|
||||||
<available file="${g++}" filepath="${env.PATH}"/>
|
|
||||||
<available file="${g++}" filepath="${env.Path}"/>
|
|
||||||
</or>
|
|
||||||
<or>
|
|
||||||
<!-- Include both b/c Windows might be either -->
|
|
||||||
<available file="${gcc}" filepath="${env.PATH}"/>
|
|
||||||
<available file="${gcc}" filepath="${env.Path}"/>
|
|
||||||
</or>
|
|
||||||
</and>
|
|
||||||
</condition>
|
|
||||||
<condition property="has-compiler">
|
|
||||||
<equals arg1="${compiler-found}" arg2="true"/>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="create-build-dir" depends="precompile" if="has-compiler">
|
|
||||||
<!-- FIXME this is pretty nasty :/ -->
|
|
||||||
<copy todir="${buildDir}">
|
|
||||||
<fileset refid="g++-files"/>
|
|
||||||
<fileset refid="gcc-files"/>
|
|
||||||
</copy>
|
|
||||||
<delete>
|
|
||||||
<fileset dir="${buildDir}">
|
|
||||||
<include name="*"/>
|
|
||||||
<exclude name="*.o"/>
|
|
||||||
</fileset>
|
|
||||||
</delete>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- compiles all C and C++ files to object files in the build directory -->
|
|
||||||
<target name="compile" depends="create-build-dir" if="has-compiler">
|
|
||||||
<mkdir dir="${buildDir}"/>
|
|
||||||
<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
|
|
||||||
<arg line="${g++-opts}"/>
|
|
||||||
<arg value="-Ijni-headers"/>
|
|
||||||
<arg value="-Ijni-headers/${jniPlatform}"/>
|
|
||||||
<arg value="-I."/>
|
|
||||||
<arg value="-I."/>
|
|
||||||
|
|
||||||
<srcfile/>
|
|
||||||
<arg value="-o"/>
|
|
||||||
<targetfile/>
|
|
||||||
<fileset refid="g++-files"/>
|
|
||||||
<compositemapper>
|
|
||||||
<mapper type="glob" from="*.cpp" to="*.o"/>
|
|
||||||
<mapper type="glob" from="*.mm" to="*.o"/>
|
|
||||||
</compositemapper>
|
|
||||||
</apply>
|
|
||||||
<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
|
|
||||||
<arg line="${gcc-opts}"/>
|
|
||||||
<arg value="-Ijni-headers"/>
|
|
||||||
<arg value="-Ijni-headers/${jniPlatform}"/>
|
|
||||||
<arg value="-I."/>
|
|
||||||
<arg value="-I."/>
|
|
||||||
|
|
||||||
<srcfile/>
|
|
||||||
<arg value="-o"/>
|
|
||||||
<targetfile/>
|
|
||||||
<fileset refid="gcc-files"/>
|
|
||||||
<compositemapper>
|
|
||||||
<mapper type="glob" from="*.c" to="*.o"/>
|
|
||||||
<mapper type="glob" from="*.m" to="*.o"/>
|
|
||||||
</compositemapper>
|
|
||||||
</apply>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<!-- links the shared library based on the previously compiled object files -->
|
|
||||||
<target name="link" depends="compile" if="has-compiler">
|
|
||||||
<fileset dir="${buildDir}" id="objFileSet">
|
|
||||||
<patternset>
|
|
||||||
<include name="**/*.o" />
|
|
||||||
</patternset>
|
|
||||||
</fileset>
|
|
||||||
<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
|
|
||||||
<mkdir dir="${libsDir}" />
|
|
||||||
<exec executable="${linker}" failonerror="true" dir="${buildDir}">
|
|
||||||
<arg line="${linker-opts}" />
|
|
||||||
<arg value="-o" />
|
|
||||||
<arg path="${libsDir}/${libName}" />
|
|
||||||
<arg line="${objFiles}"/>
|
|
||||||
<arg line="${libraries}" />
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="postcompile" depends="link">
|
|
||||||
|
|
||||||
</target>
|
|
||||||
</project>
|
|
@ -1,23 +0,0 @@
|
|||||||
<project name="vtm-jni-natives" basedir="." default="all">
|
|
||||||
<target name="clean">
|
|
||||||
<ant antfile="build-linux64.xml" target="clean"/>
|
|
||||||
<ant antfile="build-android32.xml" target="clean"/>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="compile-natives">
|
|
||||||
<ant antfile="build-linux64.xml"/>
|
|
||||||
<ant antfile="build-android32.xml"/>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="pack-natives">
|
|
||||||
<jar destfile="../libs/vtm-jni-natives.jar">
|
|
||||||
<fileset dir="../libs/linux64" includes="libvtm-jni64.so"/>
|
|
||||||
<fileset dir="../libs/android32" includes="libvtm-jni.so"/>
|
|
||||||
|
|
||||||
</jar>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="all" depends="compile-natives,pack-natives"/>
|
|
||||||
</project>
|
|
@ -1,4 +1,3 @@
|
|||||||
package org.oscim.jni;
|
|
||||||
|
|
||||||
|
|
||||||
import com.badlogic.gdx.jnigen.AntScriptGenerator;
|
import com.badlogic.gdx.jnigen.AntScriptGenerator;
|
||||||
@ -9,8 +8,28 @@ import com.badlogic.gdx.jnigen.BuildTarget.TargetOs;
|
|||||||
public class JniBuilder {
|
public class JniBuilder {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String[] headers = { "." };
|
String[] headers = { "." };
|
||||||
String[] sources = { "gl/utils.c", "triangle/TriangleJni.c", "triangle/triangle.c", "triangle/triangle_dbg.c" };
|
String[] sources = {
|
||||||
String cflags = " -Wall -std=c99 -O2 -DTRILIBRARY -DREDUCED -DCDT_ONLY -DNO_TIMER"; // -Werror";
|
// Matrix stuff
|
||||||
|
"gl/utils.c",
|
||||||
|
// Triangle
|
||||||
|
"triangle/TriangleJni.c",
|
||||||
|
"triangle/triangle.c",
|
||||||
|
"triangle/triangle_dbg.c",
|
||||||
|
// libtessellate
|
||||||
|
"tessellate/dict.c",
|
||||||
|
"tessellate/mesh.c",
|
||||||
|
"tessellate/render.c",
|
||||||
|
"tessellate/tess.c",
|
||||||
|
"tessellate/geom.c",
|
||||||
|
"tessellate/memalloc.c",
|
||||||
|
"tessellate/normal.c",
|
||||||
|
"tessellate/priorityq.c",
|
||||||
|
"tessellate/sweep.c",
|
||||||
|
"tessellate/tessmono.c",
|
||||||
|
"tessellate/tessellate.c"
|
||||||
|
};
|
||||||
|
|
||||||
|
String cflags = " -Wall -std=c99 -O2 -ffast-math -DTRILIBRARY -DREDUCED -DCDT_ONLY -DNO_TIMER";
|
||||||
|
|
||||||
BuildTarget win32home = BuildTarget.newDefaultTarget(TargetOs.Windows,
|
BuildTarget win32home = BuildTarget.newDefaultTarget(TargetOs.Windows,
|
||||||
false);
|
false);
|
||||||
@ -73,8 +92,13 @@ public class JniBuilder {
|
|||||||
new AntScriptGenerator().generate(new BuildConfig("vtm-jni"),
|
new AntScriptGenerator().generate(new BuildConfig("vtm-jni"),
|
||||||
//win32home, win32, win64, lin32,
|
//win32home, win32, win64, lin32,
|
||||||
lin64, android);
|
lin64, android);
|
||||||
|
|
||||||
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v clean");
|
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v clean");
|
||||||
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v");
|
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v");
|
||||||
// BuildExecutor.executeAnt("jni/build.xml", "pack-natives -v");
|
// BuildExecutor.executeAnt("jni/build.xml", "pack-natives -v");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,9 +9,10 @@
|
|||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef uintptr_t
|
//#ifndef uintptr_t
|
||||||
typedef unsigned long uintptr_t;
|
//typedef unsigned long uintptr_t;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
typedef struct Triangle {
|
typedef struct Triangle {
|
||||||
@ -167,7 +168,7 @@ void begin(GLenum which, void *poly_data)
|
|||||||
ctx->vertex_cb = &fan_vertex;
|
ctx->vertex_cb = &fan_vertex;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf(stderr, "ERROR, can't handle %d\n", (int) which);
|
//printf(stderr, "ERROR, can't handle %d\n", (int) which);
|
||||||
ctx->vertex_cb = &skip_vertex;
|
ctx->vertex_cb = &skip_vertex;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -249,6 +250,46 @@ TessContext *tessellate(
|
|||||||
|
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TessContext *tessellateD(
|
||||||
|
int *nverts,
|
||||||
|
int *ntris,
|
||||||
|
const double **contoursbegin,
|
||||||
|
const double **contoursend)
|
||||||
|
{
|
||||||
|
const double *contourbegin, *contourend;
|
||||||
|
Vertex *current_vertex;
|
||||||
|
GLUtesselator *tess;
|
||||||
|
TessContext *ctx;
|
||||||
|
|
||||||
|
tess = gluNewTess();
|
||||||
|
ctx = new_tess_context();
|
||||||
|
|
||||||
|
gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (GLvoid (*)()) &vertex);
|
||||||
|
gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (GLvoid (*)()) &begin);
|
||||||
|
gluTessCallback(tess, GLU_TESS_COMBINE_DATA, (GLvoid (*)()) &combine);
|
||||||
|
|
||||||
|
gluTessBeginPolygon(tess, ctx);
|
||||||
|
do {
|
||||||
|
contourbegin = *contoursbegin++;
|
||||||
|
contourend = *contoursbegin;
|
||||||
|
gluTessBeginContour(tess);
|
||||||
|
while (contourbegin != contourend) {
|
||||||
|
current_vertex = new_vertex(ctx, contourbegin[0], contourbegin[1]);
|
||||||
|
contourbegin += 2;
|
||||||
|
gluTessVertex(tess, current_vertex->pt, current_vertex);
|
||||||
|
}
|
||||||
|
gluTessEndContour(tess);
|
||||||
|
} while (contoursbegin != (contoursend - 1));
|
||||||
|
gluTessEndPolygon(tess);
|
||||||
|
|
||||||
|
//write_output(ctx, verts, tris, nverts, ntris);
|
||||||
|
//destroy_tess_context(ctx);
|
||||||
|
|
||||||
|
gluDeleteTess(tess);
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
#define printf(...) __android_log_print(ANDROID_LOG_DEBUG, "Tesselate", __VA_ARGS__)
|
#define printf(...) __android_log_print(ANDROID_LOG_DEBUG, "Tesselate", __VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
@ -287,8 +328,8 @@ jint Java_org_oscim_renderer_sublayers_MeshLayer_tessGetCoordinates(JNIEnv *env,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int n_verts = 1 + ctx->latest_v->index;
|
//int n_verts = 1 + ctx->latest_v->index;
|
||||||
int n_tris_copy = ctx->n_tris;
|
//int n_tris_copy = ctx->n_tris;
|
||||||
|
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
for (; ctx->latest_v && cnt < length; cnt += 2) {
|
for (; ctx->latest_v && cnt < length; cnt += 2) {
|
||||||
@ -303,6 +344,33 @@ jint Java_org_oscim_renderer_sublayers_MeshLayer_tessGetCoordinates(JNIEnv *env,
|
|||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jint Java_org_oscim_renderer_sublayers_MeshLayer_tessGetCoordinatesD(JNIEnv *env, jclass c,
|
||||||
|
jlong ptr_context, jdoubleArray obj_coords) {
|
||||||
|
|
||||||
|
TessContext *ctx = CAST_CTX(ptr_context);
|
||||||
|
|
||||||
|
int length = (*env)->GetArrayLength(env, obj_coords);
|
||||||
|
|
||||||
|
jdouble* coords = (jdouble*) (*env)->GetPrimitiveArrayCritical(env, obj_coords, 0);
|
||||||
|
if (coords == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//int n_verts = 1 + ctx->latest_v->index;
|
||||||
|
//int n_tris_copy = ctx->n_tris;
|
||||||
|
|
||||||
|
int cnt = 0;
|
||||||
|
for (; ctx->latest_v && cnt < length; cnt += 2) {
|
||||||
|
coords[cnt + 0] = ctx->latest_v->pt[0];
|
||||||
|
coords[cnt + 1] = ctx->latest_v->pt[1];
|
||||||
|
Vertex *prev = ctx->latest_v->prev;
|
||||||
|
free(ctx->latest_v);
|
||||||
|
ctx->latest_v = prev;
|
||||||
|
}
|
||||||
|
(*env)->ReleasePrimitiveArrayCritical(env, obj_coords, coords, JNI_ABORT);
|
||||||
|
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
jint Java_org_oscim_renderer_sublayers_MeshLayer_tessGetIndices(JNIEnv *env, jclass c,
|
jint Java_org_oscim_renderer_sublayers_MeshLayer_tessGetIndices(JNIEnv *env, jclass c,
|
||||||
jlong ptr_context, jshortArray obj_indices) {
|
jlong ptr_context, jshortArray obj_indices) {
|
||||||
|
|
||||||
@ -380,3 +448,48 @@ jlong Java_org_oscim_renderer_sublayers_MeshLayer_tessellate(JNIEnv *env, jclass
|
|||||||
|
|
||||||
return (long) ctx;
|
return (long) ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jlong Java_org_oscim_renderer_sublayers_MeshLayer_tessellateD(JNIEnv *env, jclass c,
|
||||||
|
jdoubleArray obj_points, jint pos,
|
||||||
|
jshortArray obj_index, jint ipos,
|
||||||
|
jint num_rings) { //, jintArray obj_out) {
|
||||||
|
|
||||||
|
jboolean isCopy;
|
||||||
|
|
||||||
|
printf("add %d %d %d\n", pos, ipos, num_rings);
|
||||||
|
|
||||||
|
double* orig_points = (double*) (*env)->GetPrimitiveArrayCritical(env, obj_points, &isCopy);
|
||||||
|
if (orig_points == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
const double *points = orig_points + pos;
|
||||||
|
|
||||||
|
jshort* orig_indices = (jshort*) (*env)->GetPrimitiveArrayCritical(env, obj_index, &isCopy);
|
||||||
|
if (orig_indices == NULL) {
|
||||||
|
(*env)->ReleasePrimitiveArrayCritical(env, obj_points, orig_points, JNI_ABORT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
jshort* indices = orig_indices + ipos;
|
||||||
|
|
||||||
|
const double **rings = malloc(sizeof(double*) * (num_rings + 1));
|
||||||
|
int offset = 0;
|
||||||
|
for (int i = 0; i < num_rings; i++) {
|
||||||
|
rings[i] = points + offset;
|
||||||
|
offset += indices[i];
|
||||||
|
}
|
||||||
|
rings[num_rings] = points + offset;
|
||||||
|
|
||||||
|
int nverts, ntris;
|
||||||
|
|
||||||
|
TessContext *ctx = tessellateD(&nverts, &ntris,
|
||||||
|
rings, rings + (num_rings + 1));
|
||||||
|
|
||||||
|
free(rings);
|
||||||
|
|
||||||
|
(*env)->ReleasePrimitiveArrayCritical(env, obj_index, orig_indices, JNI_ABORT);
|
||||||
|
(*env)->ReleasePrimitiveArrayCritical(env, obj_points, orig_points, JNI_ABORT);
|
||||||
|
|
||||||
|
return (long) ctx;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user