Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 76f9edd

Browse files
MortimerGorobluemarvin
authored andcommitted
Move WaveVR render initialization to a separate method (#3695)
Fixes #3692
1 parent 5e93f75 commit 76f9edd

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,22 @@ struct DeviceDelegateWaveVR::State {
194194
cameras[device::EyeIndex(device::Eye::Left)] = vrb::CameraEye::Create(create);
195195
cameras[device::EyeIndex(device::Eye::Right)] = vrb::CameraEye::Create(create);
196196
InitializeCameras();
197+
198+
elbow = ElbowModel::Create();
199+
}
200+
201+
void InitializeRender() {
197202
WVR_GetRenderTargetSize(&renderWidth, &renderHeight);
198203
VRB_GL_CHECK(glViewport(0, 0, renderWidth, renderHeight));
199204
VRB_DEBUG("Recommended size is %ux%u", renderWidth, renderHeight);
200205
if (renderWidth == 0 || renderHeight == 0) {
201206
VRB_ERROR("Please check Wave server configuration");
202207
return;
203208
}
209+
if (immersiveDisplay) {
210+
immersiveDisplay->SetEyeResolution(renderWidth, renderHeight);
211+
}
204212
InitializeTextureQueues();
205-
elbow = ElbowModel::Create();
206213
}
207214

208215
void InitializeTextureQueues() {
@@ -461,6 +468,10 @@ DeviceDelegateWaveVR::Create(vrb::RenderContextPtr& aContext) {
461468
return result;
462469
}
463470

471+
void DeviceDelegateWaveVR::InitializeRender() {
472+
m.InitializeRender();
473+
}
474+
464475
device::DeviceType
465476
DeviceDelegateWaveVR::GetDeviceType() {
466477
return m.deviceType;

app/src/wavevr/cpp/DeviceDelegateWaveVR.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ typedef std::shared_ptr<DeviceDelegateWaveVR> DeviceDelegateWaveVRPtr;
1414
class DeviceDelegateWaveVR : public DeviceDelegate {
1515
public:
1616
static DeviceDelegateWaveVRPtr Create(vrb::RenderContextPtr& aContext);
17+
void InitializeRender();
1718
// DeviceDelegate interface
1819
device::DeviceType GetDeviceType() override;
1920
void SetRenderMode(const device::RenderMode aMode) override;

app/src/wavevr/cpp/native-lib.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,19 @@ JNI_METHOD(void, activityResumed)
4545
int main(int argc, char *argv[]) {
4646
sQueue->AttachToThread();
4747
VRB_LOG("Call WVR_Init");
48-
sDevice = DeviceDelegateWaveVR::Create(BrowserWorld::Instance().GetRenderContext());
49-
BrowserWorld::Instance().RegisterDeviceDelegate(sDevice);
50-
while(!sJavaInitialized) {
51-
sQueue->ProcessRunnables();
52-
}
5348

5449
WVR_InitError eError = WVR_Init(WVR_AppType_VRContent);
5550
if (eError != WVR_InitError_None) {
5651
VRB_LOG("Unable to init VR runtime: %s", WVR_GetInitErrorString(eError));
5752
return 1;
5853
}
5954

55+
sDevice = DeviceDelegateWaveVR::Create(BrowserWorld::Instance().GetRenderContext());
56+
BrowserWorld::Instance().RegisterDeviceDelegate(sDevice);
57+
while(!sJavaInitialized) {
58+
sQueue->ProcessRunnables();
59+
}
60+
6061
WVR_InputAttribute inputIdAndTypes[] = {
6162
{WVR_InputId_Alias1_Menu, WVR_InputType_Button, WVR_AnalogType_None},
6263
{WVR_InputId_Alias1_Touchpad, WVR_InputType_Button | WVR_InputType_Touch | WVR_InputType_Analog, WVR_AnalogType_2D},
@@ -76,6 +77,7 @@ int main(int argc, char *argv[]) {
7677
if (pError != WVR_RenderError_None) {
7778
VRB_LOG("Present init failed - Error[%d]", pError);
7879
}
80+
sDevice->InitializeRender();
7981
VRB_GL_CHECK(glEnable(GL_DEPTH_TEST));
8082
VRB_GL_CHECK(glEnable(GL_CULL_FACE));
8183
VRB_GL_CHECK(glEnable(GL_BLEND));

0 commit comments

Comments
 (0)