summaryrefslogtreecommitdiffhomepage
path: root/ovr_sdk_win_23.0.0/LibOVR/Include/OVR_CAPI_GL.h
blob: 6c1b9bf064e4640005280241fa164a24f62ce8e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/********************************************************************************/ /**
 \file      OVR_CAPI_GL.h
 \brief     OpenGL-specific structures used by the CAPI interface.
 \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
 ************************************************************************************/

#ifndef OVR_CAPI_GL_h
#define OVR_CAPI_GL_h

#include "OVR_CAPI.h"

#if !defined(OVR_EXPORTING_CAPI)

/// Creates a TextureSwapChain suitable for use with OpenGL.
///
/// \param[in]  session Specifies an ovrSession previously returned by ovr_Create.
/// \param[in]  desc Specifies the requested texture properties.
///             See notes for more info about texture format.
/// \param[out] out_TextureSwapChain Returns the created ovrTextureSwapChain,
///             which will be valid upon a successful return value, else it will be NULL.
///             This texture swap chain must be eventually destroyed via
//              ovr_DestroyTextureSwapChain before destroying the session with ovr_Destroy.
///
/// \return Returns an ovrResult indicating success or failure. In the case of failure, use
///         ovr_GetLastErrorInfo to get more information.
///
/// \note The \a format provided should be thought of as the format the distortion compositor will
///       use when reading the contents of the texture. To that end, it is highly recommended
///       that the application requests texture swap chain formats that are in sRGB-space
///       (e.g. OVR_FORMAT_R8G8B8A8_UNORM_SRGB) as the distortion compositor does sRGB-correct
///       rendering. Furthermore, the app should then make sure "glEnable(GL_FRAMEBUFFER_SRGB);"
///       is called before rendering into these textures. Even though it is not recommended,
///       if the application would like to treat the texture as a linear format and do
///       linear-to-gamma conversion in GLSL, then the application can avoid
///       calling "glEnable(GL_FRAMEBUFFER_SRGB);", but should still pass in an sRGB variant for
///       the \a format. Failure to do so will cause the distortion compositor to apply incorrect
///       gamma conversions leading to gamma-curve artifacts.
///
/// \see ovr_GetTextureSwapChainLength
/// \see ovr_GetTextureSwapChainCurrentIndex
/// \see ovr_GetTextureSwapChainDesc
/// \see ovr_GetTextureSwapChainBufferGL
/// \see ovr_DestroyTextureSwapChain
///
OVR_PUBLIC_FUNCTION(ovrResult)
ovr_CreateTextureSwapChainGL(
    ovrSession session,
    const ovrTextureSwapChainDesc* desc,
    ovrTextureSwapChain* out_TextureSwapChain);

/// Get a specific buffer within the chain as a GL texture name
///
/// \param[in]  session Specifies an ovrSession previously returned by ovr_Create.
/// \param[in]  chain Specifies an ovrTextureSwapChain previously returned
///             by ovr_CreateTextureSwapChainGL
/// \param[in]  index Specifies the index within the chain to retrieve.
///             Must be between 0 and length (see ovr_GetTextureSwapChainLength)
///             or may pass -1 to get the buffer at the CurrentIndex location.
///             (Saving a call to GetTextureSwapChainCurrentIndex)
/// \param[out] out_TexId Returns the GL texture object name associated with
///             the specific index requested
///
/// \return Returns an ovrResult indicating success or failure.
///         In the case of failure, use ovr_GetLastErrorInfo to get more information.
///
OVR_PUBLIC_FUNCTION(ovrResult)
ovr_GetTextureSwapChainBufferGL(
    ovrSession session,
    ovrTextureSwapChain chain,
    int index,
    unsigned int* out_TexId);

/// Creates a Mirror Texture which is auto-refreshed to mirror Rift contents produced by this
/// application.
///
/// A second call to ovr_CreateMirrorTextureWithOptionsGL for a given ovrSession before destroying
/// the first one is not supported and will result in an error return.
///
/// \param[in]  session Specifies an ovrSession previously returned by ovr_Create.
/// \param[in]  desc Specifies the requested mirror texture description.
/// \param[out] out_MirrorTexture Specifies the created ovrMirrorTexture, which will be
///             valid upon a successful return value, else it will be NULL.
///             This texture must be eventually destroyed via ovr_DestroyMirrorTexture before
///             destroying the session with ovr_Destroy.
///
/// \return Returns an ovrResult indicating success or failure. In the case of failure, use
///         ovr_GetLastErrorInfo to get more information.
///
/// \note The \a format provided should be thought of as the format the distortion compositor will
///       use when writing into the mirror texture. It is highly recommended that mirror textures
//        are requested as sRGB formats because the distortion compositor does sRGB-correct
///       rendering. If the application requests a non-sRGB format (e.g. R8G8B8A8_UNORM) as the
///       mirror texture, then the application might have to apply a manual linear-to-gamma
///       conversion when reading from the mirror texture. Failure to do so can result in
//        incorrect gamma conversions leading to gamma-curve artifacts and color banding.
///
/// \see ovr_GetMirrorTextureBufferGL
/// \see ovr_DestroyMirrorTexture
///
OVR_PUBLIC_FUNCTION(ovrResult)
ovr_CreateMirrorTextureWithOptionsGL(
    ovrSession session,
    const ovrMirrorTextureDesc* desc,
    ovrMirrorTexture* out_MirrorTexture);

/// Deprecated. Use ovr_CreateMirrorTextureWithOptionsGL instead
///
/// Same as ovr_CreateMirrorTextureWithOptionsGL except doesn't use ovrMirrorOptions flags as part
/// of ovrMirrorTextureDesc's MirrorOptions field, and defaults to ovrMirrorOption_PostDistortion
///
/// \see ovrMirrorOptions, ovr_CreateMirrorTextureWithOptionsGL
///
OVR_PUBLIC_FUNCTION(ovrResult)
ovr_CreateMirrorTextureGL(
    ovrSession session,
    const ovrMirrorTextureDesc* desc,
    ovrMirrorTexture* out_MirrorTexture);

/// Get a the underlying buffer as a GL texture name
///
/// \param[in]  session Specifies an ovrSession previously returned by ovr_Create.
/// \param[in]  mirrorTexture Specifies an ovrMirrorTexture previously returned
//              by ovr_CreateMirrorTextureWithOptionsGL
/// \param[out] out_TexId Specifies the GL texture object name associated with the mirror texture
///
/// \return Returns an ovrResult indicating success or failure. In the case of failure, use
///         ovr_GetLastErrorInfo to get more information.
///
OVR_PUBLIC_FUNCTION(ovrResult)
ovr_GetMirrorTextureBufferGL(
    ovrSession session,
    ovrMirrorTexture mirrorTexture,
    unsigned int* out_TexId);

#endif // !defined(OVR_EXPORTING_CAPI)

#endif // OVR_CAPI_GL_h