OVR_CAPI_GL.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /********************************************************************************//**
  2. \file OVR_CAPI_GL.h
  3. \brief OpenGL-specific structures used by the CAPI interface.
  4. \copyright Copyright 2013 Oculus VR, LLC. All Rights reserved.
  5. ************************************************************************************/
  6. #ifndef OVR_CAPI_GL_h
  7. #define OVR_CAPI_GL_h
  8. #include "OVR_CAPI.h"
  9. // We avoid gl.h #includes here which interferes with some users' use of alternatives and typedef GLuint manually.
  10. typedef unsigned int GLuint;
  11. #if defined(_MSC_VER)
  12. #pragma warning(push)
  13. #pragma warning(disable: 4324) // structure was padded due to __declspec(align())
  14. #endif
  15. /// Used to pass GL eye texture data to ovr_EndFrame.
  16. typedef struct ovrGLTextureData_s
  17. {
  18. ovrTextureHeader Header; ///< General device settings.
  19. GLuint TexId; ///< The OpenGL name for this texture.
  20. } ovrGLTextureData;
  21. OVR_STATIC_ASSERT(sizeof(ovrTexture) >= sizeof(ovrGLTextureData), "Insufficient size.");
  22. OVR_STATIC_ASSERT(sizeof(ovrGLTextureData) == sizeof(ovrTextureHeader) + 4, "size mismatch");
  23. /// Contains OpenGL-specific texture information.
  24. typedef union ovrGLTexture_s
  25. {
  26. ovrTexture Texture; ///< General device settings.
  27. ovrGLTextureData OGL; ///< OpenGL-specific settings.
  28. } ovrGLTexture;
  29. #if defined(_MSC_VER)
  30. #pragma warning(pop)
  31. #endif
  32. /// Creates a Texture Set suitable for use with OpenGL.
  33. ///
  34. /// Multiple calls to ovr_CreateSwapTextureSetD3D11 for the same ovrHmd are supported, but applications
  35. /// cannot rely on switching between ovrSwapTextureSets at runtime without a performance penalty.
  36. ///
  37. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  38. /// \param[in] format Specifies the texture format.
  39. /// \param[in] width Specifies the requested texture width.
  40. /// \param[in] height Specifies the requested texture height.
  41. /// \param[out] outTextureSet Specifies the created ovrSwapTextureSet, which will be valid upon a successful return value, else it will be NULL.
  42. /// This texture set must be eventually destroyed via ovr_DestroySwapTextureSet before destroying the HMD with ovr_Destroy.
  43. ///
  44. /// \return Returns an ovrResult indicating success or failure. In the case of failure, use
  45. /// ovr_GetLastErrorInfo to get more information.
  46. ///
  47. /// \note The \a format provided should be thought of as the format the distortion compositor will use when reading the contents of the
  48. /// texture. To that end, it is highly recommended that the application requests swap-texture-set formats that are in sRGB-space (e.g. GL_SRGB_ALPHA8)
  49. /// as the distortion compositor does sRGB-correct rendering. Furthermore, the app should then make sure "glEnable(GL_FRAMEBUFFER_SRGB);"
  50. /// is called before rendering into these textures. Even though it is not recommended, if the application would like to treat the
  51. /// texture as a linear format and do linear-to-gamma conversion in GLSL, then the application can avoid calling "glEnable(GL_FRAMEBUFFER_SRGB);",
  52. /// but should still pass in GL_SRGB_ALPHA8 (not GL_RGBA) for the \a format. Failure to do so will cause the distortion compositor
  53. /// to apply incorrect gamma conversions leading to gamma-curve artifacts.
  54. ///
  55. /// \see ovr_DestroySwapTextureSet
  56. ///
  57. OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateSwapTextureSetGL(ovrSession session, GLuint format,
  58. int width, int height,
  59. ovrSwapTextureSet** outTextureSet);
  60. /// Creates a Mirror Texture which is auto-refreshed to mirror Rift contents produced by this application.
  61. ///
  62. /// A second call to ovr_CreateMirrorTextureGL for a given ovrHmd before destroying the first one
  63. /// is not supported and will result in an error return.
  64. ///
  65. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  66. /// \param[in] format Specifies the texture format.
  67. /// \param[in] width Specifies the requested texture width.
  68. /// \param[in] height Specifies the requested texture height.
  69. /// \param[out] outMirrorTexture Specifies the created ovrSwapTexture, which will be valid upon a successful return value, else it will be NULL.
  70. /// This texture must be eventually destroyed via ovr_DestroyMirrorTexture before destroying the HMD with ovr_Destroy.
  71. ///
  72. /// \return Returns an ovrResult indicating success or failure. In the case of failure, use
  73. /// ovr_GetLastErrorInfo to get more information.
  74. ///
  75. /// \note The \a format provided should be thought of as the format the distortion compositor will use when writing into the mirror
  76. /// texture. It is highly recommended that mirror textures are requested as GL_SRGB_ALPHA8 because the distortion compositor
  77. /// does sRGB-correct rendering. If the application requests a non-sRGB format (e.g. GL_RGBA) as the mirror texture,
  78. /// then the application might have to apply a manual linear-to-gamma conversion when reading from the mirror texture.
  79. /// Failure to do so can result in incorrect gamma conversions leading to gamma-curve artifacts and color banding.
  80. ///
  81. /// \see ovr_DestroyMirrorTexture
  82. ///
  83. OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateMirrorTextureGL(ovrSession session, GLuint format,
  84. int width, int height,
  85. ovrTexture** outMirrorTexture);
  86. #endif // OVR_CAPI_GL_h