| 46 | void renderScene(); |
| 47 | |
| 48 | int main(int argc, char *argv[]) { |
| 49 | namespace SDL = osvr::SDL2; |
| 50 | |
| 51 | // Open SDL |
| 52 | SDL::Lib lib; |
| 53 | |
| 54 | // Use OpenGL 2.1 |
| 55 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); |
| 56 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); |
| 57 | |
| 58 | // Create a window |
| 59 | auto window = SDL::createWindow("OSVR", SDL_WINDOWPOS_UNDEFINED, |
| 60 | SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, |
| 61 | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); |
| 62 | if (!window) { |
| 63 | std::cerr << "Could not create window: " << SDL_GetError() << std::endl; |
| 64 | return -1; |
| 65 | } |
| 66 | |
| 67 | // Create an OpenGL context and make it current. |
| 68 | SDL::GLContext glctx(window.get()); |
| 69 | |
| 70 | // Turn on V-SYNC |
| 71 | SDL_GL_SetSwapInterval(1); |
| 72 | |
| 73 | // Start OSVR and get OSVR display config |
| 74 | osvr::clientkit::ClientContext ctx("com.osvr.example.SDLOpenGL"); |
| 75 | OSVR_DisplayConfig display; |
| 76 | auto ret = osvrClientGetDisplay(ctx.get(), &display); |
| 77 | if (ret != OSVR_RETURN_SUCCESS) { |
| 78 | std::cerr << "\nCould not get display config (server probably not " |
| 79 | "running or not behaving), exiting." |
| 80 | << std::endl; |
| 81 | return -1; |
| 82 | } |
| 83 | |
| 84 | std::cout << "Waiting for the display to fully start up, including " |
| 85 | "receiving initial pose update..." |
| 86 | << std::endl; |
| 87 | while (osvrClientCheckDisplayStartup(display) != OSVR_RETURN_SUCCESS) { |
| 88 | ctx.update(); |
| 89 | } |
| 90 | std::cout << "OK, display startup status is good!" << std::endl; |
| 91 | |
| 92 | // Event handler |
| 93 | SDL_Event e; |
| 94 | #ifndef __ANDROID__ // Don't want to pop up the on-screen keyboard |
| 95 | SDL::TextInput textinput; |
| 96 | #endif |
| 97 | bool quit = false; |
| 98 | while (!quit) { |
| 99 | // Handle all queued events |
| 100 | while (SDL_PollEvent(&e)) { |
| 101 | switch (e.type) { |
| 102 | case SDL_QUIT: |
| 103 | // Handle some system-wide quit event |
| 104 | quit = true; |
| 105 | break; |
nothing calls this directly
no test coverage detected