25 #ifndef INCLUDED_Display_h_GUID_E15D0209_6784_4CBF_4F89_788E7A4B440C
26 #define INCLUDED_Display_h_GUID_E15D0209_6784_4CBF_4F89_788E7A4B440C
53 inline OSVR_ReturnCode
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;
96 struct RelativeViewport {
103 struct ProjectionClippingPlanes {
110 struct DisplayDimensions {
121 : m_disp(disp), m_viewer(viewer), m_eye(eye), m_surface(surface) {}
128 RelativeViewport viewport;
129 OSVR_ReturnCode ret =
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!");
174 ProjectionClippingPlanes clippingPlanes;
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");
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 =
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));
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!");
481 DisplayDimensions dimensions;
484 handleDisplayError(
"Couldn't get dimensions of this "
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>
541 template <
typename F>
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.
uint8_t OSVR_CBool
A pre-C99-safe bool type. Canonical values for true and false are provided. Interpretation of other v...
void forEachSurface(F OSVR_CLIENTKIT_FUNCTOR_REF functor)
Parameters for a per-color-component radial distortion shader.
bool operator==(Surface const &lhs, Surface const &rhs)
Equality operator for clientkit::Surface.
ProjectionClippingPlanes getProjectionClippingPlanes() const
Gets the clipping planes.
Constant for the number of elements in the matrices we use - 4x4.
Client context object: Create and keep one in your application. Handles lifetime management and provi...
void forEachSurface(F OSVR_CLIENTKIT_FUNCTOR_REF functor)
OSVR_DisplayInputCount getNumDisplayInputs() const
Returns number of inputs for this display.
bool getViewMatrix(OSVR_MatrixConventions flags, float mat[OSVR_MATRIX_SIZE])
uint32_t OSVR_SurfaceCount
The integer type specifying the number of surfaces seen by a viewer's eye.
DisplayConfig()
Empty constructor - constructs a config where valid() is false.
DisplayConfig(ClientContext &ctx)
Retrieve a display config, owning it and managing its lifetime.
OSVR_ReturnCode osvrClientCheckDisplayStartup(OSVR_DisplayConfig disp)
Checks to see if a display is fully configured and ready, including having received its first pose up...
bool getPose(OSVR_Pose3 &pose)
Attempt to get the eye pose.
The main namespace for all C++ elements of the framework, internal and external.
#define OSVR_CLIENTKIT_FUNCTOR_REF
Define if your compiler supports && in a type-deduced context.
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.
DisplayConfig(OSVR_DisplayConfig disp)
Construct from a (presumably-externally-managed) raw display config, not affecting lifetime...
void forEachSurface(F functor)
Wrapper for a viewer, eye, and surface bound to a display config. DOES NOT provide lifetime managemen...
bool getViewMatrix(OSVR_MatrixConventions flags, double mat[OSVR_MATRIX_SIZE])
Attempt to get the view matrix.
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.
bool operator==(DisplayConfig const &lhs, DisplayConfig const &rhs)
Equality operator for clientkit::DisplayConfig - does not consider the ownership status in the compar...
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.
bool getPose(OSVR_Pose3 &pose)
Attempt to get the viewer pose.
bool operator==(DisplayConfig const &lhs, OSVR_DisplayConfig rhs)
Equality operator for clientkit::DisplayConfig.
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 ...
void forEachEye(F OSVR_CLIENTKIT_FUNCTOR_REF functor)
uint16_t OSVR_MatrixConventions
Type for passing matrix convention flags.
void getProjectionMatrix(double near, double far, OSVR_MatrixConventions flags, double matrix[OSVR_MATRIX_SIZE]) const
Gets the projection matrix.
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...
bool operator==(Viewer const &lhs, Viewer const &rhs)
Equality operator for clientkit::Viewer.
bool isDistortionRequested() const
Determines if the description of the surface requests any distortion to be performed.
bool operator==(Eye const &lhs, Eye const &rhs)
Equality operator for clientkit::Eye.
OSVR_ReturnCode osvrClientGetViewerPose(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_Pose3 *pose)
Get the pose of a viewer in a display config.
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.
Wrapper for a viewer and eye bound to a display config. DOES NOT provide lifetime management for the ...
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: ...
bool operator!=(DisplayConfig const &lhs, DisplayConfig const &rhs)
Inequality operator for clientkit::DisplayConfig - does not consider the ownership status in the comp...
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_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
uint32_t OSVR_ViewerCount
The integer type specifying a number of viewers in a system.
OSVR_ClientContext get()
Gets the bare OSVR_ClientContext.
bool operator!=(DisplayConfig const &lhs, OSVR_DisplayConfig rhs)
Inequality operator for clientkit::DisplayConfig.
OSVR_ReturnCode osvrClientGetDisplay(OSVR_ClientContext ctx, OSVR_DisplayConfig *disp)
Allocates a display configuration object populated with data from the OSVR system.
bool checkStartup() const
Checks if the display is fully configured and ready, including first pose.
OSVR_RadialDistortionParameters getRadialDistortion()
Get the radial distortion parameters.
OSVR_DistortionPriority getRadialDistortionPriority()
Get the priority/availability of radial distortion parameters for this surface. Negative values (cano...
osvr::clientkit::DisplayDimensions getDisplayDimensions(OSVR_DisplayInputCount displayInputIndex) const
Returns display dimensions for a display input.
bool operator!=(Eye const &lhs, Eye const &rhs)
Inequality operator for clientkit::Eye.
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...
uint8_t OSVR_EyeCount
The integer type specifying the number of eyes (viewpoints) of a viewer.
uint8_t OSVR_DisplayInputCount
A count or index for a display input in a display config.
bool operator==(OSVR_DisplayConfig lhs, DisplayConfig const &rhs)
Equality operator for clientkit::DisplayConfig.
A structure defining a 3D (6DOF) rigid body pose: translation and rotation.
Class wrapping OSVR_DisplayConfig objects, optionally managing shared ownership.
bool operator!=(OSVR_DisplayConfig lhs, DisplayConfig const &rhs)
Inequality operator for clientkit::DisplayConfig.
int32_t OSVR_ViewportDimension
The integer type used in specification of size or location of a viewport.
bool valid() const
Checks the validity of the contained pointer.
UnderlyingDisplayConfigPtr getOwningPtr() const
Gets a copy of the owning pointer, if we hold shared ownership over this DisplayConfig.
void forEachViewer(F OSVR_CLIENTKIT_FUNCTOR_REF functor)
void getProjectionMatrix(float near, float far, OSVR_MatrixConventions flags, float matrix[OSVR_MATRIX_SIZE]) const
OSVR_DisplayConfig getDisplayConfig() const
Gets the raw OSVR_DisplayConfig.
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...
RelativeViewport getRelativeViewport() const
Gets the video-input-relative viewport corresponding to this surface.
UnderlyingDisplayConfigPtr getDisplay(ClientContext &ctx)
Get a shared_ptr to a DisplayConfig (with appropriate deleter pre-loaded)
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...
bool operator!=(Viewer const &lhs, Viewer const &rhs)
Inequality operator for clientkit::Viewer.
Wrapper for a viewer bound to a display config. DOES NOT provide lifetime management for the associat...
struct OSVR_DisplayConfigObject * OSVR_DisplayConfig
Opaque type of a display configuration.
void forEachEye(F OSVR_CLIENTKIT_FUNCTOR_REF functor)
int32_t OSVR_DisplayDimension
The integer type used in specification of size or location of a display input, in pixels...
Header configuring some general properties of the header-only C++ API provided by ClientKit...