glm - jvm glm - Kotlin Resources


Build Status license Release Size Github All Releases Awesome Kotlin Badge

This is the Kotlin port of OpenGL Mathematics (GLM), written by g-truc (repository), a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications.

GLM provides classes and functions designed and implemented with the same naming conventions and functionality than GLSL so that anyone who knows GLSL, can use GLM as well in Kotlin and Java.

This project isn’t limited to GLSL features. An extension system, based on the GLSL extension conventions, provides extended capabilities: matrix transformations, quaternions, data packing, random numbers, noise, etc…

This library works perfectly with OpenGL but it also ensures interoperability with other third party libraries and SDK. It is a good candidate for software rendering (raytracing / rasterisation), image processing, physic simulations and any development context that requires a simple and convenient mathematics library.

GLM is written entirely in Kotlin, but can be also used from Java. It is a platform independent library with no dependences other than kotlin-unsigned for unsigned support and kotlin-test for testing.

For more information about GLM, please have a look at the manual and the original API reference documentation. The source code and the documentation are licensed under both the Happy Bunny License (Modified MIT) or the MIT License.

Don’t hesitate to contribute to the project by submitting issues or pull requests for bugs and features. Any feedback is welcome at

import glm_.vec2.Vec2
import glm_.vec3.Vec3
import glm_.mat4x4.Mat4
import glm_.glm

fun camera(translate: Float, rotate: Vec2): Mat4 {

    val projection = glm.perspective(glm.PIf * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f)
    var view = glm.translate(Mat4(1.0f), Vec3(0.0f, 0.0f, -translate))
    view = glm.rotate(view, rotate.y, Vec3(-1.0f, 0.0f, 0.0f))
    view = glm.rotate(view, rotate.x, Vec3(0.0f, 1.0f, 0.0f))
    val model = glm.scale(Mat4(1.0f), Vec3(0.5f))
    return projection * view * model


  • Add it in your root build.gradle at the end of repositories:

      allprojects {
          repositories {
                  maven { url '' }
  • Add the dependency

      dependencies {
          implementation 'com.github.kotlin-graphics.glm:glm:<version>'
  • The kotlin-test matchers can be used by adding the following dependency

      dependencies {
          implementation 'com.github.kotlin-graphics.glm:glm-test:<version>'

Gradle, Maven, Sbt, Leiningen

Ps: we use bleeding edge lwjgl, which is available under the sonatype repository, if you are experiencing problems, just add maven { url '' } to your build.gradle

compile "com.github.kotlin-graphics:glm:v1.0.1"

Related Libraries


UNofficial Opengl SDK

Last updated 3 mins ago



Last updated 3 mins ago



Last updated 3 mins ago


jvm glm

Last updated 3 mins ago


jvm gli

Last updated 3 mins ago