A Qt-based Live2d widget
QtLive2d is a Qt-based Live2d widget, it is modified from the official Live2d Sample. Unlike the official examples, QtLive2d uses QOpenGLWidget and QOpenGLFunctions provided by Qt instead of glfw and glew. This makes it easy to combine with any Qt Gui software.
Thanks @6ziv for your blogs and projects. They have helped me a lot on this project
- Easy to use
- Using OpenGL instead of WebGL
- Less resource consumption
- Support Live2d mouse events
- Support transparent background
- CrossPlatform
We provide a sample application called Sample to show you how to use it.
Running on Win10:
Running on Ubuntu (xcfe4):
│ QtLive2d.pro
│
└───src
├───Core
│
├───dll
│ libLive2DCubismCore.so
│
├───Framework
│ Framework.pro
│
├───lib
│
└───Sample
│ Sample.pro
│
├───QtLive2dWidget
│
└───Resources
Here is the basic structure for QtLive2d. To build the Sample, we just need to build the main project QtLive2d.pro
. It help us automatically finish the compile processing.
- Compile Framework
- Copy
Framework.lib
to the lib file. - Compile Sample.
Folder Core
are from CubismNativeSamples. All the library is pre-compiled.
- Live2DCubismCore.lib
- Framework.lib
- OpenGL32 (Only for Win32)
- User32 (Only for Win32)
- Glu32 (Only for Win32)
-
For Win32 Please use MSVC 2017 or 2019! and std C++ 17
-
To use QtLive2d in your program, you need to add Floder QtLive2d, Framework, thirdParty and Core into you project.
-
Add includepath and dependpath in
pro
fileINCLUDEPATH += $$PWD/Core/include INCLUDEPATH += $$PWD/Framework/src INCLUDEPATH += $$PWD/thirdParty/stb
-
Add Framework.lib into
pro
file.CONFIG += debug_and_release CONFIG(debug, debug|release){ message(Debug build) LIBS += -L$$PWD/lib/ -lFrameworkd } CONFIG(release, debug|release){ message(Release build) LIBS += -L$$PWD/lib/ -lFramework }
-
Add Live2DCubismCore lib into
pro
file.CONFIG += debug_and_release CONFIG(debug, debug|release){ message(Debug build) LIBS += -L$$PWD/lib/ -lLive2DCubismCore_MDd } CONFIG(release, debug|release){ message(Release build) LIBS += -L$$PWD/lib/ -lLive2DCubismCore_MD }
-
For Win32, Please the following as well
LIBS += -lOpenGL32 LIBS += -lUser32 LIBS += -lGlu32
-
QLive2dWidget is a subclass of QOpenGLWidget, which can be used directly or be promoted in the Qt Designer.
-
To use QOpenGLWidget in Qt, you need the following modules
QT += core gui opengl widgets
-
To use QOpenGLWidget in Qt 6, you need add extra module
openglwidgets
greaterThan(QT_MAJOR_VERSION, 5) {QT += openglwidgets}
-
Define you model path in
LAppDefine.cpp
. -
Enjoy it!
- Cross Platform
Copyright (C) 2022 duanxianpi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.