Skip to content
Branch: master
Find file History

Latest commit

oldnewthing Windows 10 Version 1903 - March 2020 Update
* 360VideoPlayback: Align configurations, reset shader between stages #791 #942
* Clipboard: Add history and roaming scenarios, improve delay-rendering, clipboard change reporting, error-handling.
* CustomSerialDeviceAccess: Fix RequestToSendXOnXOff #1085
* Holographic samples support HoloLens 2 device and emulator
* HolographicFaceTracking: Fix comment about NV12 #834
* HolographicVoiceInput: Fix release build
* PlayReady: Don't create container twice #1159
* RadioManager: Clarify require capabilities #1165
* SpeechRecognitionAndSynthesis: Clarify which scenarios require internet access #725, Update permission links #1002
* UserActivity: Fix protocol navigation #1176
* XamlMasterDetail: Fix navigation problems #344 #345
* SharedContent: Default.rd.xml fixes #950
* Miscellaneous typos: AdvancedCasting #1006, AudioCreation #1006, BluetoothAdvertisement #898, BluetoothRfcommChat #1139, Json #404, Nfc #1039, XamlBind #1169 #1182
* Add missing Line Display sample to TOC #704
* All C++ samples now build in both VS2017 and VS2019.
* All C++/WinRT samples upgraded to C++/WinRT 2.0 #1179
* New: Clipboard (C++/WinRT), JapanesePhoneticAnalysis (C++/WinRT)
* Archived: Advertising, CallerId, Clipboard (C++/CX and VB), CommunicationBlockAndFilter, PhoneCall
Latest commit 3ac8bb2 Mar 26, 2020


Type Name Latest commit message Commit time
Failed to load latest commit information.
cpp Windows 10 Version 1903 - March 2020 Update Mar 26, 2020 Onboarding samples to Dec 19, 2019

page_type languages products urlFragment extendedZipContent description
path target
path target
Shows how to instantiate and render a gradient mesh in Direct2D.

Direct2D gradient mesh sample

Shows how to instantiate and render a gradient mesh in Direct2D. This samples uses the helper method provided by Direct2D to create a mesh consisting of two tensor patches that share a side.

Note: This sample is part of a large collection of UWP feature samples. You can download this sample as a standalone ZIP file from, or you can download the entire collection as a single ZIP file, but be sure to unzip everything to access shared dependencies. For more info on working with the ZIP file, the samples collection, and GitHub, see Get the UWP samples from GitHub. For more samples, see the Samples portal on the Windows Dev Center.

Some important APIs used in this sample are:

Sample project files

The sample's project files fall into the following categories.

Sample-specific files

The following files exercise the gradient mesh APIs and form the main educational content of the sample:

  • App.cpp/.h
  • D2DGradientMeshMain.cpp/.h
  • D2DGradientMeshRenderer.cpp/.h

D2DGradientMeshRenderer contains most of the gradient mesh-specific code.

DirectX SDK sample common files

The following files provide common functionality needed by DirectX SDK samples:

  • DeviceResources.cpp/.h: Manages creation and lifetime of the core Direct3D and Direct2D device-dependent resources. Handles cases such as device lost and window size and orientation changes.
  • DirectXHelper.h: Common inline helper functions, including ThrowIfFailed which converts HRESULT-based APIs into an exception model.
  • SampleOverlay.cpp/.h: Renders the Windows SDK overlay badge on top of sample content.

All DX SDK samples and the Visual Studio template DX project contain a version of these files. These common files demonstrate important best practices for DX UWP apps, and you are encouraged to use them in your own projects.

C++ UWP common files

Variants of the following files are found in every UWP app written in C++:

  • Package.appxmanifest
  • pch.cpp/.h
  • D2DGradientMesh.vcxproj
  • D2DGradientMesh.vcxproj.filters
  • D2DGradientMesh.sln

Related topics


System requirements

Client: Windows 10

Server: Windows Server 2016 Technical Preview

Phone: Windows 10

Build the sample

  1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
  2. Start Microsoft Visual Studio and select File > Open > Project/Solution.
  3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio Solution (.sln) file.
  4. Press Ctrl+Shift+B, or select Build > Build Solution.

Run the sample

The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.

Deploying the sample

  • Select Build > Deploy Solution.

Deploying and running the sample

  • To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging.
You can’t perform that action at this time.