@param eye 0 for left, 1 for right @todo handle swapeyes? - just for calls to this function
| 39 | /// @param eye 0 for left, 1 for right |
| 40 | /// @todo handle swapeyes? - just for calls to this function |
| 41 | inline static Viewport |
| 42 | computeViewport(uint8_t eye, |
| 43 | display_schema_1::DisplayDescriptor &descriptor) { |
| 44 | Viewport viewport; |
| 45 | // Set up the viewport based on the display resolution and the |
| 46 | // display configuration. |
| 47 | switch (descriptor.getDisplayMode()) { |
| 48 | case display_schema_1::DisplayDescriptor::FULL_SCREEN: |
| 49 | viewport.bottom = viewport.left = 0; |
| 50 | viewport.width = descriptor.getDisplayWidth(); |
| 51 | viewport.height = descriptor.getDisplayHeight(); |
| 52 | break; |
| 53 | case display_schema_1::DisplayDescriptor::HORIZONTAL_SIDE_BY_SIDE: |
| 54 | viewport.bottom = 0; |
| 55 | viewport.height = descriptor.getDisplayHeight(); |
| 56 | viewport.width = descriptor.getDisplayWidth() / 2; |
| 57 | // Eye 0 starts at the left, eye 1 starts in the middle. |
| 58 | viewport.left = eye * viewport.width; |
| 59 | break; |
| 60 | case display_schema_1::DisplayDescriptor::VERTICAL_SIDE_BY_SIDE: |
| 61 | viewport.left = 0; |
| 62 | viewport.width = descriptor.getDisplayWidth(); |
| 63 | viewport.height = descriptor.getDisplayHeight() / 2; |
| 64 | // Eye 0 in the top half, eye 1 at the bottom. |
| 65 | if (eye == 0) { |
| 66 | viewport.bottom = viewport.height; |
| 67 | } else { |
| 68 | viewport.bottom = 0; |
| 69 | } |
| 70 | break; |
| 71 | default: |
| 72 | throw std::logic_error("Unrecognized enum value for display mode"); |
| 73 | } |
| 74 | |
| 75 | return viewport; |
| 76 | } |
| 77 | |
| 78 | inline static util::Rectd |
| 79 | computeRect(display_schema_1::DisplayDescriptor &descriptor) { |
no test coverage detected