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();
12-19-2017 10:06 AM
12-21-2017 05:59 PM
{
char str[256];
sprintf_s(str, "sizeof(void*)=%u sizeof(desc)=%u\n", (unsigned)sizeof(void*), (unsigned)sizeof(desc));
MessageBoxA(NULL, str, "Info", 0);
}
12-22-2017 02:30 AM
12-22-2017 02:45 AM
#pragma pack (push, 1)
// make it 64 bytes long
struct ovrHack
{
ovrTextureSwapChainDesc desc;
char padding[27];
};
#pragma pack (pop)
ovrHack hack;
memset(&hack, 0, sizeof(hack));
lprint("%u", sizeof(hack)); // reports 64
hack.desc.Type = ovrTexture_2D;
hack.desc.ArraySize = 1;
hack.desc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
hack.desc.Width = w;
hack.desc.Height = h;
hack.desc.MipLevels = isHiQuality ? 3 : 1;
hack.desc.SampleCount = 1;
hack.desc.StaticImage = ovrFalse;
ovrResult res = ovr_CreateTextureSwapChainGL(session, &hack.desc, &swapTextures);
return (res == ovrSuccess); // SUCCESS!!!
12-22-2017 05:25 AM
#if defined(_MSC_VER) && _MSC_VER <= 1900
#define _HAS_ITERATOR_DEBUGGING 0 // Disable run-time checking of std iterators
#endif
12-22-2017 03:56 PM
12-23-2017 01:25 AM
#pragma pack (push, 1)
...
#pragma pack (pop, 1)
Be careful with copy-pasting!03-19-2018 04:02 AM
08-10-2018 08:35 AM