This sample demonstrates how to add a stereoscopic 3-D effect to C++ apps by using Direct3D. It also demonstrates how to respond to system stereo changes in Direct3D.
Note The stereoscopic 3-D effect requires a display that supports stereo 3-D.
You can use the code in this sample to add stereoscopic 3-D effects to your Direct3D 11.1 app. It shows the best practices and usage of stereo 3-D support APIs that Direct3D 11.1 supports for apps.
The process demonstrated in this sample is as follows:
- Call IDXGIFactory2::IsWindowedStereoEnabled to verify that the computer on which the app runs supports stereo 3-D.
- Use the following code to register for
StereoEnabledChanged notifications whenever the stereo 3D support on the computer changes. The
DisplayPropertiesEventHandler delegate handles these notifications. These are Windows Runtime APIs from the
Windows.Graphics.Display namespace.
DisplayProperties::StereoEnabledChanged += ref new DisplayPropertiesEventHandler(this, &View::OnStereoEnableChanged);
- Create the device with the feature level set at least at the minimum requirement for stereo 3-D support, that is, a Direct3D 11.1 device with feature level 10.0 or higher.
- Create stereo 3-D supported swap chains on which to render stereo content for left and right eye views.
- Create and set stereo projection matrices for rendering stereo content.
- Set up rendering state and pipeline for rendering stereo content; that is, left and right render-target views.
- Render Direct2D content on the stereo 3-D swap chain. That is, obtain the back buffer of a swap chain as a DXGI resource and call the IDXGIResource1::CreateSubresourceSurface API to obtain the left and right views.
For more info about the concepts and APIs demonstrated in this sample, see these topics:
- Create an app using DirectX
- Direct3D 11 graphics
- Direct2D graphics
- DXGI reference
- DirectX HLSL
- UnderstandingDirectX game development
- Developing games
This sample is written in C++ and requires some experience with graphics programming and DirectX.
Requirements
In addition to the minimum supported operating systems being Windows 8.1 and Windows Server 2012 R2, a WDDM 1.2 display driver must be installed on the computer, and the graphics hardware must support feature level 10 or higher.
To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.
To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.
Related topics
Operating system requirements
Client | |
---|---|
Server |
Build the sample
- Start Visual Studio 2019 and select File > Open > Project/Solution.
- Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio 2019 Solution (.sln) file.
- Press F7 or use Build > Build Solution to build the sample.
Run the sample
To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
You can adjust the stereoscopic visual effect by pressing the 'up' or 'down' arrow keys.