OSVR-Core  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ViewerEyeSurfaces.c
Go to the documentation of this file.
1 
11 /*
12 // Copyright 2014 Sensics, Inc.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "License");
15 // you may not use this file except in compliance with the License.
16 // You may obtain a copy of the License at
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 // See the License for the specific language governing permissions and
24 // limitations under the License.
25 */
26 
27 /* Internal Includes */
30 
31 /* Library/third-party includes */
32 /* - none */
33 
34 // Standard includes
35 #include <stdio.h>
36 
37 int main() {
38  OSVR_ClientContext ctx =
39  osvrClientInit("com.osvr.example.ViewerEyeSurfaces", 0);
40  OSVR_DisplayConfig display;
41 
42  /* This is in a loop in case we don't have a display config right away. */
43  OSVR_ReturnCode ret = OSVR_RETURN_FAILURE;
44  do {
45  printf("Trying to get the display config\n");
46  osvrClientUpdate(ctx);
47  ret = osvrClientGetDisplay(ctx, &display);
48  } while (ret == OSVR_RETURN_FAILURE);
49 
50  OSVR_ViewerCount viewers;
51  osvrClientGetNumViewers(display, &viewers);
52 
53  OSVR_ViewerCount viewer;
54  for (viewer = 0; viewer < viewers; ++viewer) {
55  printf("Viewer %d\n", viewer);
56  OSVR_EyeCount eyes;
57  osvrClientGetNumEyesForViewer(display, viewer, &eyes);
58 
59  OSVR_EyeCount eye;
60  for (eye = 0; eye < eyes; ++eye) {
61  printf("\tEye %d\n", eye);
62  OSVR_SurfaceCount surfaces;
63  osvrClientGetNumSurfacesForViewerEye(display, viewer, eye,
64  &surfaces);
65 
66  OSVR_SurfaceCount surface;
67  for (surface = 0; surface < surfaces; ++surface) {
68  printf("\t\tSurface %d\n", surface);
69  }
70  }
71  }
72  osvrClientFreeDisplay(display);
73  osvrClientShutdown(ctx);
74  printf("Library shut down, exiting.\n");
75  return 0;
76 }
uint32_t OSVR_SurfaceCount
The integer type specifying the number of surfaces seen by a viewer's eye.
OSVR_ClientContext osvrClientInit(const char applicationIdentifier[], uint32_t flags=0)
Initialize the library.
Header.
OSVR_ReturnCode osvrClientShutdown(OSVR_ClientContext ctx)
Shutdown the library.
#define OSVR_RETURN_FAILURE
The "failure" value for an OSVR_ReturnCode.
Definition: ReturnCodesC.h:47
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 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: ...
uint32_t OSVR_ViewerCount
The integer type specifying a number of viewers in a system.
struct OSVR_ClientContextObject * OSVR_ClientContext
Opaque handle that should be retained by your application. You need only and exactly one...
OSVR_ReturnCode osvrClientUpdate(OSVR_ClientContext ctx)
Updates the state of the context - call regularly in your mainloop.
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 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.
Header.
struct OSVR_DisplayConfigObject * OSVR_DisplayConfig
Opaque type of a display configuration.
Definition: DisplayC.h:57