Skip to content

Commit f429f15

Browse files
committed
removed jogl dependendy
1 parent fc67ccf commit f429f15

File tree

20 files changed

+1418
-1520
lines changed

20 files changed

+1418
-1520
lines changed

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ dependencies {
3535

3636
testCompile 'io.kotlintest:kotlintest:2.0.7'
3737

38-
compile 'com.github.kotlin-graphics:gln:9e7578300874893436d0aabad5ffed9399fc44b4'
38+
compile 'com.github.kotlin-graphics:gln:1f1ed15e96a8cfc9489047cb98acf80352312716'
3939

4040
testCompile 'io.kotlintest:kotlintest-runner-junit5:3.0.6'
4141

4242
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
4343

4444

45-
ext.jogl = "2.3.2"
46-
compile "org.jogamp.gluegen:gluegen-rt:$jogl"
47-
compile "org.jogamp.jogl:jogl-all:$jogl"
45+
// ext.jogl = "2.3.2"
46+
// compile "org.jogamp.gluegen:gluegen-rt:$jogl"
47+
// compile "org.jogamp.jogl:jogl-all:$jogl"
4848

4949

5050
switch (OperatingSystem.current()) {

src/main/kotlin/uno/buffer/buffer.kt

Lines changed: 45 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package uno.buffer
22

33

44
import glm_.BYTES
5-
import glm_.set
5+
import glm_.buffer.*
66
import org.lwjgl.PointerBuffer
77
import org.lwjgl.system.MemoryUtil
88
import uno.kotlin.Quadruple
@@ -13,15 +13,6 @@ import java.nio.*
1313
* Created by elect on 05/03/17.
1414
*/
1515

16-
fun floatBufferBig(capacity: Int): FloatBuffer = MemoryUtil.memCallocFloat(capacity)
17-
fun doubleBufferBig(capacity: Int): DoubleBuffer = MemoryUtil.memCallocDouble(capacity)
18-
19-
fun bufferBig(capacity: Int): ByteBuffer = MemoryUtil.memCalloc(capacity)
20-
fun shortBufferBig(capacity: Int): ShortBuffer = MemoryUtil.memCallocShort(capacity)
21-
fun intBufferBig(capacity: Int): IntBuffer = MemoryUtil.memCallocInt(capacity)
22-
fun longBufferBig(capacity: Int): LongBuffer = MemoryUtil.memCallocLong(capacity)
23-
24-
fun charBufferBig(capacity: Int): CharBuffer = TODO()
2516

2617
fun pointerBufferBig(capacity: Int): PointerBuffer = MemoryUtil.memCallocPointer(capacity)
2718
fun pointerBufferBig(capacity: IntBuffer): PointerBuffer = MemoryUtil.memCallocPointer(capacity[0])
@@ -68,60 +59,51 @@ fun doubleBuffersBig(sizeA: Int, sizeB: Int, sizeC: Int) = Triple(doubleBufferBi
6859
fun doubleBuffersBig(sizeA: Int, sizeB: Int, sizeC: Int, sizeD: Int) = Quadruple(doubleBufferBig(sizeA), doubleBufferBig(sizeB), doubleBufferBig(sizeC), doubleBufferBig(sizeD))
6960
fun doubleBuffersBig(sizeA: Int, sizeB: Int, sizeC: Int, sizeD: Int, sizeE: Int) = Quintuple(doubleBufferBig(sizeA), doubleBufferBig(sizeB), doubleBufferBig(sizeC), doubleBufferBig(sizeD), doubleBufferBig(sizeE))
7061

71-
72-
fun ByteBuffer.destroy() = MemoryUtil.memFree(this) // TODO rename?
73-
fun ShortBuffer.destroy() = MemoryUtil.memFree(this)
74-
fun IntBuffer.destroy() = MemoryUtil.memFree(this)
75-
fun LongBuffer.destroy() = MemoryUtil.memFree(this)
76-
fun FloatBuffer.destroy() = MemoryUtil.memFree(this)
77-
fun DoubleBuffer.destroy() = MemoryUtil.memFree(this)
78-
fun CharBuffer.destroy() = MemoryUtil.memFree(this)
79-
fun PointerBuffer.destroy() = MemoryUtil.memFree(this)
80-
81-
fun destroyBuf(vararg buffers: Buffer) {
62+
fun free(vararg buffers: Buffer) {
8263
for (i in 0 until buffers.size)
8364
MemoryUtil.memFree(buffers[i])
8465
}
8566

86-
fun <R> ByteBuffer.use(block: (ByteBuffer) -> R) = block(this).also { destroy() }
87-
fun <R> ShortBuffer.use(block: (ShortBuffer) -> R) = block(this).also { destroy() }
88-
fun <R> IntBuffer.use(block: (IntBuffer) -> R) = block(this).also { destroy() }
89-
fun <R> LongBuffer.use(block: (LongBuffer) -> R) = block(this).also { destroy() }
90-
fun <R> FloatBuffer.use(block: (FloatBuffer) -> R) = block(this).also { destroy() }
91-
fun <R> DoubleBuffer.use(block: (DoubleBuffer) -> R) = block(this).also { destroy() }
92-
fun <R> CharBuffer.use(block: (CharBuffer) -> R) = block(this).also { destroy() }
93-
fun <R> PointerBuffer.use(block: (PointerBuffer) -> R) = block(this).also { destroy() }
94-
95-
@Suppress("UNCHECKED_CAST")
96-
fun withBuffer(list: List<*>, block: ByteBuffer.() -> Unit) {
97-
when (list.elementAt(0)) {
98-
is Byte -> bufferBig(list.size).apply {
99-
val l = list as List<Byte>
100-
for (i in l.indices) set(i, l[i])
101-
}
102-
is Short -> bufferBig(list.size * Short.BYTES).apply {
103-
val l = list as List<Short>
104-
for (i in l.indices) putShort(i * Short.BYTES, l[i])
105-
}
106-
is Int -> bufferBig(list.size * Int.BYTES).apply {
107-
val l = list as List<Int>
108-
for (i in l.indices) putInt(i * Int.BYTES, l[i])
109-
}
110-
is Long -> bufferBig(list.size * Long.BYTES).apply {
111-
val l = list as List<Long>
112-
for (i in l.indices) putLong(i * Long.BYTES, l[i])
113-
}
114-
is Float -> bufferBig(list.size * Float.BYTES).apply {
115-
val l = list as List<Float>
116-
for (i in l.indices) putFloat(i * Float.BYTES, l[i])
117-
}
118-
is Double -> bufferBig(list.size * Double.BYTES).apply {
119-
val l = list as List<Double>
120-
for (i in l.indices) putDouble(i * Double.BYTES, l[i])
121-
}
122-
else -> throw Error("unsupported type")
123-
}.run {
124-
block()
125-
destroy()
126-
}
127-
}
67+
fun <R> ByteBuffer.use(block: (ByteBuffer) -> R) = block(this).also { free() }
68+
fun <R> ShortBuffer.use(block: (ShortBuffer) -> R) = block(this).also { free() }
69+
fun <R> IntBuffer.use(block: (IntBuffer) -> R) = block(this).also { free() }
70+
fun <R> LongBuffer.use(block: (LongBuffer) -> R) = block(this).also { free() }
71+
fun <R> FloatBuffer.use(block: (FloatBuffer) -> R) = block(this).also { free() }
72+
fun <R> DoubleBuffer.use(block: (DoubleBuffer) -> R) = block(this).also { free() }
73+
fun <R> CharBuffer.use(block: (CharBuffer) -> R) = block(this).also { free() }
74+
fun <R> PointerBuffer.use(block: (PointerBuffer) -> R) = block(this).also { free() }
75+
//
76+
//@Suppress("UNCHECKED_CAST")
77+
//fun withBuffer(list: List<*>, block: ByteBuffer.() -> Unit) {
78+
// when (list.elementAt(0)) {
79+
// is Byte -> bufferBig(list.size).apply {
80+
// val l = list as List<Byte>
81+
// for (i in l.indices)
82+
// put(i, l[i])
83+
// }
84+
// is Short -> bufferBig(list.size * Short.BYTES).apply {
85+
// val l = list as List<Short>
86+
// for (i in l.indices) putShort(i * Short.BYTES, l[i])
87+
// }
88+
// is Int -> bufferBig(list.size * Int.BYTES).apply {
89+
// val l = list as List<Int>
90+
// for (i in l.indices) putInt(i * Int.BYTES, l[i])
91+
// }
92+
// is Long -> bufferBig(list.size * Long.BYTES).apply {
93+
// val l = list as List<Long>
94+
// for (i in l.indices) putLong(i * Long.BYTES, l[i])
95+
// }
96+
// is Float -> bufferBig(list.size * Float.BYTES).apply {
97+
// val l = list as List<Float>
98+
// for (i in l.indices) putFloat(i * Float.BYTES, l[i])
99+
// }
100+
// is Double -> bufferBig(list.size * Double.BYTES).apply {
101+
// val l = list as List<Double>
102+
// for (i in l.indices) putDouble(i * Double.BYTES, l[i])
103+
// }
104+
// else -> throw Error("unsupported type")
105+
// }.run {
106+
// block()
107+
// free()
108+
// }
109+
//}

src/main/kotlin/uno/buffer/extensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import glm_.size
55
import org.lwjgl.system.MemoryUtil
66
import java.nio.*
77

8-
// TODO -> _buffers
8+
99
fun FloatArray.toFloatBuffer(): FloatBuffer {
1010
val res = MemoryUtil.memAllocFloat(size)
1111
for (i in 0 until size) res.put(i, this[i])

src/main/kotlin/uno/buffer/of.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package uno.buffer
22

33
import glm_.BYTES
4+
import glm_.buffer.bufferBig
5+
import glm_.buffer.floatBufferBig
6+
import glm_.buffer.intBufferBig
47
import glm_.i
58
import glm_.set
69
import glm_.vec2.Vec2
@@ -15,6 +18,7 @@ import gln.glf.glf
1518
import org.lwjgl.system.MemoryUtil
1619
import java.nio.*
1720

21+
1822
fun floatBufferOf(vararg floats: Float): FloatBuffer {
1923
val res = MemoryUtil.memAllocFloat(floats.size)
2024
for (i in 0 until floats.size) res.put(i, floats[i])
@@ -253,7 +257,7 @@ fun intBufferOf(vertices: Collection<*>): IntBuffer {
253257

254258
fun bufferOf(charSequence: CharSequence): ByteBuffer {
255259
val buffer = bufferBig(charSequence.length)
256-
for(i in charSequence.indices)
260+
for (i in charSequence.indices)
257261
buffer[i] = charSequence[i].i
258262
return buffer
259263
}

src/main/kotlin/uno/caps/caps.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package uno.caps
22

3-
import com.jogamp.opengl.GLES1.GL_ETC1_RGB8_OES
3+
import glm_.buffer.cap
4+
import glm_.buffer.intBufferBig
45
import glm_.vec2.Vec2
56
import gln.checkError
67
import gln.glGetVec2
@@ -29,8 +30,7 @@ import org.lwjgl.opengl.GL45.GL_MAX_CULL_DISTANCES
2930
import org.lwjgl.opengl.KHRTextureCompressionASTCLDR.*
3031
import org.lwjgl.opengl.NVDeepTexture3D.GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV
3132
import org.lwjgl.opengl.NVDeepTexture3D.GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV
32-
import uno.buffer.destroy
33-
import uno.buffer.intBufferBig
33+
import uno.buffer.use
3434
import uno.gl.*
3535
import uno.glfw.GlfwWindow
3636
import uno.glfw.glfw
@@ -50,7 +50,7 @@ fun main(args: Array<String>) {
5050
val debug = false
5151
val defaultVersion = "4.6"
5252
val defaultPath = Paths.get("").toAbsolutePath().normalize().toString()
53-
val defaultFilename = "report.txt"
53+
val defaultFilename = "report.txt"
5454

5555
val version: String
5656
val path: String
@@ -1207,11 +1207,10 @@ class Caps(profile: Profile) {
12071207
inner class Formats {
12081208

12091209
private val compressed by lazy {
1210-
val buffer = intBufferBig(limits.NUM_COMPRESSED_TEXTURE_FORMATS)
1211-
glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, buffer)
1212-
val formats = (0 until buffer.capacity()).map { buffer[it] }
1213-
buffer.destroy()
1214-
formats
1210+
intBufferBig(limits.NUM_COMPRESSED_TEXTURE_FORMATS).use { buffer ->
1211+
glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, buffer)
1212+
(0 until buffer.cap).map { buffer[it] }
1213+
}
12151214
}
12161215

12171216
@JvmField
Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
package uno.debug
2-
3-
import com.jogamp.opengl.GL2ES2.GL_DEBUG_SEVERITY_NOTIFICATION
4-
import com.jogamp.opengl.GL2ES2.GL_DEBUG_SEVERITY_LOW
5-
import com.jogamp.opengl.GLDebugMessage
6-
import com.jogamp.opengl.GLDebugListener
7-
8-
9-
/**
10-
* Created by elect on 13/02/17.
11-
*/
12-
13-
class GlDebugOutput : GLDebugListener {
14-
15-
var source = 0
16-
var type = 0
17-
var id = 0
18-
var severity = 0
19-
var length = 0
20-
var message: String? = null
21-
var received = false
22-
23-
constructor()
24-
25-
constructor(source: Int, type: Int, severity: Int) {
26-
this.source = source
27-
this.type = type
28-
this.severity = severity
29-
this.message = null
30-
this.id = -1
31-
32-
}
33-
34-
constructor(message: String, id: Int) {
35-
this.source = -1
36-
this.type = -1
37-
this.severity = -1
38-
this.message = message
39-
this.id = id
40-
}
41-
42-
override fun messageSent(event: GLDebugMessage) {
43-
44-
if (event.dbgSeverity == GL_DEBUG_SEVERITY_LOW || event.dbgSeverity == GL_DEBUG_SEVERITY_NOTIFICATION)
45-
println("GlDebugOutput.messageSent(): $event")
46-
else
47-
System.err.println("GlDebugOutput.messageSent(): " + event)
48-
49-
if (null != message && message == event.dbgMsg && id == event.dbgId)
50-
received = true
51-
else if (0 <= source && source == event.dbgSource && type == event.dbgType && severity == event.dbgSeverity)
52-
received = true
53-
}
54-
}
1+
//package uno.debug
2+
//
3+
//import com.jogamp.opengl.GL2ES2.GL_DEBUG_SEVERITY_NOTIFICATION
4+
//import com.jogamp.opengl.GL2ES2.GL_DEBUG_SEVERITY_LOW
5+
//import com.jogamp.opengl.GLDebugMessage
6+
//import com.jogamp.opengl.GLDebugListener
7+
//
8+
//
9+
///**
10+
// * Created by elect on 13/02/17.
11+
// */
12+
//
13+
//class GlDebugOutput : GLDebugListener {
14+
//
15+
// var source = 0
16+
// var type = 0
17+
// var id = 0
18+
// var severity = 0
19+
// var length = 0
20+
// var message: String? = null
21+
// var received = false
22+
//
23+
// constructor()
24+
//
25+
// constructor(source: Int, type: Int, severity: Int) {
26+
// this.source = source
27+
// this.type = type
28+
// this.severity = severity
29+
// this.message = null
30+
// this.id = -1
31+
//
32+
// }
33+
//
34+
// constructor(message: String, id: Int) {
35+
// this.source = -1
36+
// this.type = -1
37+
// this.severity = -1
38+
// this.message = message
39+
// this.id = id
40+
// }
41+
//
42+
// override fun messageSent(event: GLDebugMessage) {
43+
//
44+
// if (event.dbgSeverity == GL_DEBUG_SEVERITY_LOW || event.dbgSeverity == GL_DEBUG_SEVERITY_NOTIFICATION)
45+
// println("GlDebugOutput.messageSent(): $event")
46+
// else
47+
// System.err.println("GlDebugOutput.messageSent(): $event")
48+
//
49+
// if (null != message && message == event.dbgMsg && id == event.dbgId)
50+
// received = true
51+
// else if (0 <= source && source == event.dbgSource && type == event.dbgType && severity == event.dbgSeverity)
52+
// received = true
53+
// }
54+
//}

0 commit comments

Comments
 (0)