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

Commit

Permalink
Move WaveVR render initialization to a separate method (#3695)
Browse files Browse the repository at this point in the history
Fixes #3692
  • Loading branch information
MortimerGoro authored and bluemarvin committed Jul 17, 2020
1 parent 5e93f75 commit 76f9edd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
13 changes: 12 additions & 1 deletion app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,22 @@ struct DeviceDelegateWaveVR::State {
cameras[device::EyeIndex(device::Eye::Left)] = vrb::CameraEye::Create(create);
cameras[device::EyeIndex(device::Eye::Right)] = vrb::CameraEye::Create(create);
InitializeCameras();

elbow = ElbowModel::Create();
}

void InitializeRender() {
WVR_GetRenderTargetSize(&renderWidth, &renderHeight);
VRB_GL_CHECK(glViewport(0, 0, renderWidth, renderHeight));
VRB_DEBUG("Recommended size is %ux%u", renderWidth, renderHeight);
if (renderWidth == 0 || renderHeight == 0) {
VRB_ERROR("Please check Wave server configuration");
return;
}
if (immersiveDisplay) {
immersiveDisplay->SetEyeResolution(renderWidth, renderHeight);
}
InitializeTextureQueues();
elbow = ElbowModel::Create();
}

void InitializeTextureQueues() {
Expand Down Expand Up @@ -461,6 +468,10 @@ DeviceDelegateWaveVR::Create(vrb::RenderContextPtr& aContext) {
return result;
}

void DeviceDelegateWaveVR::InitializeRender() {
m.InitializeRender();
}

device::DeviceType
DeviceDelegateWaveVR::GetDeviceType() {
return m.deviceType;
Expand Down
1 change: 1 addition & 0 deletions app/src/wavevr/cpp/DeviceDelegateWaveVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ typedef std::shared_ptr<DeviceDelegateWaveVR> DeviceDelegateWaveVRPtr;
class DeviceDelegateWaveVR : public DeviceDelegate {
public:
static DeviceDelegateWaveVRPtr Create(vrb::RenderContextPtr& aContext);
void InitializeRender();
// DeviceDelegate interface
device::DeviceType GetDeviceType() override;
void SetRenderMode(const device::RenderMode aMode) override;
Expand Down
12 changes: 7 additions & 5 deletions app/src/wavevr/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,19 @@ JNI_METHOD(void, activityResumed)
int main(int argc, char *argv[]) {
sQueue->AttachToThread();
VRB_LOG("Call WVR_Init");
sDevice = DeviceDelegateWaveVR::Create(BrowserWorld::Instance().GetRenderContext());
BrowserWorld::Instance().RegisterDeviceDelegate(sDevice);
while(!sJavaInitialized) {
sQueue->ProcessRunnables();
}

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

sDevice = DeviceDelegateWaveVR::Create(BrowserWorld::Instance().GetRenderContext());
BrowserWorld::Instance().RegisterDeviceDelegate(sDevice);
while(!sJavaInitialized) {
sQueue->ProcessRunnables();
}

WVR_InputAttribute inputIdAndTypes[] = {
{WVR_InputId_Alias1_Menu, WVR_InputType_Button, WVR_AnalogType_None},
{WVR_InputId_Alias1_Touchpad, WVR_InputType_Button | WVR_InputType_Touch | WVR_InputType_Analog, WVR_AnalogType_2D},
Expand All @@ -76,6 +77,7 @@ int main(int argc, char *argv[]) {
if (pError != WVR_RenderError_None) {
VRB_LOG("Present init failed - Error[%d]", pError);
}
sDevice->InitializeRender();
VRB_GL_CHECK(glEnable(GL_DEPTH_TEST));
VRB_GL_CHECK(glEnable(GL_CULL_FACE));
VRB_GL_CHECK(glEnable(GL_BLEND));
Expand Down

0 comments on commit 76f9edd

Please sign in to comment.