Building OpenGL Samples

[Last updated: 12/09/2021]

This page describes the steps to compile the OpenGL sample project included in Live2D Cubism SDK for Native with Visual Studio in 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 you need

Live2D Cubism SDK for Native

The main body of the SDK. Download from the “official download” page.

Visual Studio

This is the development environment that will be used in this project. The language will be C++.
Also, please use Visual Studio 2013 or later.

CMake

Used to generate project files.

GLFW

It is an auxiliary library for OpenGL, with input and window management capabilities.
It can be downloaded from the batch file included in the Cubism SDK sample.

GLEW

It is an extension library for OpenGL, which makes it easy to call OpenGL extensions.
It can be downloaded from the batch file included in the Cubism SDK sample.

 

Within this article, GLFW and GLEW are downloaded from the batch file included in the Cubism SDK sample, so there is no need to download them in advance.

Also, for tools and libraries such as CMake, GLFW, GLEW, etc.,
check the instructions and version in 'README.md' located in “[root]Samples/OpenGL” in the sample SDK zip.

 

 

Installation process

Visual Studio

Install the integrated development environment.
Set up the system so that C++ can compile.

 

CMake

Install CMake.
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. 

 

Development of GLFW and GLEW

For GLFW and GLEW deployment, please refer to the instructions in 'README.md' in “Samples/OpenGL”.
On Windows, run “setup.bat” in “Samples/OpenGL/thirdParty” to download GLFW and GLEW.

After batch deployment, the folder structure will look like the following.

* If you downloaded GLFW and GLEW manually, you need to extract them into the “Samples/OpenGL/thirdParty” folder.

 

Execution of CMake

CMake can also be used from the GUI, but this time we will use the batch file included in the sample.
On Windows, the batch file can be found in “Samples/OpenGL/Demo/proj.win.cmake/scripts”.
The batch file for Windows is a combination of several settings to choose from.

• 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 this example, we will run “proj_msvc2015.bat” to select the project containing the Visual Stadio 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
  • Physics
  • Breath
  • Pose

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.

 

Build

When CMake generation is finished, open the solution file from the generated files.
In this example,execute
• proj_msvc2015.bat

and select
• x64(Win64)
• use the multithread-specific and DLL-specific version of the run-time library (MD)
• Full Demo

and then
open the output “Demo.sln” in “[root]/Samples/OpenGL/Demo/proj.win.cmake/build/proj_msvc2015_x64_md” in Visual Studio and execute the build.

 

Execution

If the build is successful, let's run it through debugging.

If you get a big screen and log output from the command prompt, you've 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, please refer to “/Sample/OpenGL/Demo/proj.win.cmake/src/LAppDelegate.cpp”.
Change the values of the first and second arguments of glfwCreateWindow() used in LAppDelegate::Initialize().

 

* Actual values for RenderTargetWidth and RenderTargetHeight are defined in “/Sample/OpenGL/Demo/proj.win.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 in the same hierarchy as the project folder.

Specifically, when the project folder is “[root]/Samples/OpenGL/Demo/proj.win.cmake/build/proj_msvc2015_x64_md
the executable file is output to the same location as the project folder.

Please note that “[root]/Samples/OpenGL/Demo/proj.win.cmake/build/proj_msvc2015_x64_md/Release” etc. will be generated at build time, but no files will be output here.

© 2010 - 2022 Live2D Inc.