mirror of
https://github.com/overte-org/overte.git
synced 2025-06-06 08:41:51 +02:00
Merge pull request #8826 from zzmp/fix/failed-oculus-gl
avoid uninitialized oculus gl calls
This commit is contained in:
commit
5b9606f0fc
4 changed files with 13 additions and 5 deletions
|
@ -59,13 +59,15 @@ void OculusDisplayPlugin::customizeContext() {
|
||||||
|
|
||||||
ovrResult result = ovr_CreateTextureSwapChainGL(_session, &desc, &_textureSwapChain);
|
ovrResult result = ovr_CreateTextureSwapChainGL(_session, &desc, &_textureSwapChain);
|
||||||
if (!OVR_SUCCESS(result)) {
|
if (!OVR_SUCCESS(result)) {
|
||||||
logFatal("Failed to create swap textures");
|
logCritical("Failed to create swap textures");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int length = 0;
|
int length = 0;
|
||||||
result = ovr_GetTextureSwapChainLength(_session, _textureSwapChain, &length);
|
result = ovr_GetTextureSwapChainLength(_session, _textureSwapChain, &length);
|
||||||
if (!OVR_SUCCESS(result) || !length) {
|
if (!OVR_SUCCESS(result) || !length) {
|
||||||
qFatal("Unable to count swap chain textures");
|
logCritical("Unable to count swap chain textures");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < length; ++i) {
|
for (int i = 0; i < length; ++i) {
|
||||||
GLuint chainTexId;
|
GLuint chainTexId;
|
||||||
|
@ -83,6 +85,7 @@ void OculusDisplayPlugin::customizeContext() {
|
||||||
_sceneLayer.ColorTexture[0] = _textureSwapChain;
|
_sceneLayer.ColorTexture[0] = _textureSwapChain;
|
||||||
// not needed since the structure was zeroed on init, but explicit
|
// not needed since the structure was zeroed on init, but explicit
|
||||||
_sceneLayer.ColorTexture[1] = nullptr;
|
_sceneLayer.ColorTexture[1] = nullptr;
|
||||||
|
_customized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusDisplayPlugin::uncustomizeContext() {
|
void OculusDisplayPlugin::uncustomizeContext() {
|
||||||
|
@ -98,10 +101,14 @@ void OculusDisplayPlugin::uncustomizeContext() {
|
||||||
ovr_DestroyTextureSwapChain(_session, _textureSwapChain);
|
ovr_DestroyTextureSwapChain(_session, _textureSwapChain);
|
||||||
_textureSwapChain = nullptr;
|
_textureSwapChain = nullptr;
|
||||||
_outputFramebuffer.reset();
|
_outputFramebuffer.reset();
|
||||||
|
_customized = false;
|
||||||
Parent::uncustomizeContext();
|
Parent::uncustomizeContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusDisplayPlugin::hmdPresent() {
|
void OculusDisplayPlugin::hmdPresent() {
|
||||||
|
if (!_customized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PROFILE_RANGE_EX(__FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex)
|
PROFILE_RANGE_EX(__FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex)
|
||||||
|
|
||||||
|
|
|
@ -32,5 +32,6 @@ private:
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
ovrTextureSwapChain _textureSwapChain;
|
ovrTextureSwapChain _textureSwapChain;
|
||||||
gpu::FramebufferPointer _outputFramebuffer;
|
gpu::FramebufferPointer _outputFramebuffer;
|
||||||
|
bool _customized { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,12 @@ void logWarning(const char* what) {
|
||||||
qWarning(oculus) << what << ":" << getError().ErrorString;
|
qWarning(oculus) << what << ":" << getError().ErrorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
void logFatal(const char* what) {
|
void logCritical(const char* what) {
|
||||||
std::string error("[oculus] ");
|
std::string error("[oculus] ");
|
||||||
error += what;
|
error += what;
|
||||||
error += ": ";
|
error += ": ";
|
||||||
error += getError().ErrorString;
|
error += getError().ErrorString;
|
||||||
qFatal(error.c_str());
|
qCritical(error.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include <controllers/Forward.h>
|
#include <controllers/Forward.h>
|
||||||
|
|
||||||
void logWarning(const char* what);
|
void logWarning(const char* what);
|
||||||
void logFatal(const char* what);
|
void logCritical(const char* what);
|
||||||
bool oculusAvailable();
|
bool oculusAvailable();
|
||||||
ovrSession acquireOculusSession();
|
ovrSession acquireOculusSession();
|
||||||
void releaseOculusSession();
|
void releaseOculusSession();
|
||||||
|
|
Loading…
Reference in a new issue