avoid uninitialized oculus gl calls

This commit is contained in:
Zach Pomerantz 2016-10-17 10:48:51 -07:00
parent aec76cd542
commit 2191903803
2 changed files with 9 additions and 1 deletions

View file

@ -60,12 +60,14 @@ void OculusDisplayPlugin::customizeContext() {
ovrResult result = ovr_CreateTextureSwapChainGL(_session, &desc, &_textureSwapChain);
if (!OVR_SUCCESS(result)) {
logFatal("Failed to create swap textures");
return;
}
int length = 0;
result = ovr_GetTextureSwapChainLength(_session, _textureSwapChain, &length);
if (!OVR_SUCCESS(result) || !length) {
qFatal("Unable to count swap chain textures");
logFatal("Unable to count swap chain textures");
return;
}
for (int i = 0; i < length; ++i) {
GLuint chainTexId;
@ -83,6 +85,7 @@ void OculusDisplayPlugin::customizeContext() {
_sceneLayer.ColorTexture[0] = _textureSwapChain;
// not needed since the structure was zeroed on init, but explicit
_sceneLayer.ColorTexture[1] = nullptr;
_customized = true;
}
void OculusDisplayPlugin::uncustomizeContext() {
@ -98,10 +101,14 @@ void OculusDisplayPlugin::uncustomizeContext() {
ovr_DestroyTextureSwapChain(_session, _textureSwapChain);
_textureSwapChain = nullptr;
_outputFramebuffer.reset();
_customized = false;
Parent::uncustomizeContext();
}
void OculusDisplayPlugin::hmdPresent() {
if (!_customized) {
return;
}
PROFILE_RANGE_EX(__FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex)

View file

@ -32,5 +32,6 @@ private:
static const QString NAME;
ovrTextureSwapChain _textureSwapChain;
gpu::FramebufferPointer _outputFramebuffer;
bool _customized { false };
};