Skip to content
This repository was archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
Add minimal run as service option to sample
Browse files Browse the repository at this point in the history
New flag service causes the application to run as a "service" main
overlay application.
  • Loading branch information
jzulauf-lunarg committed Aug 10, 2021
1 parent ec29274 commit 3cd5722
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions overlay-sample/overlay_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ constexpr int gFudgeMinAlpha = 128;

int gLayerPlacement = 0;
float gLayerRotationalOffset = 0.f;
bool gEmptyFrame = false;

// OpenXR will give us a LUID. This function will walk adapters to find
// the adapter matching that LUID, then create an ID3D11Device* from it so
Expand Down Expand Up @@ -420,8 +421,8 @@ void OpenXRProgram::CreateSession(ID3D11Device* d3d11Device, bool requestOverlay
d3dBinding.device = d3d11Device;
chain = &d3dBinding;

XrSessionCreateInfoOverlayEXTX sessionCreateInfoOverlay{ XR_TYPE_SESSION_CREATE_INFO_OVERLAY_EXTX };
if(requestOverlaySession) {
XrSessionCreateInfoOverlayEXTX sessionCreateInfoOverlay{ XR_TYPE_SESSION_CREATE_INFO_OVERLAY_EXTX };
sessionCreateInfoOverlay.next = chain;
sessionCreateInfoOverlay.createFlags = 0;
sessionCreateInfoOverlay.sessionLayersPlacement = gLayerPlacement;
Expand Down Expand Up @@ -1037,6 +1038,7 @@ void usage(const char *programName)
std::cerr << "usage: overlay-sample [options]\n";
std::cerr << "options:\n";
std::cerr << " --main Create a main session, not an overlay session\n";
std::cerr << " --service Create a main session with no content\n";
std::cerr << " --placement N Set overlay layer level to N [default 0]\n";
std::cerr << " --rotational-offset N Angle in radians to offset the layer clockwise about\n";
std::cerr << " the stage space world up vector [default 0]\n";
Expand All @@ -1058,6 +1060,10 @@ int main( int argc, char **argv )
} else if (strcmp(argv[arg], "--main") == 0) {
createOverlaySession = false;
arg += 1;
} else if (strcmp(argv[arg], "--service") == 0) {
createOverlaySession = false;
gEmptyFrame = true;
arg += 1;

} else if ((strcmp(argv[arg], "--rotational-offset") == 0) || (strcmp(argv[arg], "--rot") == 0)) {
if (arg + 1 >= argc) {
Expand Down Expand Up @@ -1279,7 +1285,7 @@ int main( int argc, char **argv )

program.BeginFrame();

if(shouldRender) {
if(shouldRender && !gEmptyFrame) {


for(int eye = 0; eye < 2; eye++) {
Expand Down

0 comments on commit 3cd5722

Please sign in to comment.