-
Notifications
You must be signed in to change notification settings - Fork 13
Migrating from OVR C API to Python
Christopher Bruns edited this page Oct 24, 2015
·
12 revisions
Many function names, constants, and type names in the C OVR API begin with prefixes such as "ovr", "OVR_", or "ovr_". These prefixes are removed in the Python API because all of these identifiers are in the python "ovr" module namespace.
For example, the C code
OVR_KEY_IPD
would become in python
ovr.KEY_IPD
In the Python API, identifiers are changed like so:
- All OVR API identifiers are in the "ovr" module namespace
- Prefix "ovr", "OVR_", or "ovr_" is stripped off:
OVR_KEY_IPD
becomesovr.KEY_IPD
- Function names begin with a lower case letter:
ovr_Shutdown()
becomesovr.shutdown()
- Type names, macros, and enum values retain their capitalization:
ovrTrackingState
becomesovr.TrackingState
,OVR_KEY_IPD
becomesovr.KEY_IPD
, andovrTrackingCap_Orientation
becomesovr.TrackingCap_Orientation
Many OVR functions in the C API return a value of type ovrResult
. The corresponding functions in the Python API do not return an ovrResult, but rather raise an exception, in the case where ovrResult was not OVR_SUCCESS
.
For example, the C code
ovrResult result = ovr_Initialize(nullptr);
if (OVR_FAILURE(result))
return;
becomes
try:
ovr.initialize(None)
except:
return