ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.14k stars 1.28k forks source link

C API No longer exposes VR_Init #89

Open newhouseb opened 8 years ago

newhouseb commented 8 years ago

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 commented 8 years ago

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

cmbruns commented 8 years ago

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 commented 8 years ago

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

amroibrahim commented 8 years ago

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 commented 8 years ago

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

cmbruns commented 8 years ago

@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.

VsevolodGolovanov commented 7 years ago

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

Pyrolistical commented 9 months ago

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