MCPcopy Create free account
hub / github.com/OSVR/OSVR-Core / computeViewport

Function computeViewport

src/osvr/Client/DisplayConfig.cpp:41–76  ·  view source on GitHub ↗

@param eye 0 for left, 1 for right @todo handle swapeyes? - just for calls to this function

Source from the content-addressed store, hash-verified

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) {

Callers 1

createMethod · 0.85

Calls 3

getDisplayModeMethod · 0.80
getDisplayWidthMethod · 0.45
getDisplayHeightMethod · 0.45

Tested by

no test coverage detected