29 |
using Renderables::Renderable1; |
using Renderables::Renderable1; |
30 |
using Renderables::Renderable2; |
using Renderables::Renderable2; |
31 |
using Renderables::TextRenderer; |
using Renderables::TextRenderer; |
|
using Renderables::AffineCoords; |
|
32 |
|
|
33 |
// XXX MEMLEAK |
// XXX MEMLEAK |
34 |
struct RealFont { |
struct RealFont { |
53 |
|
|
54 |
extern ObjectStorer<Paper::Paper> papers; |
extern ObjectStorer<Paper::Paper> papers; |
55 |
|
|
56 |
Renderables::Renderer<AffineCoords> renderer; |
Renderables::Renderer renderer; |
57 |
|
|
58 |
Mosaic::MosaicBuilder *mosaicbuilder; |
Mosaic::MosaicBuilder *mosaicbuilder; |
59 |
|
|
818 |
|
|
819 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_renderImpl |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_renderImpl |
820 |
(JNIEnv *env, jclass, jint window, |
(JNIEnv *env, jclass, jint window, |
821 |
jintArray codes, jfloatArray pts1, jintArray indices2, |
jint numinds, |
822 |
jfloatArray pts2, |
jintArray j_inds1, jfloatArray j_pts1, |
823 |
jint numpts, jfloat fract, jboolean standardcoords, |
jintArray j_interpinds, |
824 |
jboolean showFinal) { |
jintArray j_inds2, jfloatArray j_pts2, |
825 |
|
jintArray j_codes, |
826 |
|
jfloat fract, jboolean standardcoords, jboolean showFinal) { |
827 |
DBG(dbg) << "RENDER\n"; |
DBG(dbg) << "RENDER\n"; |
828 |
GLERR |
GLERR |
829 |
if(standardcoords) |
if(standardcoords) |
833 |
sizeof(jfloat) != sizeof(float)) |
sizeof(jfloat) != sizeof(float)) |
834 |
env->FatalError("Invalid data type sizes!"); |
env->FatalError("Invalid data type sizes!"); |
835 |
|
|
836 |
jint *ncodes = env->GetIntArrayElements(codes, 0); |
jint *inds1 = env->GetIntArrayElements(j_inds1, 0); |
837 |
jfloat *npts1 = env->GetFloatArrayElements(pts1, 0); |
jfloat *pts1 = env->GetFloatArrayElements(j_pts1, 0); |
838 |
jint *ninds2 = 0; |
jint *interpinds = env->GetIntArrayElements(j_interpinds, 0); |
839 |
if(indices2 != 0) { |
|
840 |
ninds2 = env->GetIntArrayElements(indices2, 0); |
jint *inds2 = 0; |
841 |
|
jfloat *pts2 = 0; |
842 |
|
if(j_inds2 != 0) { |
843 |
|
inds2 = env->GetIntArrayElements(j_inds2, 0); |
844 |
|
pts2 = env->GetFloatArrayElements(j_pts2, 0); |
845 |
} |
} |
846 |
jfloat *npts2 = env->GetFloatArrayElements(pts2, 0); |
|
847 |
|
jint *codes = env->GetIntArrayElements(j_codes, 0); |
848 |
|
|
849 |
DBG(dbg) << "Got data\n"; |
DBG(dbg) << "Got data\n"; |
850 |
|
|
851 |
renderer.setPoints(numpts, npts1, (int *)ninds2, npts2, fract, showFinal); |
renderer.setPoints(numinds, |
852 |
|
inds1, pts1, |
853 |
|
interpinds, |
854 |
|
inds2, pts2, |
855 |
|
fract, showFinal); |
856 |
|
|
857 |
DBG(dbg) << "Set datapoints\n"; |
DBG(dbg) << "Set datapoints\n"; |
858 |
|
|
867 |
GLERR |
GLERR |
868 |
|
|
869 |
DBG(dbg) << "Did stdcoords\n"; |
DBG(dbg) << "Did stdcoords\n"; |
870 |
renderer.renderScene((int *)ncodes, renderable0s, renderable1s, renderable2s); |
renderer.renderScene((int *)codes, renderable0s, renderable1s, renderable2s); |
871 |
DBG(dbg) << "Did renderscene\n"; |
DBG(dbg) << "Did renderscene\n"; |
872 |
windows.get(window)->swapBuffers(); |
windows.get(window)->swapBuffers(); |
873 |
DBG(dbg) << "Did swapbuffers\n"; |
DBG(dbg) << "Did swapbuffers\n"; |
874 |
|
|
875 |
env->ReleaseIntArrayElements(codes, ncodes, JNI_ABORT); |
env->ReleaseIntArrayElements(j_codes, codes, JNI_ABORT); |
|
|
|
|
env->ReleaseFloatArrayElements(pts1, npts1, JNI_ABORT); |
|
|
env->ReleaseFloatArrayElements(pts2, npts2, JNI_ABORT); |
|
876 |
|
|
877 |
if(indices2 != 0) { |
env->ReleaseIntArrayElements(j_inds1, inds1, JNI_ABORT); |
878 |
env->ReleaseIntArrayElements(indices2, ninds2, JNI_ABORT); |
env->ReleaseFloatArrayElements(j_pts1, pts1, JNI_ABORT); |
879 |
|
env->ReleaseIntArrayElements(j_interpinds, interpinds, JNI_ABORT); |
880 |
|
|
881 |
|
if(inds2 != 0) { |
882 |
|
env->ReleaseIntArrayElements(j_inds2, inds2, JNI_ABORT); |
883 |
|
env->ReleaseFloatArrayElements(j_pts2, pts2, JNI_ABORT); |
884 |
} |
} |
885 |
DBG(dbg) << "Did releasearrays\n"; |
DBG(dbg) << "Did releasearrays\n"; |
886 |
GLERR |
GLERR |
900 |
} |
} |
901 |
|
|
902 |
JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GL_timeRenderImpl |
JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GL_timeRenderImpl |
903 |
(JNIEnv *env, jclass, jint window, |
(JNIEnv *env, jclass, jint window, jint iters, |
904 |
jintArray codes, jfloatArray pts1, |
jint numinds, |
905 |
jint numpts, jboolean standardcoords, jint iters) { |
jintArray j_inds1, jfloatArray j_pts1, |
906 |
|
jintArray j_codes, |
907 |
|
jboolean standardcoords) { |
908 |
DBG(dbg) << "RENDER\n"; |
DBG(dbg) << "RENDER\n"; |
909 |
GLERR |
GLERR |
910 |
if(standardcoords) |
if(standardcoords) |
914 |
sizeof(jfloat) != sizeof(float)) |
sizeof(jfloat) != sizeof(float)) |
915 |
env->FatalError("Invalid data type sizes!"); |
env->FatalError("Invalid data type sizes!"); |
916 |
|
|
917 |
jint *ncodes = env->GetIntArrayElements(codes, 0); |
jint *inds1 = env->GetIntArrayElements(j_inds1, 0); |
918 |
jfloat *npts1 = env->GetFloatArrayElements(pts1, 0); |
jfloat *pts1 = env->GetFloatArrayElements(j_pts1, 0); |
919 |
|
|
920 |
|
jint *codes = env->GetIntArrayElements(j_codes, 0); |
921 |
|
|
922 |
DBG(dbg) << "Got data\n"; |
DBG(dbg) << "Got data\n"; |
923 |
|
|
924 |
renderer.setPoints(numpts, npts1); |
renderer.setPoints(numinds, |
925 |
|
inds1, pts1); |
926 |
|
|
927 |
DBG(dbg) << "Set datapoints\n"; |
DBG(dbg) << "Set datapoints\n"; |
928 |
|
|
936 |
} |
} |
937 |
GLERR |
GLERR |
938 |
|
|
|
DBG(dbg) << "Did stdcoords\n"; |
|
939 |
|
|
940 |
double t0 = getTime(); |
double t0 = getTime(); |
941 |
for (int i = 0; i < iters; i++) { |
for (int i = 0; i < iters; i++) { |
942 |
renderer.renderScene((int *)ncodes, renderable0s, renderable1s, renderable2s); |
renderer.renderScene((int *)codes, renderable0s, renderable1s, renderable2s); |
943 |
DBG(dbg) << "Did renderscene\n"; |
DBG(dbg) << "Did renderscene\n"; |
944 |
windows.get(window)->swapBuffers(); |
windows.get(window)->swapBuffers(); |
945 |
DBG(dbg) << "Did swapbuffers\n"; |
DBG(dbg) << "Did swapbuffers\n"; |
948 |
float t = t1 - t0; |
float t = t1 - t0; |
949 |
DBG(dbg) << "The time was " << t << " [" << t0 << " - " << t1 << "]\n"; |
DBG(dbg) << "The time was " << t << " [" << t0 << " - " << t1 << "]\n"; |
950 |
|
|
951 |
env->ReleaseIntArrayElements(codes, ncodes, JNI_ABORT); |
env->ReleaseIntArrayElements(j_codes, codes, JNI_ABORT); |
952 |
|
|
953 |
env->ReleaseFloatArrayElements(pts1, npts1, JNI_ABORT); |
env->ReleaseIntArrayElements(j_inds1, inds1, JNI_ABORT); |
954 |
|
env->ReleaseFloatArrayElements(j_pts1, pts1, JNI_ABORT); |
955 |
|
|
956 |
DBG(dbg) << "Did releasearrays\n"; |
DBG(dbg) << "Did releasearrays\n"; |
957 |
GLERR |
GLERR |
960 |
releaseWindow(); |
releaseWindow(); |
961 |
} |
} |
962 |
|
|
963 |
|
return t; |
|
return t; |
|
964 |
} |
} |
965 |
|
|
966 |
|
|
967 |
|
|
968 |
|
|
969 |
|
|
970 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_setDebugVar |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_setDebugVar |
971 |
(JNIEnv *env, jclass, jstring name, jint value) { |
(JNIEnv *env, jclass, jstring name, jint value) { |
972 |
const char *utf = env->GetStringUTFChars(name, 0); |
const char *utf = env->GetStringUTFChars(name, 0); |