Skip to content

Commit ba60de3

Browse files
committed
awesome kotlin
1 parent 8ec52ae commit ba60de3

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package main.framework
2+
3+
import com.jogamp.newt.opengl.GLWindow
4+
import com.jogamp.opengl.GL3
5+
import com.jogamp.opengl.GLAutoDrawable
6+
7+
/**
8+
* Created by GBarbieri on 22.03.2017.
9+
*/
10+
11+
inline infix fun GLWindow.gl3(crossinline inject: GL3.() -> Unit) {
12+
invoke(false) { glAutoDrawable ->
13+
glAutoDrawable.gl.gL3.inject()
14+
false
15+
}
16+
}

src/main/kotlin/main/tut05/depthClamping.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import glm.vec._3.Vec3
1313
import glm.vec._4.Vec4
1414
import main.framework.Framework
1515
import main.framework.Semantic
16+
import main.framework.gl3
1617
import uno.buffer.*
1718
import uno.glsl.programOf
1819

@@ -157,17 +158,12 @@ class DepthClamping_ : Framework("Tutorial 05 - Depth Clamping") {
157158

158159
when (keyEvent.keyCode) {
159160
KeyEvent.VK_ESCAPE -> quit()
160-
KeyEvent.VK_SPACE -> {
161-
window.invoke(false) { glAutoDrawable ->
162-
with(glAutoDrawable.gl.gL3) {
163-
if (depthClampingActive)
164-
glDisable(GL_DEPTH_CLAMP)
165-
else
166-
glEnable(GL_DEPTH_CLAMP)
167-
}
168-
depthClampingActive = !depthClampingActive
169-
false
170-
}
161+
KeyEvent.VK_SPACE -> window.gl3 {
162+
if (depthClampingActive)
163+
glDisable(GL_DEPTH_CLAMP)
164+
else
165+
glEnable(GL_DEPTH_CLAMP)
166+
depthClampingActive = !depthClampingActive
171167
}
172168
}
173169
}

0 commit comments

Comments
 (0)