Logo

dev-resources.site

for different kinds of informations.

Unofficial Live2D Cubism SDK for Golang

Published at
12/25/2024
Categories
live2d
go
ebitengine
gamedev
Author
Chan Aethiopicus
Categories
4 categories in total
live2d
open
go
open
ebitengine
open
gamedev
open
Unofficial Live2D Cubism SDK for Golang

Introduction

Q. What is Live2D?
A. See Official Site.

Main Topic

If you want to use Live2D, you’ll need the Cubism Framework and Cubism Core. The former has official open-source releases for various environments and programming languages, but the latter is closed and has no alternatives. (For detailed configuration, please refer to the Cubism Core API Reference.)

Now, looking at the Cubism Framework, you can find available versions for Unity, Native, Web and Java.

But I’m really into Golang and Ebitengine!

Deliverables

In the end, I wrote my own code that replicates the Cubism Framework’s functionality and turned it into a library: github.com/aethiopicuschan/cubism-go.

The library also includes a reference renderer for Ebitengine, so if you’re using Ebitengine for development, you can easily incorporate it into your project.

ScreenShot of example project

About Cubism Core

Cubism Core is provided as a dynamic library (such as a .dylib).

Let's consider how to use it from Golang. We could use cgo, of course, but this time I employed a library called purego.

You'll need to grapple with a storm of unsafe and uintptr, but it's still much better than using cgo.

In this case, there's an implementation related to the following. Feel free to take a look and experience the storm for yourself!

core.go

I did say you'd have to battle a storm, but purego is a fantastic library, so I encourage everyone to try it out.

That's all. Thank you for reading.

Featured ones: