38 #include <boost/assert.hpp>
47 OSVR_DEV_VERBOSE(
"Created an OSVR_DisplayConfigObject!");
50 OSVR_DEV_VERBOSE(
"OSVR_DisplayConfigObject destructor");
53 osvr::client::DisplayConfigPtr cfg;
56 #define OSVR_VALIDATE_OUTPUT_PTR(X, DESC) \
57 OSVR_UTIL_MULTILINE_BEGIN \
59 OSVR_DEV_VERBOSE("Passed a null pointer for output parameter " #X \
61 return OSVR_RETURN_FAILURE; \
63 OSVR_UTIL_MULTILINE_END
69 OSVR_DEV_VERBOSE(
"Passed a null client context!");
73 std::shared_ptr<OSVR_DisplayConfigObject> config;
75 config = std::make_shared<OSVR_DisplayConfigObject>(ctx);
76 }
catch (std::exception &e) {
78 "Error creating display config: constructor threw exception :"
84 "Error creating display config - null config returned");
88 OSVR_DEV_VERBOSE(
"Error creating display config - null internal config "
97 #define OSVR_VALIDATE_DISPLAY_CONFIG \
98 OSVR_UTIL_MULTILINE_BEGIN \
99 if (nullptr == disp) { \
100 OSVR_DEV_VERBOSE("Passed a null display config!"); \
101 return OSVR_RETURN_FAILURE; \
103 OSVR_UTIL_MULTILINE_END
109 #define OSVR_VALIDATE_VIEWER_ID \
110 BOOST_ASSERT_MSG(viewer == 0, "Must pass a valid viewer ID.")
112 #define OSVR_VALIDATE_EYE_ID \
113 BOOST_ASSERT_MSG(eye < disp->cfg->getNumViewerEyes(viewer), \
114 "Must pass a valid eye ID.")
117 #define OSVR_VALIDATE_SURFACE_ID \
118 BOOST_ASSERT_MSG(surface == 0, "Must pass a valid surface ID.")
120 #define OSVR_VALIDATE_DISPLAY_INPUT_ID \
121 BOOST_ASSERT_MSG(displayInputIndex < disp->cfg->getNumDisplayInputs(), \
122 "Must pass a valid display input index.")
125 OSVR_VALIDATE_DISPLAY_CONFIG;
129 "Should never get a display config object with a null context in it.");
130 if (
nullptr == ctx) {
138 OSVR_VALIDATE_DISPLAY_CONFIG;
147 OSVR_VALIDATE_DISPLAY_CONFIG;
149 *numDisplayInputs = disp->cfg->getNumDisplayInputs();
157 OSVR_VALIDATE_DISPLAY_CONFIG;
158 OSVR_VALIDATE_DISPLAY_INPUT_ID;
161 *width = disp->cfg->getDisplayInput(displayInputIndex).getDisplayWidth();
162 *height = disp->cfg->getDisplayInput(displayInputIndex).getDisplayHeight();
168 OSVR_VALIDATE_DISPLAY_CONFIG;
170 *viewers = disp->cfg->getNumViewers();
177 OSVR_VALIDATE_DISPLAY_CONFIG;
181 *pose = disp->cfg->getViewer(viewer).getPose();
184 OSVR_DEV_VERBOSE(
"Error getting viewer pose: no pose yet available");
186 }
catch (std::exception &e) {
188 OSVR_DEV_VERBOSE(
"Error getting viewer pose - exception: " << e.what());
197 OSVR_VALIDATE_DISPLAY_CONFIG;
200 *eyes = disp->cfg->getNumViewerEyes(viewer);
208 OSVR_VALIDATE_DISPLAY_CONFIG;
210 OSVR_VALIDATE_EYE_ID;
213 *pose = disp->cfg->getViewerEye(viewer, eye).getPose();
217 "Error getting viewer eye pose: no pose yet available");
219 }
catch (std::exception &e) {
222 "Error getting viewer eye pose - exception: " << e.what());
228 template <
typename Scalar>
233 OSVR_VALIDATE_DISPLAY_CONFIG;
235 OSVR_VALIDATE_EYE_ID;
239 disp->cfg->getViewerEye(viewer, eye).getView(), flags, mat);
243 "Error getting viewer eye view matrix: no pose yet available");
245 }
catch (std::exception &e) {
248 "Error getting viewer eye view matrix - exception: " << e.what());
251 OSVR_DEV_VERBOSE(
"Error getting viewer eye view matrix");
259 return getViewMatrixImpl(disp, viewer, eye, mat, flags);
265 return getViewMatrixImpl(disp, viewer, eye, mat, flags);
272 OSVR_VALIDATE_DISPLAY_CONFIG;
274 OSVR_VALIDATE_EYE_ID;
276 *surfaces = disp->cfg->getNumViewerEyeSurfaces(viewer, eye);
286 OSVR_VALIDATE_DISPLAY_CONFIG;
288 OSVR_VALIDATE_EYE_ID;
294 auto viewport = disp->cfg->getViewerEyeSurface(viewer, eye, surface)
295 .getDisplayRelativeViewport();
296 *left = viewport.left;
297 *bottom = viewport.bottom;
298 *width = viewport.width;
299 *height = viewport.height;
307 OSVR_VALIDATE_DISPLAY_CONFIG;
309 OSVR_VALIDATE_EYE_ID;
313 *displayInput = disp->cfg->getViewerEyeSurface(viewer, eye, surface)
314 .getDisplayInputIdx();
319 template <
typename Scalar>
320 static inline OSVR_ReturnCode
325 OSVR_VALIDATE_DISPLAY_CONFIG;
327 OSVR_VALIDATE_EYE_ID;
330 if (near == 0 || far == 0) {
331 OSVR_DEV_VERBOSE(
"Can't specify a near or far distance as 0!");
334 if (near < 0 || far < 0) {
335 OSVR_DEV_VERBOSE(
"Can't specify a negative near or far distance!");
339 OSVR_DEV_VERBOSE(
"Can't specify equal near and far distances!");
343 disp->cfg->getViewerEyeSurface(viewer, eye, surface)
344 .getProjection(near, far, flags),
354 return getProjectionMatrixImpl(disp, viewer, eye, surface, near, far, flags,
362 return getProjectionMatrixImpl(disp, viewer, eye, surface, near, far, flags,
370 OSVR_VALIDATE_DISPLAY_CONFIG;
372 OSVR_VALIDATE_EYE_ID;
377 auto rect = disp->cfg->getViewerEyeSurface(viewer, eye, surface).getRect();
378 *left = rect[rect.LEFT];
379 *right = rect[rect.RIGHT];
380 *bottom = rect[rect.BOTTOM];
381 *top = rect[rect.TOP];
388 OSVR_VALIDATE_DISPLAY_CONFIG;
390 OSVR_VALIDATE_EYE_ID;
393 *distortionRequested =
394 disp->cfg->getViewerEyeSurface(viewer, eye, surface).wantDistortion()
403 OSVR_VALIDATE_DISPLAY_CONFIG;
405 OSVR_VALIDATE_EYE_ID;
408 *priority = disp->cfg->getViewerEyeSurface(viewer, eye, surface)
409 .getRadialDistortionPriority();
416 OSVR_VALIDATE_DISPLAY_CONFIG;
418 OSVR_VALIDATE_EYE_ID;
421 auto optParams = disp->cfg->getViewerEyeSurface(viewer, eye, surface)
422 .getRadialDistortionParams();
423 if (optParams.is_initialized()) {
424 *params = *optParams;
uint8_t OSVR_CBool
A pre-C99-safe bool type. Canonical values for true and false are provided. Interpretation of other v...
Parameters for a per-color-component radial distortion shader.
#define OSVR_FALSE
Canonical "false" value for OSVR_CBool.
uint32_t OSVR_SurfaceCount
The integer type specifying the number of surfaces seen by a viewer's eye.
#define OSVR_VALIDATE_SURFACE_ID
OSVR_ReturnCode osvrClientCheckDisplayStartup(OSVR_DisplayConfig disp)
Checks to see if a display is fully configured and ready, including having received its first pose up...
int32_t OSVR_DistortionPriority
The integer type used to indicate relative priorities of a display distortion strategy. Negative values are defined to mean that strategy is unavailable.
OSVR_ReturnCode osvrClientGetViewerEyePose(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_Pose3 *pose)
Get the "viewpoint" for the given eye of a viewer in a display config.
OSVR_ReturnCode osvrClientGetNumDisplayInputs(OSVR_DisplayConfig disp, OSVR_DisplayInputCount *numDisplayInputs)
A display config can have one or more display inputs to pass pixels over (HDMI/DVI connections...
#define OSVR_TRUE
Canonical "true" value for OSVR_CBool.
OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixd(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_MatrixConventions flags, double *mat)
Get the view matrix (inverse of pose) for the given eye of a viewer in a display config - matrix of d...
OSVR_ReturnCode osvrClientGetRelativeViewportForViewerEyeSurface(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_SurfaceCount surface, OSVR_ViewportDimension *left, OSVR_ViewportDimension *bottom, OSVR_ViewportDimension *width, OSVR_ViewportDimension *height)
Get the dimensions/location of the viewport within the display input for a surface seen by an eye of ...
uint16_t OSVR_MatrixConventions
Type for passing matrix convention flags.
OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_SurfaceCount surface, double *left, double *right, double *bottom, double *top)
Get the clipping planes (positions at unit distance) for a surface seen by an eye of a viewer in a di...
OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixf(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_MatrixConventions flags, float *mat)
Get the view matrix (inverse of pose) for the given eye of a viewer in a display config - matrix of f...
OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortionPriority(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_SurfaceCount surface, OSVR_DistortionPriority *priority)
Returns the priority/availability of radial distortion parameters for a surface seen by an eye of a v...
#define OSVR_RETURN_FAILURE
The "failure" value for an OSVR_ReturnCode.
OSVR_ReturnCode osvrClientGetViewerPose(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_Pose3 *pose)
Get the pose of a viewer in a display config.
void * acquireObject(T obj)
Pass (smart-pointer) ownership of some object to the client context.
OSVR_ReturnCode osvrClientGetNumSurfacesForViewerEye(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_SurfaceCount *surfaces)
Each eye of each viewer in a display config has one or more surfaces (aka "screens") on which content...
OSVR_ReturnCode osvrClientGetDisplayDimensions(OSVR_DisplayConfig disp, OSVR_DisplayInputCount displayInputIndex, OSVR_DisplayDimension *width, OSVR_DisplayDimension *height)
Retrieve the pixel dimensions of a given display input for a display config.
OSVR_ReturnCode osvrClientGetNumEyesForViewer(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount *eyes)
Each viewer in a display config can have one or more "eyes" which have a substantially similar pose: ...
OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixd(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_SurfaceCount surface, double near, double far, OSVR_MatrixConventions flags, double *matrix)
Get the projection matrix for a surface seen by an eye of a viewer in a display config. (double version)
#define OSVR_VALIDATE_OUTPUT_PTR(X, DESC)
#define OSVR_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
uint32_t OSVR_ViewerCount
The integer type specifying a number of viewers in a system.
bool releaseObject(void *obj)
Frees some object whose lifetime is controlled by the client context.
#define OSVR_VALIDATE_VIEWER_ID
OSVR_ReturnCode osvrClientGetViewerEyeSurfaceDisplayInputIndex(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_SurfaceCount surface, OSVR_DisplayInputCount *displayInput)
Get the index of the display input for a surface seen by an eye of a viewer in a display config...
OSVR_ReturnCode osvrClientGetDisplay(OSVR_ClientContext ctx, OSVR_DisplayConfig *disp)
Allocates a display configuration object populated with data from the OSVR system.
OSVR_ReturnCode osvrClientFreeDisplay(OSVR_DisplayConfig disp)
Frees a display configuration object. The corresponding context must still be open.
OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixf(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_SurfaceCount surface, float near, float far, OSVR_MatrixConventions flags, float *matrix)
Get the projection matrix for a surface seen by an eye of a viewer in a display config. (float version)
OSVR_ReturnCode osvrClientGetNumViewers(OSVR_DisplayConfig disp, OSVR_ViewerCount *viewers)
A display config can have one (or theoretically more) viewers: retrieve the viewer count...
static DisplayConfigPtr create(OSVR_ClientContext ctx)
uint8_t OSVR_EyeCount
The integer type specifying the number of eyes (viewpoints) of a viewer.
Internal, configured header file for verbosity macros.
uint8_t OSVR_DisplayInputCount
A count or index for a display input in a display config.
A structure defining a 3D (6DOF) rigid body pose: translation and rotation.
Header for interoperation between the Eigen math library, the internal mini math library, and VRPN's quatlib.
int32_t OSVR_ViewportDimension
The integer type used in specification of size or location of a viewport.
OSVR_ReturnCode osvrClientDoesViewerEyeSurfaceWantDistortion(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_SurfaceCount surface, OSVR_CBool *distortionRequested)
Determines if a surface seen by an eye of a viewer in a display config requests some distortion to be...
OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortion(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, OSVR_SurfaceCount surface, OSVR_RadialDistortionParameters *params)
Returns the radial distortion parameters, if known/requested, for a surface seen by an eye of a viewe...
void matrixEigenAssign(T const &src, OSVR_MatrixConventions flags, Scalar *dest)
Helper function template to assign/convert matrices as required.
double Scalar
Common scalar type.
int32_t OSVR_DisplayDimension
The integer type used in specification of size or location of a display input, in pixels...