1 |
|
|
2 |
#include <vector> |
#include <vector> |
3 |
#include "gzz_gfx_gl_GZZGL.h" |
#include "gzz_gfx_gl_GL.h" |
4 |
|
|
5 |
#include "librenderables/Renderables.hxx" |
#include "librenderables/Renderables.hxx" |
6 |
#include "librenderables/RealRenderables.hxx" |
#include "librenderables/RealRenderables.hxx" |
186 |
|
|
187 |
int inited = 0; |
int inited = 0; |
188 |
|
|
189 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_init |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_init |
190 |
(JNIEnv *env, jclass, jint) { |
(JNIEnv *env, jclass, jint) { |
191 |
if(inited++) { |
if(inited++) { |
192 |
cerr << "Already inited: "<<(inited-1)<<"\n"; |
cerr << "Already inited: "<<(inited-1)<<"\n"; |
221 |
|
|
222 |
// Window |
// Window |
223 |
|
|
224 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_createWindowImpl |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_createWindowImpl |
225 |
(JNIEnv *env, jclass, jint x, jint y, jint w, jint h, jobject eh) { |
(JNIEnv *env, jclass, jint x, jint y, jint w, jint h, jobject eh) { |
226 |
DBG(dbg) << "Creating new window for Java "<<x<<" "<<y<<" "<<w<<" "<<h<<"\n"; |
DBG(dbg) << "Creating new window for Java "<<x<<" "<<y<<" "<<w<<" "<<h<<"\n"; |
227 |
jobject ehglobal = env->NewGlobalRef(eh); |
jobject ehglobal = env->NewGlobalRef(eh); |
233 |
return windows.add(win); |
return windows.add(win); |
234 |
} |
} |
235 |
|
|
236 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_deleteWindow |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_deleteWindow |
237 |
(JNIEnv *env, jclass, jint id) { |
(JNIEnv *env, jclass, jint id) { |
238 |
|
|
239 |
// Window *w = windows.get(id); |
// Window *w = windows.get(id); |
242 |
windows.remove(id); |
windows.remove(id); |
243 |
} |
} |
244 |
|
|
245 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_repaintWindow |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_repaintWindow |
246 |
(JNIEnv *env, jclass, jint id) { |
(JNIEnv *env, jclass, jint id) { |
247 |
DBG(dbg_event) << "RepaintWindow called\n"; |
DBG(dbg_event) << "RepaintWindow called\n"; |
248 |
Os::Window *w = windows.get(id); |
Os::Window *w = windows.get(id); |
249 |
w->repaint(); |
w->repaint(); |
250 |
} |
} |
251 |
|
|
252 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_getWindowSize |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_getWindowSize |
253 |
(JNIEnv *env, jclass, jint id, jobject rect) { |
(JNIEnv *env, jclass, jint id, jobject rect) { |
254 |
Os::Window *win = windows.get(id); |
Os::Window *win = windows.get(id); |
255 |
int xywh[4]; |
int xywh[4]; |
269 |
|
|
270 |
} |
} |
271 |
|
|
272 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_addTimeoutWindow |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_addTimeoutWindow |
273 |
(JNIEnv *env, jclass, jint id, jint ms, jint tid) { |
(JNIEnv *env, jclass, jint id, jint ms, jint tid) { |
274 |
Os::Window *w = windows.get(id); |
Os::Window *w = windows.get(id); |
275 |
w->addTimeout(ms, tid); |
w->addTimeout(ms, tid); |
276 |
} |
} |
277 |
|
|
278 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_impl_1Window_1setCurrent |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Window_1setCurrent |
279 |
(JNIEnv *env, jclass, jint id) { |
(JNIEnv *env, jclass, jint id) { |
280 |
setWindow(id); |
setWindow(id); |
281 |
} |
} |
282 |
|
|
283 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_impl_1Window_1release |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Window_1release |
284 |
(JNIEnv *env, jclass, jint id) { |
(JNIEnv *env, jclass, jint id) { |
285 |
releaseWindow(); |
releaseWindow(); |
286 |
} |
} |
287 |
|
|
288 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_impl_1Window_1move |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Window_1move |
289 |
(JNIEnv *env, jclass, jint id, jint x, jint y) { |
(JNIEnv *env, jclass, jint id, jint x, jint y) { |
290 |
windows.get(id)->move(x,y); |
windows.get(id)->move(x,y); |
291 |
} |
} |
292 |
|
|
293 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_impl_1Window_1resize |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Window_1resize |
294 |
(JNIEnv *env, jclass, jint id, jint w, jint h) { |
(JNIEnv *env, jclass, jint id, jint w, jint h) { |
295 |
windows.get(id)->resize(w,h); |
windows.get(id)->resize(w,h); |
296 |
} |
} |
328 |
|
|
329 |
// Image |
// Image |
330 |
|
|
331 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_createImageImpl |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_createImageImpl |
332 |
(JNIEnv *env, jclass, jstring filename) { |
(JNIEnv *env, jclass, jstring filename) { |
333 |
const char *utf = env->GetStringUTFChars(filename, 0); |
const char *utf = env->GetStringUTFChars(filename, 0); |
334 |
Image *img = ws->loadImageFile(utf); |
Image *img = ws->loadImageFile(utf); |
336 |
return images.add(img); |
return images.add(img); |
337 |
} |
} |
338 |
|
|
339 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_deleteImage |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_deleteImage |
340 |
(JNIEnv *, jclass, jint img) { |
(JNIEnv *, jclass, jint img) { |
341 |
images.remove(img); |
images.remove(img); |
342 |
} |
} |
343 |
|
|
344 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_getImageSize |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_getImageSize |
345 |
(JNIEnv *, jclass, jint img, jint dimNo) { |
(JNIEnv *, jclass, jint img, jint dimNo) { |
346 |
Image *i = images[img]; |
Image *i = images[img]; |
347 |
if(dimNo == 0) |
if(dimNo == 0) |
352 |
|
|
353 |
// TexRect |
// TexRect |
354 |
|
|
355 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_createTexRectImpl |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_createTexRectImpl |
356 |
(JNIEnv *, jclass, jint id) |
(JNIEnv *, jclass, jint id) |
357 |
{ |
{ |
358 |
DBG(dbg) << "CreateTexRectImpl\n"; |
DBG(dbg) << "CreateTexRectImpl\n"; |
373 |
return imagetiles.add(t); |
return imagetiles.add(t); |
374 |
} |
} |
375 |
|
|
376 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_deleteTexRect |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_deleteTexRect |
377 |
(JNIEnv *, jclass, jint id) |
(JNIEnv *, jclass, jint id) |
378 |
{ |
{ |
379 |
// MEMLEAK! MUST FREE MOSAICTILE FIRST! |
// MEMLEAK! MUST FREE MOSAICTILE FIRST! |
380 |
imagetiles.remove(id); |
imagetiles.remove(id); |
381 |
} |
} |
382 |
|
|
383 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_getTexRectTexID |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_getTexRectTexID |
384 |
(JNIEnv *, jclass, jint id) |
(JNIEnv *, jclass, jint id) |
385 |
{ |
{ |
386 |
return imagetiles[id]->getRect().tex.getTexId(); |
return imagetiles[id]->getRect().tex.getTexId(); |
387 |
} |
} |
388 |
|
|
389 |
JNIEXPORT jdouble JNICALL Java_gzz_gfx_gl_GZZGL_getTexRectTexCoord |
JNIEXPORT jdouble JNICALL Java_gzz_gfx_gl_GL_getTexRectTexCoord |
390 |
(JNIEnv *, jclass, jint id, jint coord, double v) |
(JNIEnv *, jclass, jint id, jint coord, double v) |
391 |
{ |
{ |
392 |
Mosaic::Rect &rect = imagetiles[id]->getRect(); |
Mosaic::Rect &rect = imagetiles[id]->getRect(); |
398 |
} |
} |
399 |
|
|
400 |
// Texture |
// Texture |
401 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_impl_1createTexture |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_impl_1createTexture |
402 |
(JNIEnv *, jclass) { |
(JNIEnv *, jclass) { |
403 |
setWindow(); |
setWindow(); |
404 |
GLuint ret; |
GLuint ret; |
409 |
return ret; |
return ret; |
410 |
} |
} |
411 |
|
|
412 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_impl_1deleteTexture |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1deleteTexture |
413 |
(JNIEnv *, jclass, jint id) { |
(JNIEnv *, jclass, jint id) { |
414 |
setWindow(); |
setWindow(); |
415 |
GLuint rel = id; |
GLuint rel = id; |
424 |
return ret; |
return ret; |
425 |
} |
} |
426 |
|
|
427 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_impl_1Texture_1loadNull2D |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Texture_1loadNull2D |
428 |
(JNIEnv *env, jclass, jint id, jint level, jstring internalFormat_s, |
(JNIEnv *env, jclass, jint id, jint level, jstring internalFormat_s, |
429 |
jint w, jint h, jint border, jstring format_s, jstring type_s) { |
jint w, jint h, jint border, jstring format_s, jstring type_s) { |
430 |
int internalFormat = tokenFromJstring(env, internalFormat_s); |
int internalFormat = tokenFromJstring(env, internalFormat_s); |
439 |
GLERR |
GLERR |
440 |
} |
} |
441 |
|
|
442 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_impl_1Texture_1loadSubImage |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Texture_1loadSubImage |
443 |
(JNIEnv *env, jclass, jint id, jint level, jint imageId, jint xoffs, jint yoffs) { |
(JNIEnv *env, jclass, jint id, jint level, jint imageId, jint xoffs, jint yoffs) { |
444 |
|
|
445 |
glBindTexture(GL_TEXTURE_2D, id); |
glBindTexture(GL_TEXTURE_2D, id); |
451 |
GLERR |
GLERR |
452 |
} |
} |
453 |
|
|
454 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_impl_1Texture_1downsampleInto |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Texture_1downsampleInto |
455 |
(JNIEnv *env, jclass, jint id, jint intoid, jstring targetstr, jint level, jstring internalFormat, jstring transferType) |
(JNIEnv *env, jclass, jint id, jint intoid, jstring targetstr, jint level, jstring internalFormat, jstring transferType) |
456 |
{ |
{ |
457 |
GLenum target = tokenFromJstring(env, targetstr); |
GLenum target = tokenFromJstring(env, targetstr); |
483 |
|
|
484 |
} |
} |
485 |
|
|
486 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_impl_1Texture_1shade |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_impl_1Texture_1shade |
487 |
(JNIEnv *env, jclass, jint id, jint w, jint h, jint d, jint comp, |
(JNIEnv *env, jclass, jint id, jint w, jint h, jint d, jint comp, |
488 |
jstring internalFormat, |
jstring internalFormat, |
489 |
jstring format, |
jstring format, |
561 |
|
|
562 |
|
|
563 |
// VertexProgramNV |
// VertexProgramNV |
564 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_impl_1createVertexProgramNV |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_impl_1createVertexProgramNV |
565 |
(JNIEnv *, jclass) { |
(JNIEnv *, jclass) { |
566 |
setWindow(); |
setWindow(); |
567 |
GLuint ret; |
GLuint ret; |
573 |
return ret; |
return ret; |
574 |
} |
} |
575 |
|
|
576 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_impl_1deleteVertexProgramNV |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1deleteVertexProgramNV |
577 |
(JNIEnv *, jclass, jint id) { |
(JNIEnv *, jclass, jint id) { |
578 |
#ifdef GL_VERTEX_PROGRAM_NV |
#ifdef GL_VERTEX_PROGRAM_NV |
579 |
setWindow(); |
setWindow(); |
583 |
#endif |
#endif |
584 |
} |
} |
585 |
|
|
586 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_impl_1VertexProgramNV_1load |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_impl_1VertexProgramNV_1load |
587 |
(JNIEnv *env, jclass, jint id, jstring prog) { |
(JNIEnv *env, jclass, jint id, jstring prog) { |
588 |
#ifdef GL_VERTEX_PROGRAM_NV |
#ifdef GL_VERTEX_PROGRAM_NV |
589 |
setWindow(); |
setWindow(); |
600 |
|
|
601 |
// Font |
// Font |
602 |
|
|
603 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_createFontImpl |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_createFontImpl |
604 |
(JNIEnv *env, jclass, jstring file, jint pt) { |
(JNIEnv *env, jclass, jstring file, jint pt) { |
605 |
DBG(dbg) << "creatFontImpl\n"; |
DBG(dbg) << "creatFontImpl\n"; |
606 |
setWindow(); |
setWindow(); |
614 |
return fonts.add(f); |
return fonts.add(f); |
615 |
} |
} |
616 |
|
|
617 |
JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GZZGL_getFontHeight |
JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GL_getFontHeight |
618 |
(JNIEnv *, jclass, jint i) { |
(JNIEnv *, jclass, jint i) { |
619 |
return fonts.get(i)->f->getLineHeight(); |
return fonts.get(i)->f->getLineHeight(); |
620 |
} |
} |
621 |
|
|
622 |
JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GZZGL_getFontYOffs |
JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GL_getFontYOffs |
623 |
(JNIEnv *, jclass, jint i) { |
(JNIEnv *, jclass, jint i) { |
624 |
return fonts.get(i)->f->getLineOffset(); |
return fonts.get(i)->f->getLineOffset(); |
625 |
} |
} |
626 |
|
|
627 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_deleteFont |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_deleteFont |
628 |
(JNIEnv *, jclass, jint i) { |
(JNIEnv *, jclass, jint i) { |
629 |
fonts.remove(i); |
fonts.remove(i); |
630 |
} |
} |
631 |
|
|
632 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_putFontWidths |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_putFontWidths |
633 |
(JNIEnv *env, jclass, jint fontId, jshortArray widths) { |
(JNIEnv *env, jclass, jint fontId, jshortArray widths) { |
634 |
|
|
635 |
int arrayLength = env->GetArrayLength(widths); |
int arrayLength = env->GetArrayLength(widths); |
646 |
|
|
647 |
// DisplayList |
// DisplayList |
648 |
|
|
649 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_createDisplayListImpl |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_createDisplayListImpl |
650 |
(JNIEnv *, jclass) { |
(JNIEnv *, jclass) { |
651 |
setWindow(); |
setWindow(); |
652 |
int l = glGenLists(1); |
int l = glGenLists(1); |
657 |
} |
} |
658 |
return l; |
return l; |
659 |
} |
} |
660 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_startCompile |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_startCompile |
661 |
(JNIEnv *, jclass, jint l, jint wid) { |
(JNIEnv *, jclass, jint l, jint wid) { |
662 |
DBG(dbg) << "Start list compilation "<<l<<"\n"; |
DBG(dbg) << "Start list compilation "<<l<<"\n"; |
663 |
|
|
667 |
glNewList(l, GL_COMPILE); |
glNewList(l, GL_COMPILE); |
668 |
GLERR |
GLERR |
669 |
} |
} |
670 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_endCompile |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_endCompile |
671 |
(JNIEnv *, jclass, jint, jint wid) { |
(JNIEnv *, jclass, jint, jint wid) { |
672 |
DBG(dbg) << "End list compilation\n"; |
DBG(dbg) << "End list compilation\n"; |
673 |
GLERR |
GLERR |
677 |
releaseWindow(); |
releaseWindow(); |
678 |
} |
} |
679 |
|
|
680 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_compileCallGL |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_compileCallGL |
681 |
(JNIEnv *env, jclass, jint l, jstring s) { |
(JNIEnv *env, jclass, jint l, jstring s) { |
682 |
DBG(dbg) << "Start callgl\n"; |
DBG(dbg) << "Start callgl\n"; |
683 |
setWindow(); |
setWindow(); |
692 |
DBG(dbg) << "released window\n"; |
DBG(dbg) << "released window\n"; |
693 |
} |
} |
694 |
|
|
695 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_deleteDisplayList |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_deleteDisplayList |
696 |
(JNIEnv *, jclass, jint l) { |
(JNIEnv *, jclass, jint l) { |
697 |
DBG(dbg) << "Delete display list (XXX Might crash if contexts wrong)\n"; |
DBG(dbg) << "Delete display list (XXX Might crash if contexts wrong)\n"; |
698 |
glDeleteLists(l, 1); |
glDeleteLists(l, 1); |
701 |
|
|
702 |
// ByteVector |
// ByteVector |
703 |
// |
// |
704 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_createByteVectorImpl |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_createByteVectorImpl |
705 |
(JNIEnv *, jclass, jint size) { |
(JNIEnv *, jclass, jint size) { |
706 |
ByteVector *vec = new ByteVector(size); |
ByteVector *vec = new ByteVector(size); |
707 |
return bytevectors.add(vec); |
return bytevectors.add(vec); |
708 |
} |
} |
709 |
|
|
710 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_deleteByteVector |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_deleteByteVector |
711 |
(JNIEnv *, jclass, jint id) { |
(JNIEnv *, jclass, jint id) { |
712 |
bytevectors.remove(id); |
bytevectors.remove(id); |
713 |
} |
} |
714 |
|
|
715 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_impl_1ByteVector_1readFromBuffer_1ubytes |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1ByteVector_1readFromBuffer_1ubytes |
716 |
(JNIEnv *env, jclass, jint id, jint winid, jstring buffer, jint x, jint y, jint w, jint h, jstring format) |
(JNIEnv *env, jclass, jint id, jint winid, jstring buffer, jint x, jint y, jint w, jint h, jstring format) |
717 |
{ |
{ |
718 |
setWindow(winid); |
setWindow(winid); |
732 |
releaseWindow(); |
releaseWindow(); |
733 |
} |
} |
734 |
|
|
735 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_impl_1ByteVector_1get |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_impl_1ByteVector_1get |
736 |
(JNIEnv *env, jclass, jint id, jint ind) { |
(JNIEnv *env, jclass, jint id, jint ind) { |
737 |
return (*bytevectors[id])[ind]; |
return (*bytevectors[id])[ind]; |
738 |
} |
} |
740 |
|
|
741 |
// Renderable |
// Renderable |
742 |
|
|
743 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_deleteRenderable0 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_deleteRenderable0 |
744 |
(JNIEnv *, jclass, jint id) { |
(JNIEnv *, jclass, jint id) { |
745 |
renderable0s.remove(id); |
renderable0s.remove(id); |
746 |
} |
} |
747 |
|
|
748 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_deleteRenderable1 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_deleteRenderable1 |
749 |
(JNIEnv *, jclass, jint id) { |
(JNIEnv *, jclass, jint id) { |
750 |
renderable1s.remove(id); |
renderable1s.remove(id); |
751 |
} |
} |
752 |
|
|
753 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_deleteRenderable2 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_deleteRenderable2 |
754 |
(JNIEnv *, jclass, jint id) { |
(JNIEnv *, jclass, jint id) { |
755 |
renderable2s.remove(id); |
renderable2s.remove(id); |
756 |
} |
} |
757 |
// functions |
// functions |
758 |
|
|
759 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_startContext |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_startContext |
760 |
(JNIEnv *env, jclass) { |
(JNIEnv *env, jclass) { |
761 |
setWindow(); |
setWindow(); |
762 |
} |
} |
763 |
|
|
764 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_endContext |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_endContext |
765 |
(JNIEnv *env, jclass) { |
(JNIEnv *env, jclass) { |
766 |
releaseWindow(); |
releaseWindow(); |
767 |
} |
} |
768 |
|
|
769 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_eventLoop |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_eventLoop |
770 |
(JNIEnv *env, jclass, jboolean wait) { |
(JNIEnv *env, jclass, jboolean wait) { |
771 |
DBG(dbg) << "Going into eventloop in C++\n"; |
DBG(dbg) << "Going into eventloop in C++\n"; |
772 |
try { |
try { |
782 |
*/ |
*/ |
783 |
} |
} |
784 |
|
|
785 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_renderImpl |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_renderImpl |
786 |
(JNIEnv *env, jclass, jint window, |
(JNIEnv *env, jclass, jint window, |
787 |
jintArray codes, jfloatArray pts1, jintArray indices2, |
jintArray codes, jfloatArray pts1, jintArray indices2, |
788 |
jfloatArray pts2, |
jfloatArray pts2, |
852 |
return t.tv_usec*1E-6 + t.tv_sec; |
return t.tv_usec*1E-6 + t.tv_sec; |
853 |
} |
} |
854 |
|
|
855 |
JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GZZGL_timeRenderImpl |
JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GL_timeRenderImpl |
856 |
(JNIEnv *env, jclass, jint window, |
(JNIEnv *env, jclass, jint window, |
857 |
jintArray codes, jfloatArray pts1, |
jintArray codes, jfloatArray pts1, |
858 |
jint numpts, jboolean standardcoords, jint iters) { |
jint numpts, jboolean standardcoords, jint iters) { |
912 |
return t; |
return t; |
913 |
} |
} |
914 |
|
|
915 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_setDebugVar |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_setDebugVar |
916 |
(JNIEnv *env, jclass, jstring name, jint value) { |
(JNIEnv *env, jclass, jstring name, jint value) { |
917 |
const char *utf = env->GetStringUTFChars(name, 0); |
const char *utf = env->GetStringUTFChars(name, 0); |
918 |
Debug::var(utf) = value; |
Debug::var(utf) = value; |
919 |
env->ReleaseStringUTFChars(name, utf); |
env->ReleaseStringUTFChars(name, utf); |
920 |
} |
} |
921 |
|
|
922 |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GZZGL_getDebugVar |
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_getDebugVar |
923 |
(JNIEnv *env, jclass, jstring name) { |
(JNIEnv *env, jclass, jstring name) { |
924 |
const char *utf = env->GetStringUTFChars(name, 0); |
const char *utf = env->GetStringUTFChars(name, 0); |
925 |
int value = Debug::var(utf) ; |
int value = Debug::var(utf) ; |
927 |
return value; |
return value; |
928 |
} |
} |
929 |
|
|
930 |
JNIEXPORT jobjectArray Java_gzz_gfx_gl_GZZGL_getDebugVarNames |
JNIEXPORT jobjectArray Java_gzz_gfx_gl_GL_getDebugVarNames |
931 |
(JNIEnv *env, jclass) { |
(JNIEnv *env, jclass) { |
932 |
vector<const char *> vec; |
vector<const char *> vec; |
933 |
vec = Debug::getVarNames(); |
vec = Debug::getVarNames(); |
940 |
return result; |
return result; |
941 |
} |
} |
942 |
|
|
943 |
JNIEXPORT jstring JNICALL Java_gzz_gfx_gl_GZZGL_getGLString |
JNIEXPORT jstring JNICALL Java_gzz_gfx_gl_GL_getGLString |
944 |
(JNIEnv *env, jclass, jstring name) { |
(JNIEnv *env, jclass, jstring name) { |
945 |
const char *utf = env->GetStringUTFChars(name, 0); |
const char *utf = env->GetStringUTFChars(name, 0); |
946 |
const char *value = CallGL::getString(utf) ; |
const char *value = CallGL::getString(utf) ; |
948 |
return env->NewStringUTF(value); |
return env->NewStringUTF(value); |
949 |
} |
} |
950 |
|
|
951 |
JNIEXPORT jfloatArray JNICALL Java_gzz_gfx_gl_GZZGL_getGLFloat |
JNIEXPORT jfloatArray JNICALL Java_gzz_gfx_gl_GL_getGLFloat |
952 |
(JNIEnv *env, jclass, jstring name) { |
(JNIEnv *env, jclass, jstring name) { |
953 |
const char *utf = env->GetStringUTFChars(name, 0); |
const char *utf = env->GetStringUTFChars(name, 0); |
954 |
vector<float> vec = CallGL::getFloat(utf) ; |
vector<float> vec = CallGL::getFloat(utf) ; |
958 |
return result; |
return result; |
959 |
} |
} |
960 |
|
|
961 |
JNIEXPORT jfloatArray JNICALL Java_gzz_gfx_gl_GZZGL_getGLTexParameterFloat |
JNIEXPORT jfloatArray JNICALL Java_gzz_gfx_gl_GL_getGLTexParameterFloat |
962 |
(JNIEnv *env, jclass, jstring target, jint tex, jstring name) { |
(JNIEnv *env, jclass, jstring target, jint tex, jstring name) { |
963 |
const char *utf_target = env->GetStringUTFChars(target, 0); |
const char *utf_target = env->GetStringUTFChars(target, 0); |
964 |
const char *utf = env->GetStringUTFChars(name, 0); |
const char *utf = env->GetStringUTFChars(name, 0); |
970 |
return result; |
return result; |
971 |
} |
} |
972 |
|
|
973 |
JNIEXPORT jfloatArray JNICALL Java_gzz_gfx_gl_GZZGL_getGLTexLevelParameterFloat |
JNIEXPORT jfloatArray JNICALL Java_gzz_gfx_gl_GL_getGLTexLevelParameterFloat |
974 |
(JNIEnv *env, jclass, jstring target, jint tex, jint level, jstring name) { |
(JNIEnv *env, jclass, jstring target, jint tex, jint level, jstring name) { |
975 |
const char *utf_target = env->GetStringUTFChars(target, 0); |
const char *utf_target = env->GetStringUTFChars(target, 0); |
976 |
const char *utf = env->GetStringUTFChars(name, 0); |
const char *utf = env->GetStringUTFChars(name, 0); |
982 |
return result; |
return result; |
983 |
} |
} |
984 |
|
|
985 |
JNIEXPORT jstring JNICALL Java_gzz_gfx_gl_GZZGL_getGLTokenString |
JNIEXPORT jstring JNICALL Java_gzz_gfx_gl_GL_getGLTokenString |
986 |
(JNIEnv *env, jclass, jint value) { |
(JNIEnv *env, jclass, jint value) { |
987 |
const char *str = CallGL::getTokenString(value) ; |
const char *str = CallGL::getTokenString(value) ; |
988 |
return env->NewStringUTF(str); |
return env->NewStringUTF(str); |
990 |
|
|
991 |
GLuint buf[1600 * 1200]; |
GLuint buf[1600 * 1200]; |
992 |
|
|
993 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_reallyClearStencilBuffer |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_reallyClearStencilBuffer |
994 |
(JNIEnv *env, jclass, jint w, jint h) { |
(JNIEnv *env, jclass, jint w, jint h) { |
995 |
|
|
996 |
if(w*h > 1600*1200) return; |
if(w*h > 1600*1200) return; |