Member-only story
3D Graphics in Kotlin Multiplatform Without any Dependencies
Let's Draw Some Teapots and More

Every modern platform has a variety of graphics libraries. However, if we start making a multiplatform project in Kotlin, we will have several challenges:
- Jetpack Compose has an advanced 2D graphics API with shapes, masks, primitives, gradients, animations, etc, but obviously, it does not “natively” support 3D at all.
- OpenGL ES is a standard graphics library for Android that supports 3D; however, on Apple devices it has been deprecated since iOS 12.
- OpenGL itself is a complex framework. It requires a lot of boilerplate code that combines many pieces like shaders, resource IDs, vectors, and textures — a simple drawing of a 3D cube can easily take 2–3 pages of code. If we want to support both iOS and Android, we will need not only OpenGL but also Metal (Apple graphics framework) as well.
However, not every app requires “heavy” graphics with millions of triangles. For educational or even scientific apps simple wireframe graphics can be sufficient. This can be done in pure Kotlin without any dependencies.
In this article, I will show how to make a simple “3D Engine” in Kotlin, and it will be 100% multiplatform compatible. As a bonus, I will show how to load STL…