25 #ifndef INCLUDED_Display_h_GUID_E15D0209_6784_4CBF_4F89_788E7A4B440C 26 #define INCLUDED_Display_h_GUID_E15D0209_6784_4CBF_4F89_788E7A4B440C 44 return osvrClientGetNumViewers(disp, &viewers);
50 return osvrClientGetNumEyesForViewer(disp, viewer, &eyes);
53 inline OSVR_ReturnCode
57 return osvrClientGetNumSurfacesForViewerEye(disp, viewer, eye, &surfaces);
60 inline OSVR_ReturnCode osvrClientGetRelativeViewportForViewerEyeSurface(
65 return osvrClientGetRelativeViewportForViewerEyeSurface(
66 disp, viewer, eye, surface, &left, &bottom, &width, &height);
77 #ifndef OSVR_CLIENTKIT_CUSTOM_DISPLAY_ERROR_HANDLER 78 static inline void handleDisplayError(
const char msg[]) {
79 throw std::runtime_error(msg);
85 typedef shared_ptr<OSVR_DisplayConfigObject> UnderlyingDisplayConfigPtr;
121 : m_disp(disp), m_viewer(viewer), m_eye(eye), m_surface(surface) {}
129 OSVR_ReturnCode ret =
130 osvrClientGetRelativeViewportForViewerEyeSurface(
131 m_disp, m_viewer, m_eye, m_surface, viewport.left,
132 viewport.bottom, viewport.width, viewport.height);
135 "Could not access relative viewport for surface!");
146 OSVR_ReturnCode ret =
148 m_disp, m_viewer, m_eye, m_surface, near, far, flags,
152 "Could not access projection matrix for surface!");
160 OSVR_ReturnCode ret =
162 m_disp, m_viewer, m_eye, m_surface, near, far, flags,
166 "Could not access projection matrix for surface!");
175 OSVR_ReturnCode ret =
177 m_disp, m_viewer, m_eye, m_surface, &clippingPlanes.left,
178 &clippingPlanes.right, &clippingPlanes.bottom, &clippingPlanes.top);
181 "Could not access projection clipping planes for surface!");
183 return clippingPlanes;
193 m_disp, m_viewer, m_eye, m_surface, &distort);
196 "Could not get distortion request for surface!");
210 OSVR_ReturnCode ret =
212 m_disp, m_viewer, m_eye, m_surface, &prio);
225 m_disp, m_viewer, m_eye, m_surface, ¶ms);
228 "Could not get radial distortion params for surface!");
251 : m_disp(disp), m_viewer(viewer), m_eye(eye) {
253 handleDisplayError(
"Can't interact with an eye using a " 254 "null/invalid display config");
262 OSVR_ReturnCode ret = osvrClientGetNumSurfacesForViewerEye(
263 m_disp, m_viewer, m_eye, &surfaces);
265 handleDisplayError(
"Couldn't get number of surfaces in this " 266 "display for the given viewer and eye!");
272 return Surface(m_disp, m_viewer, m_eye, surface);
281 OSVR_ReturnCode ret =
293 m_disp, m_viewer, m_eye, flags, mat);
301 m_disp, m_viewer, m_eye, flags, mat);
307 template <
typename F>
313 functor(getSurface(surface));
335 : m_disp(disp), m_viewer(viewer) {
337 handleDisplayError(
"Can't interact with a viewer using a " 338 "null/invalid display config");
346 OSVR_ReturnCode ret =
347 osvrClientGetNumEyesForViewer(m_disp, m_viewer, &eyes);
349 handleDisplayError(
"Couldn't get number of eyes in this " 350 "display for the given viewer!");
356 return Eye(m_disp, m_viewer, eye);
359 return Surface(m_disp, m_viewer, eye, surface);
373 OSVR_ReturnCode ret =
380 template <
typename F>
385 functor(getEye(eye));
392 getEye(eye).forEachSurface(functor);
420 m_disp = m_owningDisp.get();
427 : m_disp(NULL), m_owningDisp(ptr) {
429 m_disp = m_owningDisp.get();
438 bool valid()
const {
return m_disp != NULL; }
443 "Can't operate on an invalid DisplayConfig!");
450 "Can't operate on an invalid DisplayConfig!");
471 handleDisplayError(
"Couldn't get number of display inputs!");
484 handleDisplayError(
"Couldn't get dimensions of this " 495 OSVR_ReturnCode ret = osvrClientGetNumViewers(m_disp, &viewers);
497 handleDisplayError(
"Couldn't get number of viewers in this " 505 return Viewer(m_disp, viewer);
510 return Eye(m_disp, viewer, eye);
516 return Surface(m_disp, viewer, eye, surface);
523 template <
typename F>
528 functor(getViewer(viewer));
532 template <
typename F>
537 getViewer(viewer).forEachEye(functor);
541 template <
typename F>
546 getViewer(viewer).forEachSurface(functor);
560 UnderlyingDisplayConfigPtr
getOwningPtr()
const {
return m_owningDisp; }
565 UnderlyingDisplayConfigPtr m_owningDisp;
571 return (lhs.getSurfaceID() == rhs.getSurfaceID()) &&
572 (lhs.getEyeID() == rhs.getEyeID()) &&
573 (lhs.getViewerID() == rhs.getViewerID()) &&
574 (lhs.getDisplayConfig() == rhs.getDisplayConfig());
580 return (lhs.getSurfaceID() != rhs.getSurfaceID()) ||
581 (lhs.getEyeID() != rhs.getEyeID()) ||
582 (lhs.getViewerID() != rhs.getViewerID()) ||
583 (lhs.getDisplayConfig() != rhs.getDisplayConfig());
589 return (lhs.getEyeID() == rhs.getEyeID()) &&
590 (lhs.getViewerID() == rhs.getViewerID()) &&
591 (lhs.getDisplayConfig() == rhs.getDisplayConfig());
597 return (lhs.getEyeID() != rhs.getEyeID()) ||
598 (lhs.getViewerID() != rhs.getViewerID()) ||
599 (lhs.getDisplayConfig() != rhs.getDisplayConfig());
605 return (lhs.getViewerID() == rhs.getViewerID()) &&
606 (lhs.getDisplayConfig() == rhs.getDisplayConfig());
612 return (lhs.getViewerID() != rhs.getViewerID()) ||
613 (lhs.getDisplayConfig() != rhs.getDisplayConfig());
659 #endif // INCLUDED_Display_h_GUID_E15D0209_6784_4CBF_4F89_788E7A4B440C bool operator!=(Surface const &lhs, Surface const &rhs)
Inequality operator for clientkit::Surface.
Definition: Display.h:579
uint8_t OSVR_CBool
A pre-C99-safe bool type.
Definition: BoolC.h:50
void forEachSurface(F OSVR_CLIENTKIT_FUNCTOR_REF functor)
Definition: Display.h:308
Parameters for a per-color-component radial distortion shader.
Definition: RadialDistortionParametersC.h:51
bool operator==(Surface const &lhs, Surface const &rhs)
Equality operator for clientkit::Surface.
Definition: Display.h:570
Constant for the number of elements in the matrices we use - 4x4.
Definition: MatrixConventionsC.h:127
Client context object: Create and keep one in your application.
Definition: Context_decl.h:57
void forEachSurface(F OSVR_CLIENTKIT_FUNCTOR_REF functor)
Definition: Display.h:542
bool getViewMatrix(OSVR_MatrixConventions flags, float mat[OSVR_MATRIX_SIZE])
Definition: Display.h:298
uint32_t OSVR_SurfaceCount
The integer type specifying the number of surfaces seen by a viewer's eye.
Definition: RenderingTypesC.h:108
OSVR_CLIENTKIT_EXPORT 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.
Definition: DisplayC.cpp:350
DisplayConfig()
Empty constructor - constructs a config where valid() is false.
Definition: Display.h:413
DisplayConfig(ClientContext &ctx)
Retrieve a display config, owning it and managing its lifetime.
Definition: Display.h:417
void getProjectionMatrix(double near, double far, OSVR_MatrixConventions flags, double matrix[OSVR_MATRIX_SIZE]) const
Gets the projection matrix.
Definition: Display.h:143
bool checkStartup() const
Checks if the display is fully configured and ready, including first pose.
Definition: Display.h:458
bool getPose(OSVR_Pose3 &pose)
Attempt to get the eye pose.
Definition: Display.h:280
Definition: DisplayC.cpp:43
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
#define OSVR_CLIENTKIT_FUNCTOR_REF
Define if your compiler supports && in a type-deduced context.
Definition: CppAPI.h:50
OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientCheckDisplayStartup(OSVR_DisplayConfig disp)
Checks to see if a display is fully configured and ready, including having received its first pose up...
Definition: DisplayC.cpp:137
OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetDisplay(OSVR_ClientContext ctx, OSVR_DisplayConfig *disp)
Allocates a display configuration object populated with data from the OSVR system.
Definition: DisplayC.cpp:65
int32_t OSVR_DistortionPriority
The integer type used to indicate relative priorities of a display distortion strategy.
Definition: RenderingTypesC.h:121
DisplayConfig(OSVR_DisplayConfig disp)
Construct from a (presumably-externally-managed) raw display config, not affecting lifetime...
Definition: Display.h:435
void forEachSurface(F functor)
Definition: Display.h:388
UnderlyingDisplayConfigPtr getOwningPtr() const
Gets a copy of the owning pointer, if we hold shared ownership over this DisplayConfig.
Definition: Display.h:560
OSVR_CLIENTKIT_EXPORT 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...
Definition: DisplayC.cpp:144
Wrapper for a viewer, eye, and surface bound to a display config.
Definition: Display.h:117
OSVR_CLIENTKIT_EXPORT 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...
Definition: DisplayC.cpp:366
bool isDistortionRequested() const
Determines if the description of the surface requests any distortion to be performed.
Definition: Display.h:190
void getProjectionMatrix(float near, float far, OSVR_MatrixConventions flags, float matrix[OSVR_MATRIX_SIZE]) const
Definition: Display.h:157
bool getViewMatrix(OSVR_MatrixConventions flags, double mat[OSVR_MATRIX_SIZE])
Attempt to get the view matrix.
Definition: Display.h:290
OSVR_CLIENTKIT_EXPORT 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...
Definition: DisplayC.cpp:262
#define OSVR_TRUE
Canonical "true" value for OSVR_CBool.
Definition: BoolC.h:52
bool operator==(DisplayConfig const &lhs, DisplayConfig const &rhs)
Equality operator for clientkit::DisplayConfig - does not consider the ownership status in the compar...
Definition: Display.h:619
Header to bring shared_ptr into the osvr namespace.
DisplayConfig(UnderlyingDisplayConfigPtr const &ptr)
Construct from a shared pointer to the underlying display config, taking shared ownership.
Definition: Display.h:426
bool getPose(OSVR_Pose3 &pose)
Attempt to get the viewer pose.
Definition: Display.h:372
Definition: Display.h:103
bool operator==(DisplayConfig const &lhs, OSVR_DisplayConfig rhs)
Equality operator for clientkit::DisplayConfig.
Definition: Display.h:625
OSVR_CLIENTKIT_EXPORT 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.
Definition: DisplayC.cpp:153
void forEachEye(F OSVR_CLIENTKIT_FUNCTOR_REF functor)
Definition: Display.h:533
uint16_t OSVR_MatrixConventions
Type for passing matrix convention flags.
Definition: MatrixConventionsC.h:54
bool operator==(Viewer const &lhs, Viewer const &rhs)
Equality operator for clientkit::Viewer.
Definition: Display.h:604
OSVR_DisplayInputCount getNumDisplayInputs() const
Returns number of inputs for this display.
Definition: Display.h:466
bool operator==(Eye const &lhs, Eye const &rhs)
Equality operator for clientkit::Eye.
Definition: Display.h:588
Definition: Display.h:110
OSVR_CLIENTKIT_EXPORT 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...
Definition: DisplayC.cpp:385
Wrapper for a viewer and eye bound to a display config.
Definition: Display.h:248
bool operator!=(DisplayConfig const &lhs, DisplayConfig const &rhs)
Inequality operator for clientkit::DisplayConfig - does not consider the ownership status in the comp...
Definition: Display.h:638
OSVR_CLIENTKIT_EXPORT 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...
Definition: DisplayC.cpp:413
#define OSVR_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
Definition: ReturnCodesC.h:45
uint32_t OSVR_ViewerCount
The integer type specifying a number of viewers in a system.
Definition: RenderingTypesC.h:72
OSVR_CLIENTKIT_EXPORT 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.
Definition: DisplayC.cpp:358
OSVR_ClientContext get()
Gets the bare OSVR_ClientContext.
Definition: Context.h:114
bool operator!=(DisplayConfig const &lhs, OSVR_DisplayConfig rhs)
Inequality operator for clientkit::DisplayConfig.
Definition: Display.h:644
bool valid() const
Checks the validity of the contained pointer.
Definition: Display.h:438
OSVR_RadialDistortionParameters getRadialDistortion()
Get the radial distortion parameters.
Definition: Display.h:222
OSVR_DistortionPriority getRadialDistortionPriority()
Get the priority/availability of radial distortion parameters for this surface.
Definition: Display.h:208
bool operator!=(Eye const &lhs, Eye const &rhs)
Inequality operator for clientkit::Eye.
Definition: Display.h:596
OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientFreeDisplay(OSVR_DisplayConfig disp)
Frees a display configuration object.
Definition: DisplayC.cpp:124
OSVR_CLIENTKIT_EXPORT 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.
Definition: DisplayC.cpp:204
uint8_t OSVR_EyeCount
The integer type specifying the number of eyes (viewpoints) of a viewer.
Definition: RenderingTypesC.h:92
uint8_t OSVR_DisplayInputCount
A count or index for a display input in a display config.
Definition: RenderingTypesC.h:51
osvr::clientkit::DisplayDimensions getDisplayDimensions(OSVR_DisplayInputCount displayInputIndex) const
Returns display dimensions for a display input.
Definition: Display.h:479
bool operator==(OSVR_DisplayConfig lhs, DisplayConfig const &rhs)
Equality operator for clientkit::DisplayConfig.
Definition: Display.h:631
A structure defining a 3D (6DOF) rigid body pose: translation and rotation.
Definition: Pose3C.h:54
Class wrapping OSVR_DisplayConfig objects, optionally managing shared ownership.
Definition: Display.h:409
bool operator!=(OSVR_DisplayConfig lhs, DisplayConfig const &rhs)
Inequality operator for clientkit::DisplayConfig.
Definition: Display.h:650
ProjectionClippingPlanes getProjectionClippingPlanes() const
Gets the clipping planes.
Definition: Display.h:173
int32_t OSVR_ViewportDimension
The integer type used in specification of size or location of a viewport.
Definition: RenderingTypesC.h:113
RelativeViewport getRelativeViewport() const
Gets the video-input-relative viewport corresponding to this surface.
Definition: Display.h:127
OSVR_CLIENTKIT_EXPORT 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...
Definition: DisplayC.cpp:256
void forEachViewer(F OSVR_CLIENTKIT_FUNCTOR_REF functor)
Definition: Display.h:524
OSVR_DisplayConfig getDisplayConfig() const
Gets the raw OSVR_DisplayConfig.
Definition: Display.h:556
OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetViewerPose(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_Pose3 *pose)
Get the pose of a viewer in a display config.
Definition: DisplayC.cpp:174
UnderlyingDisplayConfigPtr getDisplay(ClientContext &ctx)
Get a shared_ptr to a DisplayConfig (with appropriate deleter pre-loaded)
Definition: Display.h:89
bool operator!=(Viewer const &lhs, Viewer const &rhs)
Inequality operator for clientkit::Viewer.
Definition: Display.h:611
OSVR_CLIENTKIT_EXPORT 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...
Definition: DisplayC.cpp:400
Wrapper for a viewer bound to a display config.
Definition: Display.h:332
void forEachEye(F OSVR_CLIENTKIT_FUNCTOR_REF functor)
Definition: Display.h:381
int32_t OSVR_DisplayDimension
The integer type used in specification of size or location of a display input, in pixels...
Definition: RenderingTypesC.h:56
Header configuring some general properties of the header-only C++ API provided by ClientKit...