openvr icon indicating copy to clipboard operation
openvr copied to clipboard

C API No longer exposes VR_Init

Open newhouseb opened this issue 9 years ago • 8 comments

Looks like a fair bit of bit rot has occurred since 0.9.17 that has broken the C API. Can you guys re-run whatever tools you have that generate the C API header files?

newhouseb avatar Apr 16 '16 17:04 newhouseb

For what it's worth, I went ahead and wrote a tool to do this myself, which appears to generate a working wrapper that adapts the C++ API to C.

Sample here: https://github.com/newhouseb/openvr-c/blob/master/test_binding.c

newhouseb avatar Apr 17 '16 01:04 newhouseb

Is VR_Init(...) the same as VR_InitInternal(...)? VR_InitInternal(...) appears to be at least exposed as a symbol from openvr_api.dll.

https://github.com/ValveSoftware/openvr/blob/master/headers/openvr_capi.h#L1450

cmbruns avatar May 07 '16 15:05 cmbruns

I found a discussion explaining why they "meant to do this" https://steamcommunity.com/app/358720/discussions/0/405692758722144628/

cmbruns avatar May 07 '16 16:05 cmbruns

can some one please provide a sample how to use the updated file? Am I expected to remove "#if 0" and use the header file? should we be using VR_InitInternal instead?

amroibrahim avatar May 30 '16 19:05 amroibrahim

thanx I found your code, https://github.com/cmbruns/pyopenvr/blob/master/src/c_tests/test_init.c

amroibrahim avatar May 31 '16 11:05 amroibrahim

@amroibrahim I have to give proper credit for unearthing that seemingly undocumented "FnTable:%s" trick to lukexi https://github.com/lukexi/openvr-hs/blob/master/cbits/openvr_capi_helper.c#L9

That trick, plus also following the logic implicit in the inline VR_Init() function implemented in the C++ header https://github.com/ValveSoftware/openvr/blob/master/headers/openvr.h#L3056 has allowed me to progress with my python bindings in pyopenvr. Of course, my bindings are not working flawlessly yet, so take my success with a grain of salt. But I believe the openvr.init() function, at least, is pretty much functioning as expected.

cmbruns avatar May 31 '16 13:05 cmbruns

In the meantime, here is a fully ported to C hellovr_opengl sample: https://github.com/VsevolodGolovanov/openvr_c_dabbling

VsevolodGolovanov avatar Jan 21 '17 18:01 VsevolodGolovanov

Thank you. Can confirm VR_InitInternal does not return a VR_IVRSystem_FnTable pointer. You must use ... = (VR_IVRSystem_FnTable*) VR_GetGenericInterface("FnTable:IVRSystem_022", &init_error);, where IVRSystem_022 is the value of IVRSystem_Version

Pyrolistical avatar Mar 03 '24 09:03 Pyrolistical