move UI plane when toggled in VR, fix vr start/stop on Quest
This commit is contained in:
@@ -141,6 +141,22 @@ void oculus_init_vr(EGLDisplay display, EGLContext context, ANativeWindow* surfa
|
||||
vrapi_SetPerfThread(ovr_context, VRAPI_PERF_THREAD_TYPE_RENDERER, 0);
|
||||
}
|
||||
|
||||
void oculus_release_vr()
|
||||
{
|
||||
vrapi_LeaveVrMode(ovr_context);
|
||||
ovr_context = nullptr;
|
||||
for (int eye = 0; eye < 2; eye++)
|
||||
{
|
||||
vrapi_DestroyTextureSwapChain(swap_chain[eye]);
|
||||
swap_chain[eye] = nullptr;
|
||||
for (int i = 0; i < swap_chain_count; i++)
|
||||
ovr_eyes[eye][i].destroy();
|
||||
}
|
||||
swap_chain_index = 0;
|
||||
swap_chain_count = 0;
|
||||
LOG("leave vr mode");
|
||||
}
|
||||
|
||||
void oculus_draw(float dt)
|
||||
{
|
||||
const double predictedDisplayTime = vrapi_GetPredictedDisplayTime(ovr_context, ovr_frame);
|
||||
|
||||
@@ -12,4 +12,5 @@
|
||||
|
||||
void oculus_init(JavaVM* vm, JNIEnv* jni, jobject activity_class);
|
||||
void oculus_init_vr(EGLDisplay display, EGLContext context, ANativeWindow* surface);
|
||||
void oculus_release_vr();
|
||||
void oculus_draw(float dt);
|
||||
|
||||
@@ -492,6 +492,10 @@ static int engine_init_display(struct engine* engine) {
|
||||
g_display = display;
|
||||
g_context = context;
|
||||
|
||||
#ifdef __QUEST__
|
||||
oculus_init_vr(display, context, engine->app->window);
|
||||
#endif
|
||||
|
||||
if (resuming_context)
|
||||
{
|
||||
LOG("RESUME APP");
|
||||
@@ -588,9 +592,6 @@ static int engine_init_display(struct engine* engine) {
|
||||
LOG("PROP Brand: %s", os_props["ro.product.brand"].c_str());
|
||||
LOG("PROP Maker: %s", os_props["ro.product.manufacturer"].c_str());
|
||||
LOG("PROP Mode: %s", os_props["ro.product.model"].c_str());
|
||||
//LOG("PROP: %s", os_props[""].c_str());
|
||||
//LOG("PROP: %s", os_props[""].c_str());
|
||||
//LOG("PROP: %s", os_props[""].c_str());
|
||||
|
||||
// Initialize GL state.
|
||||
|
||||
@@ -619,7 +620,6 @@ static int engine_init_display(struct engine* engine) {
|
||||
App::I.redraw = true;
|
||||
App::I.init();
|
||||
App::I.resize(1024, 1024);
|
||||
oculus_init_vr(display, context, engine->app->window);
|
||||
App::I.vr_active = true;
|
||||
App::I.has_vr = true;
|
||||
App::I.vr_only = true;
|
||||
@@ -706,6 +706,9 @@ static void engine_term_display(struct engine* engine) {
|
||||
engine->display = EGL_NO_DISPLAY;
|
||||
engine->context = EGL_NO_CONTEXT;
|
||||
engine->surface = EGL_NO_SURFACE;
|
||||
#ifdef __QUEST__
|
||||
oculus_release_vr();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user