Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
jherico's avatar
jherico
Adventurer
9 years ago

C vs C++ development

The current 'C API' header, OVR_CAPI.h includes additional headers that are not compatible with vanilla C (like OVR_Math.h, via OVR_CAPI_Util.h).  You can disable them by defining OVR_CAPI_NO_UTILS before you include OVR_CAPI.h, but the code should automatically detect if it's not running in a C++ compiler and not include incompatible headers.  

#if !defined(OVR_CAPI_NO_UTILS)
    #include "Extras/OVR_CAPI_Util.h"
#endif

should be changed to...

#if defined(__cplusplus) && !defined(OVR_CAPI_NO_UTILS)
    #include "Extras/OVR_CAPI_Util.h"
#endif

2 Replies


  • Hmmm. I replaced those lines my OVR_CAPI_0_8_0.h file, but I'm still getting the
    issue where I need to include

    LibOvRKernel/src/GL/CAPI_GLE_GL

    K in order to use the right GL format, GL_SRGB8_ALPHA8 with ovr_CreateSwapTextureSetGL function. That file, in turn, needs to include

    Kernel/OVR_Win32_IncludeWindows.h

    since I'm using win32, which includes a bunch of c++ code that breaks everything.

    Is it possible that I just use 0x8C43 when calling createSwapTexture, which is defined here:

    #define GL_SRGB8_ALPHA8_EXT 0x8C43

    If not, how do I use Kernel/OVR_Win32_IncludeWindows.h or LibOvRKernel/src/GL/CAPI_GLE_GL
    without breaking my code?






  • You don't need to include `CAPI_GLE_GL.h`.  In fact you shouldn't.  That's an extension loader used by Oculus for their internal code and examples.  You should either include a different extension loader which IS compatible with vanilla C, or you should just define what you need directly.  You can just declare

    #define GL_SRGB8_ALPHA8_EXT 0x8C43

    in your own code if that's all you need.