12-19-2017 06:18 AM
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
ovr_Detect(0);
ovrInitParams params = { ovrInit_Debug | ovrInit_RequestVersion, OVR_MINOR_VERSION, OculusLogCallback, 0, 0 };
ovr_Initialize(¶ms);
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."
}
OVR::GLEContext::SetCurrentContext(&GLEContext);
GLEContext.Init();
08-10-2018 02:59 PM
08-10-2018 03:58 PM
08-11-2018 04:05 AM
08-16-2018 12:21 AM
08-19-2018 03:23 AM
extern "C" {
__declspec(dllexport) DWORD NvOptimusEnablement = 1; // disable NVidia Optimus
__declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 1; // disable ATI Hybrid Graphics
}