Forum Discussion
djpeterson83
9 years agoExplorer
ovr_CreateTextureSwapChainDX Fails with code -1004
I'm not sure what's going on. My engine worked flawlessly for a long time. Then all of a sudden it won't initialize the Rift. It fails on ovr_CreateTextureSwapChainDX with -1004 (ovrError_NotInitia...
- 9 years agoOk, figured it out. I've got calls crossing DLLs. Because of this, the memory wasn't initialized in a single place. Make sure all of your ovr_ calls are called in a single DLL or EXE, otherwise this will happen. I'm still fighting issues, but they might still be related to this code migration, so I'll keep plugging away.UPDATE:Yep, that fixed it. For those of you who spread your calls across multiple modules, you might want to centralize everything to a single class and store function pointers to each ovr_* function you will call outside of your initialization module. You can populate these function pointers after your call to ovr_Initialize succeeds. Here's an example:OculusVr::OculusVr() {auto result = ::ovr_Initialize(nullptr);if (OVR_FAILURE(result))return;// Save function pointers in here //if (!init_library()) {ovr_Shutdown();return;}if (OVR_FAILURE(ovr_Create(&session, &luid_handle))) {ovr_Shutdown();return;}}bool OculusVr::init_library() {bool validity = true;validity &= (this->ovr_Initialize = &::ovr_Initialize) != nullptr;validity &= (this->ovr_Shutdown = &::ovr_Shutdown) != nullptr;validity &= (this->ovr_GetLastErrorInfo = &::ovr_GetLastErrorInfo) != nullptr;validity &= (this->ovr_GetVersionString = &::ovr_GetVersionString) != nullptr;validity &= (this->ovr_TraceMessage = &::ovr_TraceMessage) != nullptr;validity &= (this->ovr_IdentifyClient = &::ovr_IdentifyClient) != nullptr;validity &= (this->ovr_GetHmdDesc = &::ovr_GetHmdDesc) != nullptr;validity &= (this->ovr_GetTrackerCount = &::ovr_GetTrackerCount) != nullptr;validity &= (this->ovr_GetTrackerDesc = &::ovr_GetTrackerDesc) != nullptr;validity &= (this->ovr_Create = &::ovr_Create) != nullptr;validity &= (this->ovr_Destroy = &::ovr_Destroy) != nullptr;// ...}Now you can pass your OculusVr instance around and call ovr_* calls from it instead of the global ovr_* functions. The OculusVr calls will point to the correct address space so that your code calls the correct functions.
FYI: Please fix this ridiculous editor. I have no idea if my post is even saved. It seems to be all manners of broken, and I've had to format the above post 5 times now.
djpeterson83
9 years agoExplorer
Ok, figured it out. I've got calls crossing DLLs. Because of this, the memory wasn't initialized in a single place. Make sure all of your ovr_ calls are called in a single DLL or EXE, otherwise this will happen. I'm still fighting issues, but they might still be related to this code migration, so I'll keep plugging away.
UPDATE:
Yep, that fixed it. For those of you who spread your calls across multiple modules, you might want to centralize everything to a single class and store function pointers to each ovr_* function you will call outside of your initialization module. You can populate these function pointers after your call to ovr_Initialize succeeds. Here's an example:
OculusVr::OculusVr() {
auto result = ::ovr_Initialize(nullptr);
if (OVR_FAILURE(result))
return;
// Save function pointers in here //
if (!init_library()) {
ovr_Shutdown();
return;
}
if (OVR_FAILURE(ovr_Create(&session, &luid_handle))) {
ovr_Shutdown();
return;
}
}
bool OculusVr::init_library() {
bool validity = true;
validity &= (this->ovr_Initialize = &::ovr_Initialize) != nullptr;
validity &= (this->ovr_Shutdown = &::ovr_Shutdown) != nullptr;
validity &= (this->ovr_GetLastErrorInfo = &::ovr_GetLastErrorInfo) != nullptr;
validity &= (this->ovr_GetVersionString = &::ovr_GetVersionString) != nullptr;
validity &= (this->ovr_TraceMessage = &::ovr_TraceMessage) != nullptr;
validity &= (this->ovr_IdentifyClient = &::ovr_IdentifyClient) != nullptr;
validity &= (this->ovr_GetHmdDesc = &::ovr_GetHmdDesc) != nullptr;
validity &= (this->ovr_GetTrackerCount = &::ovr_GetTrackerCount) != nullptr;
validity &= (this->ovr_GetTrackerDesc = &::ovr_GetTrackerDesc) != nullptr;
validity &= (this->ovr_Create = &::ovr_Create) != nullptr;
validity &= (this->ovr_Destroy = &::ovr_Destroy) != nullptr;
// ...
}Now you can pass your OculusVr instance around and call ovr_* calls from it instead of the global ovr_* functions. The OculusVr calls will point to the correct address space so that your code calls the correct functions.
FYI: Please fix this ridiculous editor. I have no idea if my post is even saved. It seems to be all manners of broken, and I've had to format the above post 5 times now.
FYI: Please fix this ridiculous editor. I have no idea if my post is even saved. It seems to be all manners of broken, and I've had to format the above post 5 times now.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 3 years ago
- 4 years ago