android: call eglMakeCurrent() before rendering or deleting context
Flush texture cache and terminate gui before releasing the EGL context
This commit is contained in:
parent
666205d2a1
commit
e426bc8058
|
@ -364,6 +364,8 @@ void rend_init_renderer()
|
|||
|
||||
void rend_term_renderer()
|
||||
{
|
||||
killtex();
|
||||
gui_term();
|
||||
renderer->Term();
|
||||
delete renderer;
|
||||
renderer = NULL;
|
||||
|
@ -372,8 +374,6 @@ void rend_term_renderer()
|
|||
delete fallback_renderer;
|
||||
fallback_renderer = NULL;
|
||||
}
|
||||
killtex();
|
||||
gui_term();
|
||||
}
|
||||
|
||||
void* rend_thread(void* p)
|
||||
|
|
|
@ -407,6 +407,14 @@ GLuint fogTextureId;
|
|||
|
||||
#if (HOST_OS != OS_DARWIN) && !defined(TARGET_NACL32)
|
||||
#if defined(GLES) && !defined(USE_SDL)
|
||||
|
||||
bool egl_makecurrent()
|
||||
{
|
||||
if (gl.setup.surface == EGL_NO_SURFACE || gl.setup.context == EGL_NO_CONTEXT)
|
||||
return false;
|
||||
return eglMakeCurrent(gl.setup.display, gl.setup.surface, gl.setup.surface, gl.setup.context);
|
||||
}
|
||||
|
||||
// Create a basic GLES context
|
||||
bool gl_init(void* wind, void* disp)
|
||||
{
|
||||
|
@ -465,34 +473,39 @@ GLuint fogTextureId;
|
|||
EGLint format;
|
||||
if (!eglGetConfigAttrib(gl.setup.display, config, EGL_NATIVE_VISUAL_ID, &format))
|
||||
{
|
||||
printf("eglGetConfigAttrib() returned error %d", eglGetError());
|
||||
printf("eglGetConfigAttrib() returned error %x\n", eglGetError());
|
||||
return false;
|
||||
}
|
||||
ANativeWindow_setBuffersGeometry((ANativeWindow *)wind, 0, 0, format);
|
||||
#endif
|
||||
|
||||
gl.setup.surface = eglCreateWindowSurface(gl.setup.display, config, (EGLNativeWindowType)wind, NULL);
|
||||
|
||||
if (eglCheck() || gl.setup.surface == EGL_NO_SURFACE)
|
||||
if (gl.setup.surface == EGL_NO_SURFACE)
|
||||
{
|
||||
printf("EGL Error: eglCreateWindowSurface failed\n");
|
||||
printf("EGL Error: eglCreateWindowSurface failed: %x\n", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
if (eglCheck())
|
||||
if (!eglBindAPI(EGL_OPENGL_ES_API))
|
||||
{
|
||||
printf("eglBindAPI() failed: %x\n", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
gl.setup.context = eglCreateContext(gl.setup.display, config, NULL, pi32ContextAttribs);
|
||||
|
||||
if (eglCheck())
|
||||
if (gl.setup.context == EGL_NO_CONTEXT)
|
||||
{
|
||||
printf("eglCreateContext() failed: %x\n", eglGetError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
eglMakeCurrent(gl.setup.display, gl.setup.surface, gl.setup.surface, gl.setup.context);
|
||||
|
||||
if (eglCheck())
|
||||
if (!egl_makecurrent())
|
||||
{
|
||||
printf("eglMakeCurrent() failed: %x\n", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
EGLint w,h;
|
||||
eglQuerySurface(gl.setup.display, gl.setup.surface, EGL_WIDTH, &w);
|
||||
|
@ -753,9 +766,9 @@ void gl_term()
|
|||
close( fbdev );
|
||||
fbdev=-1;
|
||||
#endif
|
||||
gl.setup.context = NULL;
|
||||
gl.setup.surface = NULL;
|
||||
gl.setup.display = NULL;
|
||||
gl.setup.context = EGL_NO_CONTEXT;
|
||||
gl.setup.surface = EGL_NO_SURFACE;
|
||||
gl.setup.display = EGL_NO_DISPLAY;
|
||||
#endif // TARGET_PANDORA || _ANDROID
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ import android.app.Activity;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceHolder;
|
||||
|
||||
import com.reicast.emulator.config.EditVJoyActivity;
|
||||
import com.reicast.emulator.emu.JNIdc;
|
||||
import com.reicast.emulator.emu.NativeGLView;
|
||||
|
||||
|
@ -59,11 +59,13 @@ public class BaseNativeGLActivity extends Activity implements SurfaceHolder.Call
|
|||
|
||||
@Override
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||
//Log.i("BaseNativeGLActivity", "surfaceChanged: " + w + "x" + h);
|
||||
JNIdc.rendinit(holder.getSurface(), w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
//Log.i("BaseNativeGLActivity", "surfaceDestroyed");
|
||||
JNIdc.rendinit(null, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,6 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_screenDpi(JNIEnv *env
|
|||
screen_dpi = screenDpi;
|
||||
}
|
||||
|
||||
void egl_stealcntx();
|
||||
void SetApplicationPath(wchar *path);
|
||||
int dc_init(int argc, wchar* argv[]);
|
||||
void dc_run();
|
||||
|
@ -126,6 +125,7 @@ bool VramLockedWrite(u8* address);
|
|||
bool rend_single_frame();
|
||||
void rend_init_renderer();
|
||||
void rend_term_renderer();
|
||||
bool egl_makecurrent();
|
||||
|
||||
//extern cResetEvent rs,re;
|
||||
extern int screen_width,screen_height;
|
||||
|
@ -536,6 +536,8 @@ JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_emu_JNIdc_rendframe(JNIEnv
|
|||
{
|
||||
if (g_window == NULL)
|
||||
return false;
|
||||
if (!egl_makecurrent())
|
||||
return false;
|
||||
jboolean ret = (jboolean)rend_single_frame();
|
||||
if (ret)
|
||||
gl_swap();
|
||||
|
@ -553,6 +555,7 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rendinit(JNIEnv * env
|
|||
}
|
||||
else
|
||||
{
|
||||
egl_makecurrent();
|
||||
rend_term_renderer();
|
||||
ANativeWindow_release(g_window);
|
||||
g_window = NULL;
|
||||
|
|
Loading…
Reference in New Issue