https://github.com/kotlin-graphics/glm
jvm glm
https://github.com/kotlin-graphics/glm
android geometry-library glm graphics java jogl kotlin lwjgl math-library mathematics matrices vectors
Last synced: 17 days ago
JSON representation
jvm glm
- Host: GitHub
- URL: https://github.com/kotlin-graphics/glm
- Owner: kotlin-graphics
- Created: 2016-10-22T16:59:10.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-10-06T15:24:29.000Z (5 months ago)
- Last Synced: 2025-10-13T18:58:02.935Z (4 months ago)
- Topics: android, geometry-library, glm, graphics, java, jogl, kotlin, lwjgl, math-library, mathematics, matrices, vectors
- Language: Kotlin
- Homepage:
- Size: 3.16 MB
- Stars: 138
- Watchers: 10
- Forks: 22
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

[](https://github.com/kotlin-graphics/glm/actions?workflow=build)
[](https://github.com/kotlin-graphics/glm/blob/master/LICENSE)
[](https://jitpack.io/#kotlin-graphics/glm)

[]()
[](https://github.com/KotlinBy/awesome-kotlin)
This is the Kotlin port of [OpenGL Mathematics](http://glm.g-truc.net/) (*GLM*), written by [g-truc](https://github.com/Groovounet) ([repository](https://github.com/g-truc/glm)), a header only C++ mathematics library for graphics software based on the [OpenGL Shading Language (GLSL) specifications](https://www.opengl.org/registry/doc/GLSLangSpec.4.50.diff.pdf).
*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](https://www.opengl.org)* 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](https://github.com/elect86/kotlin-unsigned) for unsigned support and [kotlin-test](https://github.com/kotlintest/kotlintest) for testing.
For more information about *GLM*, please have a look at the [manual](https://github.com/kotlin-graphics/glm/wiki) and the original [API reference documentation](http://glm.g-truc.net/0.9.8/api/index.html).
The source code and the documentation are licensed under both the [Happy Bunny License (Modified MIT) or the MIT License](https://github.com/kotlin-graphics/glm/wiki/Manual#section0).
Don't hesitate to contribute to the project by submitting [issues](https://github.com/kotlin-graphics/glm/issues) or [pull requests](https://github.com/kotlin-graphics/glm/pulls) for bugs and features. Any feedback is welcome at [elect86@gmail.com](mailto://elect86@gmail.com).
```kotlin
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
}
```
### How to retrieve it:
#### mary
```kotlin
repositories {
maven("https://raw.githubusercontent.com/kotlin-graphics/mary/master")
// or with magik plugin
//github("kotlin-graphics/mary")
}
dependencies {
implementation("kotlin.graphics:glm:0.9.9.1-11")
}
```
#### maven central
```kotlin
dependencies {
implementation("io.github.kotlin-graphics:glm:0.9.9.1-12")
}
```
You can find more info by [mary](https://github.com/kotlin-graphics/mary)