mirror of
https://github.com/amwatson/CitraVR.git
synced 2024-09-20 03:11:40 +02:00
[vr_main] Move Init to a separate method
This commit is contained in:
parent
ba5f0313dd
commit
c2be12452b
1 changed files with 26 additions and 13 deletions
|
@ -177,14 +177,35 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainLoop() {
|
void MainLoop() {
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// Init
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
JNIEnv* jni;
|
JNIEnv* jni;
|
||||||
if (mVm->AttachCurrentThread(&jni, nullptr) != JNI_OK) {
|
if (mVm->AttachCurrentThread(&jni, nullptr) != JNI_OK) {
|
||||||
FAIL("%s(): Could not attach to JVM", __FUNCTION__);
|
FAIL("%s(): Could not attach to JVM", __FUNCTION__);
|
||||||
}
|
}
|
||||||
mEnv = jni;
|
mEnv = jni;
|
||||||
|
Init(jni);
|
||||||
|
|
||||||
ALOGI("VR Extra Performance Mode: {}",
|
//////////////////////////////////////////////////
|
||||||
VRSettings::values.extra_performance_mode_enabled ? "enabled" : "disabled");
|
// Frame loop
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
while (!mIsStopRequested) { Frame(jni); }
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
// Shutdown
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ALOGI("::MainLoop() exiting");
|
||||||
|
|
||||||
|
mVm->DetachCurrentThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Init(JNIEnv* jni) {
|
||||||
// Gotta set this after the JNIEnv is attached, or else it'll be
|
// Gotta set this after the JNIEnv is attached, or else it'll be
|
||||||
// overwritten
|
// overwritten
|
||||||
prctl(PR_SET_NAME, (long)"CS::Main", 0, 0, 0);
|
prctl(PR_SET_NAME, (long)"CS::Main", 0, 0, 0);
|
||||||
|
@ -214,6 +235,9 @@ public:
|
||||||
|
|
||||||
// Create the game surface layer.
|
// Create the game surface layer.
|
||||||
{
|
{
|
||||||
|
ALOGI("VR Extra Performance Mode: {}",
|
||||||
|
VRSettings::values.extra_performance_mode_enabled ? "enabled" : "disabled");
|
||||||
|
|
||||||
const uint32_t defaultResolutionFactor =
|
const uint32_t defaultResolutionFactor =
|
||||||
GetDefaultGameResolutionFactorForHmd(VRSettings::values.hmd_type);
|
GetDefaultGameResolutionFactorForHmd(VRSettings::values.hmd_type);
|
||||||
const uint32_t resolutionFactorFromPreferences = VRSettings::values.resolution_factor;
|
const uint32_t resolutionFactorFromPreferences = VRSettings::values.resolution_factor;
|
||||||
|
@ -273,19 +297,8 @@ public:
|
||||||
mOpenSettingsMethodID =
|
mOpenSettingsMethodID =
|
||||||
jni->GetMethodID(jni->GetObjectClass(mActivityObject), "openSettingsMenu", "()V");
|
jni->GetMethodID(jni->GetObjectClass(mActivityObject), "openSettingsMenu", "()V");
|
||||||
if (mOpenSettingsMethodID == nullptr) { FAIL("could not get openSettingsMenuMethodID"); }
|
if (mOpenSettingsMethodID == nullptr) { FAIL("could not get openSettingsMenuMethodID"); }
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
|
||||||
// Frame loop
|
|
||||||
//////////////////////////////////////////////////
|
|
||||||
|
|
||||||
while (!mIsStopRequested) { Frame(jni); }
|
|
||||||
|
|
||||||
ALOGI("::MainLoop() exiting");
|
|
||||||
|
|
||||||
mVm->DetachCurrentThread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
void Frame(JNIEnv* jni) {
|
void Frame(JNIEnv* jni) {
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
Loading…
Reference in a new issue