36 #include <SDL_opengl.h> 
   41 static auto const WIDTH = 1920;
 
   42 static auto const HEIGHT = 1080;
 
   48 int main(
int argc, 
char *argv[]) {
 
   55     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
 
   56     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
 
   59     auto window = SDL::createWindow(
"OSVR", SDL_WINDOWPOS_UNDEFINED,
 
   60                                     SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT,
 
   61                                     SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
 
   63         std::cerr << 
"Could not create window: " << SDL_GetError() << std::endl;
 
   68     SDL::GLContext glctx(window.get());
 
   71     SDL_GL_SetSwapInterval(1);
 
   78         std::cerr << 
"\nCould not get display config (server probably not " 
   79                      "running or not behaving), exiting." 
   84     std::cout << 
"Waiting for the display to fully start up, including " 
   85                  "receiving initial pose update..." 
   90     std::cout << 
"OK, display startup status is good!" << std::endl;
 
   94 #ifndef __ANDROID__ // Don't want to pop up the on-screen keyboard 
   95     SDL::TextInput textinput;
 
  100         while (SDL_PollEvent(&e)) {
 
  107                 if (SDL_SCANCODE_ESCAPE == e.key.keysym.scancode) {
 
  113             if (e.type == SDL_QUIT) {
 
  125         SDL_GL_SwapWindow(window.get());
 
  145     osvrClientGetNumViewers(disp, &viewers);
 
  148     glClearColor(0, 0, 0, 1.0f);
 
  149     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
  155         osvrClientGetNumEyesForViewer(disp, viewer, &eyes);
 
  166             glMatrixMode(GL_MODELVIEW);
 
  168             glMultMatrixd(viewMat);
 
  173             osvrClientGetNumSurfacesForViewerEye(disp, viewer, eye, &surfaces);
 
  181                 osvrClientGetRelativeViewportForViewerEyeSurface(
 
  182                     disp, viewer, eye, surface, &left, &bottom, &width,
 
  185                 glViewport(static_cast<GLint>(left), static_cast<GLint>(bottom),
 
  186                            static_cast<GLsizei>(width),
 
  187                            static_cast<GLsizei>(height));
 
  195                     disp, viewer, eye, surface, zNear, zFar,
 
  199                 glMatrixMode(GL_PROJECTION);
 
  201                 glMultMatrixd(projMat);
 
  205                 glMatrixMode(GL_MODELVIEW);
 
void draw_cube(double radius)
Fixed-function pipeline OpenGL code to draw a cube. 
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...
uint32_t OSVR_SurfaceCount
The integer type specifying the number of surfaces seen by a viewer's eye. 
OSVR_ReturnCode osvrClientCheckDisplayStartup(OSVR_DisplayConfig disp)
Checks to see if a display is fully configured and ready, including having received its first pose up...
void renderScene()
A simple dummy "draw" function - note that drawing occurs in "room space" by default. (that is, in this example, the modelview matrix when this function is called is initialized such that it transforms from world space to view space) 
Header containing some helper code for using SDL2 in a C++11 environment. 
Matrix transforms column vectors (default) 
Column-major memory order (default) 
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 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_ReturnCode osvrClientGetDisplay(OSVR_ClientContext ctx, OSVR_DisplayConfig *disp)
Allocates a display configuration object populated with data from the OSVR system. 
void render(OSVR_DisplayConfig disp)
The "wrapper" for rendering to a device described by OSVR. 
Matrix takes vectors from a right-handed coordinate system (default) 
uint8_t OSVR_EyeCount
The integer type specifying the number of eyes (viewpoints) of a viewer. 
int32_t OSVR_ViewportDimension
The integer type used in specification of size or location of a viewport. 
Matrix maps the near and far planes to signed Z values (in the range [-1, 1]) (default) ...