Build DirectX 11 samples
[Last updated: 12/09/2021]
This page describes the steps to compile the DirectX 11 sample project included in the Live2D Cubism SDK for Native with Visual Studio in a Windows environment.
* The content of this article is based on the Cubism 4 SDK for Native R1.
The method and procedure may differ depending on the version of Cubism SDK.
What to download
The main body of the SDK. Download from the “Official Download Page”.
This is the development environment that will be used in this project. The language will be C++.
Used to generate project files.
DirectX 11 library.
It can be downloaded from the batch file included in the Cubism SDK sample.
For libraries such as CMake, DirectXTK, etc.,
check the instructions and version in 'README.md' located in “[root]Samples/D3D11” of the sample SDK zip.
Install the integrated development environment.
Set up the system so that C++ can compile.
Also, please use Visual Studio 2013 or later.
CMake work is used from a batch file, so the CMake path setting should be set so that it can be referenced by the user who will use it.
* Images may differ from the actual screen.
Run “setup_msvcxxxx.bat” in “/Samples/D3D11/thirdParty/scripts” where the Visual Studio to be used is listed and download DirectXTK.
When the batch processing is completed, a folder named “DirectXTK” is created in “/Samples/D3D11/thirdParty”.
Execution of CMake
CMake can also be used from the GUI, but this time we will use the batch file included in the sample.
The batch file can be found in “Samples/D3D11/Demo/proj.d3d11.cmake/scripts”.
This batch file selects from several combinations of settings.
• NMake or Project
NMake builds from the command prompt and generates an executable file; use a batch file starting with nmake_.
Use batch files starting with proj_ when editing code, etc. from Visual Studio.
• Version of Visual Studio
Please select the version of Visual Studio you have installed.
In our example, we will run “proj_msvc2015.bat” to select the project containing the Visual Studio 2015 solution file.
When executed, choices will be displayed as shown in the image below, so enter the corresponding number in single-byte numbers.
• Selecting an Architecture
Select x86(Win32) or x64(Win64).
Select as appropriate depending on the environment in which it is used.
• Module Selection for Cubism Core
Select the Cubism Core runtime library to be used.
Please refer to the official Microsoft documentation for the meanings of MD, MT, etc.
• Selection of project content
Select the contents of the project to be generated.
If you select Full Demo: A sample project will be generated that utilizes all the features of Cubism SDK for Native.
If you select Minimum Demo: A minimally configured project is generated that displays a model that repeats a single motion. The following features are used in this project.
- Load and display Cubism models
- Ability to loop a single motion
- Eye tracking by mouse dragging
If the input is successful, CMake generation will begin.
* If an error occurs after the generation starts, please check the version of CMake and the version of Visual Studio you are specifying.
When CMake generation is finished, open the solution file from the generated files.
In this example,execute
• use the multithread-specific and DLL-specific version of the run-time library (MD)
open the output file “Demo.sln” in “[root]/Samples/D3D9/Demo/proj.d3d11.cmake/build/proj_msvc2015_x64_md” in Visual Studio, and execute the build.
If the build is successful, let's run it through debugging.
If a large screen appears, you have succeeded.
* In the smallest sample, UI such as the background and the gear icon for switching models are not displayed.
To adjust the window size,
change the values of the 4th and 5th arguments of SetRect() used in LAppDelegate::Initialize() in “/Sample/D3D11/Demo/proj.d3d11.cmake/src/LAppDelegate.cpp”.
SetRect(&rect, 0, 0, RenderTargetWidth, RenderTargetHeight);
* Actual values for RenderTargetWidth and RenderTargetHeight are defined in “/Sample/D3D11/Demo/proj.d3d11.cmake/src/LAppDefine.cpp”.
Destination where the executable file will be output
This project created from CMake differs from a normal project in that
the output destination of the file will be under “bin” created in the same hierarchy as the project folder.
Specifically, when the project folder is “[root]/Samples/D3D11/Demo/proj.d3d11.cmake/build/proj_msvc2015_x64_md”
the executable file will be output to “[root]/Samples/D3D11/Demo/proj.d3d11.cmake/build/proj_msvc2015_x64_md/bin/[Configurations]/”.