Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
SpaceEngineer's avatar
8 years ago

ovr_CreateTextureSwapChainGL() failed

So every tine I attempt to create the swap chains, I got the error code ovrError_InvalidParameter == -1005 with the following message returned by ovr_GetLastErrorInfo():
BindFlags not supported for OpenGL applications.

I am using Oculus DK2 with the SDK 1.20 and latest NVidia drivers. This issue started many months ago, probably since 1.12 or so.

The code is a direct copy-paste from the OculusRoomTiny (GL) sample, or from the Texture Swap Chain Initialization documentation:



    ovrTextureSwapChainDesc desc = {};
desc.Type = ovrTexture_2D;
desc.ArraySize = 1;
desc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
desc.Width = w;
desc.Height = h;
desc.MipLevels = 1;
desc.SampleCount = 1;
desc.StaticImage = ovrFalse;
desc.MiscFlags = ovrTextureMisc_None; // Tried a direct assignment, but still fail
desc.BindFlags = ovrTextureBind_None; // Tried a direct assignment, but still fail

ovrResult res = ovr_CreateTextureSwapChainGL(session, &desc, &swapTextures);
// res is always ovrError_InvalidParameter

The initialization sequence is following (I am skipping error checks for clarity):

    ovr_Detect(0);

ovrInitParams params = { ovrInit_Debug | ovrInit_RequestVersion, OVR_MINOR_VERSION, OculusLogCallback, 0, 0 };
ovr_Initialize(&params);

ovrGraphicsLuid luid;
ovr_Create(&hmdSession, &luid);

//------------------------------------
// in the function called at WM_CREATE message:
<Create core GL context, make current>
<init GLEW library>
//------------------------------------

hmdDesc = ovr_GetHmdDesc(hmdSession);

ovrSizei ResLeft = ovr_GetFovTextureSize(hmdSession, ovrEye_Left, hmdDesc.DefaultEyeFov[0], 1.0f);
ovrSizei ResRight = ovr_GetFovTextureSize(hmdSession, ovrEye_Right, hmdDesc.DefaultEyeFov[1], 1.0f);
int w = max(ResLeft.w, ResRight.w); // 1184
int h = max(ResLeft.h, ResRight.h); // 1472

for (int eyeIdx = 0; eyeIdx < ovrEye_Count; eyeIdx++)
if (!eyeBuffers[eyeIdx].Create(hmdSession, w, h)) // this function's code is provided above
{
ovr_GetLastErrorInfo(&err);
log_error(err.ErrorString); // "BindFlags not supported for OpenGL applications."
}


So according to the error message, SDK thinks that I am assigned something to desc.BindFlags, while I am not. I tried to directly assign ovrTextureBind_None value to it (which is just zero), but still no success. I traced all variable values in debugger, they are the same as is the OculusRoomTiny (GL) sample. The only difference in my code that I can see is that I am using GLEW library to handle OpenGL extensions, while sample uses OVR::GLE. It initializes it immediately after wglMakeCurrent():

    OVR::GLEContext::SetCurrentContext(&GLEContext);
GLEContext.Init();

Can this be the cause? But I don't want to switch to Oculus' extensions library. My project is not Oculus-exclusive, it supports Vive and non-VR modes as well. If it is a bug inside libovr, I request Oculus team to fix it!

14 Replies