[android] Set/unset g_hasContext variable when opengl context is available/not available. @TODO make it more clear and simple, e.g. move to Framework

This commit is contained in:
Alex Zolotarev 2012-01-25 08:30:43 +03:00 committed by Alex Zolotarev
parent ff0752ffeb
commit b8cfdfed12
3 changed files with 13 additions and 4 deletions

View file

@ -23,6 +23,14 @@
extern android::Framework * g_framework;
namespace yg
{
namespace gl
{
extern bool g_hasContext;
}
}
namespace android
{
@ -34,6 +42,7 @@ Framework & GetFramework()
Framework::Framework()
{
yg::gl::g_hasContext = false;
// @TODO refactor storage
m_work.Storage().ReInitCountries(false);
}

View file

@ -11,7 +11,7 @@ namespace yg
{
namespace gl
{
extern bool g_doDeleteOnDestroy;
extern bool g_hasContext;
}
}
@ -22,7 +22,7 @@ Java_com_mapswithme_maps_SmartGLSurfaceView_nativeBind(JNIEnv * env, jobject thi
{
if (isBound)
{
yg::gl::g_doDeleteOnDestroy = true;
yg::gl::g_hasContext = true;
g_requestRenderMethodID = jni::GetJavaMethodID(env, thiz, "requestRender", "()V");
ASSERT(g_requestRenderMethodID, ("Can't find method void com/mapswithme/maps/SmartGLSurfaceView.requestRender()"));
@ -30,7 +30,7 @@ Java_com_mapswithme_maps_SmartGLSurfaceView_nativeBind(JNIEnv * env, jobject thi
}
else
{
yg::gl::g_doDeleteOnDestroy = false;
yg::gl::g_hasContext = false;
jobject refToDelete = g_smartGLSurfaceView;
g_smartGLSurfaceView = 0;
env->DeleteGlobalRef(refToDelete);

View file

@ -55,6 +55,7 @@ public class SmartGLSurfaceView extends GLSurfaceView
public void surfaceCreated (SurfaceHolder holder)
{
Log.d(TAG, "surfaceCreated");
nativeBind(true);
m_renderer.m_isBaseSurfaceReady = false;
super.surfaceCreated(holder);
}
@ -66,7 +67,6 @@ public class SmartGLSurfaceView extends GLSurfaceView
m_renderer.m_isBaseSurfaceReady = true;
super.surfaceChanged(holder, format, w, h);
queueEvent(m_tryToLoadResourcesIfReady);
nativeBind(true);
}
@Override