diff --git a/android/src/org/gale/GaleRendererGL.java b/android/src/org/gale/GaleRendererGL.java index 0e5b2c7..1f120f5 100644 --- a/android/src/org/gale/GaleRendererGL.java +++ b/android/src/org/gale/GaleRendererGL.java @@ -12,6 +12,7 @@ import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10; import android.opengl.GLES20; import android.opengl.GLSurfaceView; +import android.os.Process; // import the gale package : /* no need in same package... */ @@ -31,14 +32,17 @@ public class GaleRendererGL implements GLSurfaceView.Renderer m_galeNative = _galeInstance; } public void onSurfaceCreated(GL10 _gl, EGLConfig _config) { + android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY); m_galeNative.renderInit(); } public void onSurfaceChanged(GL10 _gl, int _w, int _h) { + android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY); m_galeNative.renderResize(_w, _h); } public void onDrawFrame(GL10 _gl) { + android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY); m_galeNative.renderDraw(); } } diff --git a/gale/context/Context.cpp b/gale/context/Context.cpp index 850ac3c..c658418 100644 --- a/gale/context/Context.cpp +++ b/gale/context/Context.cpp @@ -633,19 +633,20 @@ bool gale::Context::OS_Draw(bool _displayEveryTime) { m_simulationFile.filePuts(etk::to_string(_displayEveryTime)); m_simulationFile.filePuts("\n"); } - gale::openGL::threadHasContext(); echrono::Steady currentTime = echrono::Steady::now(); // TODO : Review this ... // this is to prevent the multiple display at the a high frequency ... - #if (!defined(__TARGET_OS__Android) && !defined(__TARGET_OS__Windows)) + #if ( !defined(__TARGET_OS__Windows) \ + && !defined(__TARGET_OS__Android)) if(currentTime - m_previousDisplayTime < echrono::milliseconds(8)) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); - gale::openGL::threadHasNoMoreContext(); return false; } #endif m_previousDisplayTime = currentTime; + gale::openGL::threadHasContext(); + // process the events if (m_displayFps == true) { m_FpsSystemEvent.tic(); diff --git a/gale/context/Fps.hpp b/gale/context/Fps.hpp index 3ec6659..06d0452 100644 --- a/gale/context/Fps.hpp +++ b/gale/context/Fps.hpp @@ -25,6 +25,7 @@ namespace gale { echrono::Duration m_avg_idle; echrono::Duration m_max_idle; echrono::Steady m_ticTime; + echrono::Steady m_lastDrawTime; bool m_display; bool m_drawingDone; const char * m_displayName; @@ -46,7 +47,7 @@ namespace gale { m_drawingDone(false), m_displayName(_displayName), m_displayFPS(_displayFPS) { - + m_lastDrawTime = echrono::Steady::now(); } /** * @brief Destructor @@ -115,7 +116,9 @@ namespace gale { << m_max_idle << " "); } if (m_displayFPS == true) { - GALE_PRINT("FPS : " << m_nbDisplayTime << "/" << m_nbCallTime << "fps"); + float nbSeconds = (echrono::Steady::now() - m_lastDrawTime).toSeconds(); + m_lastDrawTime = echrono::Steady::now(); + GALE_PRINT("FPS : " << m_nbDisplayTime << "/" << m_nbCallTime << " frames ==> " << (float(m_nbDisplayTime)/nbSeconds) << "fps"); } m_max = echrono::Duration(0); m_min = echrono::Duration(99999999,0); diff --git a/gale/resource/Texture.cpp b/gale/resource/Texture.cpp index 5e5fa7e..91e6feb 100644 --- a/gale/resource/Texture.cpp +++ b/gale/resource/Texture.cpp @@ -56,7 +56,7 @@ bool gale::resource::Texture::updateContext() { //Lock error ==> try later ... return false; } - if (false == m_loaded) { + if (m_loaded == false) { // Request a new texture at openGl : glGenTextures(1, &m_texId); }