cancel
Showing results for 
Search instead for 
Did you mean: 

[RESOLVED] OVR_ASSERT fail in ovrHmd_ConfigureRendering()

Mecrof
Explorer
Hi everyone
I got a problem with the Oculus during my project development. Before, my program ran well on the Oculus. But since I don't know what, it does not work anymore. I got an assertion fail (on OVR_ASSERT) in the OVR_Stereo.cpp file in the function :

// DistortionFnInverse computes the inverse of the distortion function on an argument.
float LensConfig::DistortionFnInverse(float r) const
{
OVR_ASSERT((r <= 20.0f)); // fail here
...
}

I'm developping my project with:
-OpenGL 3.1 + GLM
-SDL 2.0 (for window context and user inputs)
My IDE is Visual Studio 2013. So I'm working on Windows 7 x64. And I have a NVIDIA GeForce GTX 670 (driver 9.18.13.4709).

Here my code: (nothing is done before)

SDL_Init(SDL_INIT_VIDEO);
int x = SDL_WINDOWPOS_CENTERED;
int y = SDL_WINDOWPOS_CENTERED;
Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;

bool debug = false;

ovr_Initialize();

osettings_.hmd = ovrHmd_Create(0);
ovrHmd hmd = osettings_.hmd;

if (hmd == NULL)
{
std::cout << "ERROR: Oculus Rift not detected" << std::endl;
hmd = ovrHmd_CreateDebug(ovrHmd_DK1);

debug = true;
}
if (hmd->ProductName[0] == '\0')
{
std::cout << "ERROR: Rift detected, display not enabled" << std::endl;
}
if (debug == false && hmd->HmdCaps & ovrHmdCap_ExtendDesktop)
{
x = hmd->WindowsPos.x;
y = hmd->WindowsPos.y;
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
int w = hmd->Resolution.w;
int h = hmd->Resolution.h;
window_ = SDL_CreateWindow("Oculus Rift SDL2 OpenGL Demo", x, y, w, h, flags);

glContext_ = SDL_GL_CreateContext(window_);

glewExperimental = GL_TRUE;

glewInit();

scene_->setOVR(&osettings_); // give to my scene OVR parameters for multicamera rendering

SDL_SysWMinfo info;

SDL_VERSION(&info.version);

SDL_GetWindowWMInfo(window_, &info);


osettings_.cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
osettings_.cfg.OGL.Header.BackBufferSize = OVR::Sizei(hmd->Resolution.w, hmd->Resolution.h);
osettings_.cfg.OGL.Header.Multisample = 1;
#if defined(OVR_OS_WIN32)
if (!(hmd->HmdCaps & ovrHmdCap_ExtendDesktop))
ovrHmd_AttachToWindow(hmd, info.info.win.window, NULL, NULL);

osettings_.cfg.OGL.Window = info.info.win.window;
osettings_.cfg.OGL.DC = NULL;
#elif defined(OVR_OS_LINUX)
osettings_.cfg.OGL.Disp = info.info.x11.display;
osettings_.cfg.OGL.Win = info.info.x11.window;
#endif

ovrHmd_SetEnabledCaps(hmd, ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction);

ovrHmd_ConfigureRendering(hmd, &osettings_.cfg.Config, ovrDistortionCap_Chromatic | ovrDistortionCap_Vignette | ovrDistortionCap_TimeWarp | ovrDistortionCap_Overdrive, osettings_.eyeFov, osettings_.eyeRenderDesc);

ovrHmd_ConfigureTracking(hmd, ovrTrackingCap_Orientation | ovrTrackingCap_MagYawCorrection | ovrTrackingCap_Position, 0);

It compiles well with LibOVR beside and linked. But I got the assert fail in the function ovrHmd_ConfigureRendering.
I tried to comment the line "OVR_ASSERT((r <= 20.0f));". It works but I got this:
https://framapic.org/YyK6AiDpGvFb/ibMrSKvt

SDK's samples and demo works well. Even the OpenGL sample developed by federico-mammano (here: https://github.com/federico-mammano/Oculus-SDK-0.4.4-beta-OpenGL-Demo). So, I'm pretty sure that my program is the problem.

Any idea ? 😕

(I hope my english is not too bad ^^')

EDIT:
The "ossettings_" object is a struct defined as:

struct OculusSettings
{
public:
ovrHmd hmd;
GLuint frameBuffer;
GLuint texture;
GLuint renderBuffer;
OVR::Sizei renderTargetSize;
ovrFovPort eyeFov[2];
ovrRecti eyeRenderViewport[2];
ovrGLTexture eyeTexture[2];
ovrGLConfig cfg;
ovrEyeRenderDesc eyeRenderDesc[2];
};
2 REPLIES 2

jherico
Adventurer
You are passing osettings_.eyeFov into ovrHmd_ConfigureRendering without populating it. The FOV is an input parameter, not an output parameter, so you must initialize it. You can initialize it from either the DefaultEyeFov or the MaxEyeFov inside ovrHmd or you can manually set it up yourself (the smaller the FOV the less pixels you render, but you can't really change it dynamically at runtime).

Since you're note initializing it it probably has random memory in it, which means that the distortion function is trying to create a mesh for some absurd random value (or possibly 0) interpreted as an angle. The ASSERT is there to tell you the angle is absurd.

Mecrof
Explorer
Thanks a lot jherico !
That was the problem. I thought the two last parameters of ovrHmd_ConfigureRendering were output parameters.
So I put this code before:

osettings_.eyeFov[0] = hmd->DefaultEyeFov[0];
osettings_.eyeFov[1] = hmd->DefaultEyeFov[1];
ovrHmd_ConfigureRendering(hmd, &osettings_.cfg.Config, ovrDistortionCap_Chromatic | ovrDistortionCap_TimeWarp | ovrDistortionCap_Overdrive, osettings_.eyeFov, osettings_.eyeRenderDesc);

and it works as before. Thank you 🙂

Well, now, the problem is why I can't remember when I changed my code. But it's the universal problem of the thing between the keyboard and the chair :mrgreen: