30 |
using Renderables::Renderable2; |
using Renderables::Renderable2; |
31 |
using Renderables::TextRenderer; |
using Renderables::TextRenderer; |
32 |
|
|
33 |
|
namespace CurrentFPS { |
34 |
|
// bool showFPS; |
35 |
|
double current_fps; |
36 |
|
double last_time; |
37 |
|
} |
38 |
|
|
39 |
|
|
40 |
// XXX MEMLEAK |
// XXX MEMLEAK |
41 |
struct RealFont { |
struct RealFont { |
42 |
Text::Font *f; |
Text::Font *f; |
69 |
DBGVAR(dbg, "JNI.general"); |
DBGVAR(dbg, "JNI.general"); |
70 |
DBGVAR(dbg_event, "JNI.event"); |
DBGVAR(dbg_event, "JNI.event"); |
71 |
|
|
72 |
|
// FPS |
73 |
|
DBGVAR(dbg_fps, "JNI.fps"); |
74 |
|
DBGVAR(dbg_fps_cout, "JNI.fps_console"); |
75 |
|
|
76 |
struct JavaException { }; |
struct JavaException { }; |
77 |
|
|
78 |
JNIEnv *jnienv_eventloop; |
JNIEnv *jnienv_eventloop; |
827 |
*/ |
*/ |
828 |
} |
} |
829 |
|
|
830 |
|
#include <sys/time.h> |
831 |
|
double getTime() { |
832 |
|
struct timeval t; |
833 |
|
gettimeofday(&t, 0); |
834 |
|
return t.tv_usec*1E-6 + t.tv_sec; |
835 |
|
} |
836 |
|
|
837 |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_renderImpl |
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_renderImpl |
838 |
(JNIEnv *env, jclass, jint window, |
(JNIEnv *env, jclass, jint window, |
839 |
jint numinds, |
jint numinds, |
908 |
} |
} |
909 |
|
|
910 |
|
|
911 |
|
if(dbg_fps) { |
912 |
|
double new_time = getTime(); |
913 |
|
CurrentFPS::current_fps = 1.0/(new_time - CurrentFPS::last_time); |
914 |
|
DBG(dbg_fps_cout) << "CurrentFPS: " << CurrentFPS::current_fps << "\n"; |
915 |
|
CurrentFPS::last_time = new_time; |
916 |
|
} |
917 |
|
|
918 |
} |
} |
919 |
|
|
|
#include <sys/time.h> |
|
|
double getTime() { |
|
|
struct timeval t; |
|
|
gettimeofday(&t, 0); |
|
|
return t.tv_usec*1E-6 + t.tv_sec; |
|
|
} |
|
920 |
|
|
921 |
JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GL_timeRenderImpl |
JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GL_timeRenderImpl |
922 |
(JNIEnv *env, jclass, jint window, jint iters, |
(JNIEnv *env, jclass, jint window, jint iters, |