Skip to content

Commit

Permalink
v0.7.4
Browse files Browse the repository at this point in the history
fixed kool dependencies
commented out vk stuff for the moment

bump up:
- kotlin 1.2.70
- gradle 4.10.2
- gln
  • Loading branch information
elect86 committed Sep 21, 2018
1 parent 154a92b commit c74defd
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 88 deletions.
13 changes: 6 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ group = 'com.github.kotlin-graphics'

buildscript {

ext.kotlinVersion = '1.2.60'
ext.kotlinVersion = '1.2.70'

repositories {
mavenCentral()
Expand All @@ -23,7 +23,7 @@ buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
classpath "org.junit.platform:junit-platform-gradle-plugin:1.1.0"
classpath "org.junit.platform:junit-platform-gradle-plugin:1.2.0"
}
}

Expand All @@ -36,12 +36,11 @@ dependencies {
implementation "$kotlin-reflect:$kotlinVersion"

ext.kx = "com.github.kotlin-graphics"
implementation "$kx:gln:820ec8bca2"
implementation "$kx:vkk:86fe39a"
implementation "$kx:appBuffer:39d8216"
implementation "$kx:gln:1e35c8c7a5f0f1e61a77f0a2cb803111da5ef4df"
// implementation "$kx:vkk:86fe39a"
// implementation "$kx:appBuffer:39d8216"

testImplementation 'io.kotlintest:kotlintest:2.0.7'
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.0.6'
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.1.10'

// ext.jogl = "2.3.2"
// compile "org.jogamp.gluegen:gluegen-rt:$jogl"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
3 changes: 1 addition & 2 deletions src/main/kotlin/uno/buffer/buffer.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package uno.buffer


import glm_.BYTES
import glm_.buffer.*
import kool.*
import org.lwjgl.PointerBuffer
import org.lwjgl.system.MemoryUtil
import uno.kotlin.Quadruple
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/uno/buffer/of.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package uno.buffer

import glm_.BYTES
import glm_.buffer.bufferBig
import glm_.buffer.floatBufferBig
import glm_.buffer.intBufferBig
import kool.bufferBig
import kool.floatBufferBig
import kool.intBufferBig
import glm_.i
import glm_.set
import glm_.vec2.Vec2
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/uno/caps/caps.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uno.caps

import glm_.buffer.cap
import glm_.buffer.intBufferBig
import kool.cap
import kool.intBufferBig
import glm_.vec2.Vec2
import gln.checkError
import gln.glGetVec2
Expand Down
67 changes: 33 additions & 34 deletions src/main/kotlin/uno/glfw/GlfwWindow.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package uno.glfw

import ab.appBuffer
import glm_.BYTES
import glm_.bool
import glm_.f
import glm_.i
Expand All @@ -11,6 +11,7 @@ import glm_.vec4.Vec4i
import gln.debug.GlDebugSeverity
import gln.debug.GlDebugSource
import gln.debug.GlDebugType
import kool.stak
import org.lwjgl.glfw.*
import org.lwjgl.glfw.GLFW.*
import org.lwjgl.opengl.GL
Expand All @@ -20,7 +21,6 @@ import org.lwjgl.system.Callback
import org.lwjgl.system.MemoryStack
import org.lwjgl.system.MemoryUtil.*
import org.lwjgl.vulkan.VkInstance
import uno.kotlin.first
import uno.kotlin.getOrfirst
import java.nio.ByteBuffer
import java.nio.FloatBuffer
Expand Down Expand Up @@ -129,18 +129,18 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
fun setSizeLimit(width: IntRange, height: IntRange) = glfwSetWindowSizeLimits(handle, width.start, height.start, width.endInclusive, height.endInclusive)

var pos = Vec2i()
get() {
val x = appBuffer.int
val y = appBuffer.int
get() = stak {
val x = it.nmalloc(Int.BYTES * 2)
val y = x + Int.BYTES
nglfwGetWindowPos(handle, x, y)
return field(memGetInt(x), memGetInt(y))
}
set(value) = glfwSetWindowPos(handle, value.x, value.y)

var size = Vec2i()
get() {
val x = appBuffer.int
val y = appBuffer.int
get() = stak {
val x = it.nmalloc(Int.BYTES * 2)
val y = x + Int.BYTES
nglfwGetWindowSize(handle, x, y)
return field(memGetInt(x), memGetInt(y))
}
Expand All @@ -157,27 +157,27 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
set(value) = glfwSetWindowAspectRatio(handle, value.x, value.y)

val framebufferSize = Vec2i()
get() {
val x = appBuffer.int
val y = appBuffer.int
get() = stak {
val x = it.nmalloc(Int.BYTES * 2)
val y = x + Int.BYTES
nglfwGetFramebufferSize(handle, x, y)
return field(memGetInt(x), memGetInt(y))
}

val frameSize = Vec4i()
get() {
val x = appBuffer.int
val y = appBuffer.int
val z = appBuffer.int
val w = appBuffer.int
get() = stak {
val x = it.nmalloc(Int.BYTES * 4)
val y = x + Int.BYTES
val z = y + Int.BYTES
val w = z + Int.BYTES
nglfwGetWindowFrameSize(handle, x, y, z, w)
return field(memGetInt(x), memGetInt(y), memGetInt(z), memGetInt(w))
}

val contentScale = Vec2()
get() {
val x = appBuffer.float
val y = appBuffer.float
get() = stak {
val x = it.nmalloc(Float.BYTES * 2)
val y = x + Float.BYTES
nglfwGetWindowContentScale(handle, x, y)
return field(memGetFloat(x), memGetFloat(y))
}
Expand Down Expand Up @@ -247,9 +247,9 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
}

var cursorPos = Vec2d()
get() {
val x = appBuffer.double
val y = appBuffer.double
get() = stak {
val x = it.nmalloc(Double.BYTES * 2)
val y = x + Double.BYTES
nglfwGetCursorPos(handle, x, y)
return field(memGetDouble(x), memGetDouble(y))
}
Expand Down Expand Up @@ -354,7 +354,7 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
// Event handlers are called by the GLFW callback mechanism and should not be called directly
//

open fun onWindowResized(newSize: Vec2i) = appBuffer.reset()
open fun onWindowResized(newSize: Vec2i) {}
open fun onWindowClosed() {}

// Keyboard handling
Expand Down Expand Up @@ -413,8 +413,8 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
val joystick3Buttons: ByteBuffer?
get() = getJoystickButtons(GLFW_JOYSTICK_3)

fun getJoystickButtons(joystickId: Int): ByteBuffer? {
val count = appBuffer.int
fun getJoystickButtons(joystickId: Int): ByteBuffer? = stak {
val count = it.nmalloc(Int.BYTES)
val result = nglfwGetJoystickButtons(joystickId, count)
return memByteBufferSafe(result, memGetInt(count))
}
Expand All @@ -426,8 +426,8 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
val joystick3Axes: FloatBuffer?
get() = getJoystickAxes(GLFW_JOYSTICK_3)

fun getJoystickAxes(joystickId: Int): FloatBuffer? {
val count = appBuffer.int
fun getJoystickAxes(joystickId: Int): FloatBuffer? = stak {
val count = it.nmalloc(Int.BYTES)
val result = nglfwGetJoystickAxes(joystickId, count)
return memFloatBufferSafe(result, memGetInt(count))
}
Expand All @@ -445,16 +445,15 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
inline fun loop(condition: () -> Boolean, block: (MemoryStack) -> Unit) {
while (condition()) {
glfwPollEvents()
val stack = MemoryStack.stackGet()
block(stack.push())
if (autoSwap)
glfwSwapBuffers(handle)
stack.pop()
appBuffer.reset() // TODO delete
stak {
block(it)
if (autoSwap)
glfwSwapBuffers(handle)
}
}
}

infix fun createSurface(instance: VkInstance) = glfw.createWindowSurface(handle, instance)
// infix fun createSurface(instance: VkInstance) = glfw.createWindowSurface(handle, instance)

fun swapBuffers() = glfwSwapBuffers(handle)
inline fun present() = swapBuffers()
Expand Down
13 changes: 6 additions & 7 deletions src/main/kotlin/uno/glfw/direct fields.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ package uno.glfw

import glm_.vec2.Vec2i
import org.lwjgl.glfw.GLFWVidMode
import vkk.adr


inline val GLFWVidMode.width: Int
get() = GLFWVidMode.nwidth(adr)
get() = GLFWVidMode.nwidth(address()) // TODO adr
inline val GLFWVidMode.height: Int
get() = GLFWVidMode.nheight(adr)
get() = GLFWVidMode.nheight(address())
inline val GLFWVidMode.size: Vec2i
get() = Vec2i(width, height)
inline val GLFWVidMode.redBits: Int
get() = GLFWVidMode.nredBits(adr)
get() = GLFWVidMode.nredBits(address())
inline val GLFWVidMode.greenBits: Int
get() = GLFWVidMode.ngreenBits(adr)
get() = GLFWVidMode.ngreenBits(address())
inline val GLFWVidMode.blueBits: Int
get() = GLFWVidMode.nblueBits(adr)
get() = GLFWVidMode.nblueBits(address())
inline val GLFWVidMode.refreshRate: Int
get() = GLFWVidMode.nrefreshRate(adr)
get() = GLFWVidMode.nrefreshRate(address())


typealias HWND = Long
50 changes: 25 additions & 25 deletions src/main/kotlin/uno/glfw/glfw.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package uno.glfw

import ab.appBuffer
import glm_.buffer.adr
import kool.adr
import glm_.i
import glm_.vec2.Vec2i
import kool.stak
import org.lwjgl.glfw.GLFW.*
import org.lwjgl.glfw.GLFWErrorCallback
import org.lwjgl.glfw.GLFWVidMode
Expand All @@ -15,9 +15,9 @@ import org.lwjgl.system.Platform
import org.lwjgl.vulkan.VkInstance
import uno.glfw.windowHint.Profile
import uno.kotlin.parseInt
import vkk.VK_CHECK_RESULT
import vkk.VkSurfaceKHR
import vkk.adr
//import vkk.VK_CHECK_RESULT
//import vkk.VkSurfaceKHR
//import vkk.adr
import java.util.function.BiPredicate

/**
Expand Down Expand Up @@ -85,7 +85,7 @@ object glfw {
set(value) {
if (value != null) {
field = value
nglfwSetErrorCallback(nErrorCallback.adr)
nglfwSetErrorCallback(nErrorCallback.address()) // TODO adr
} else
nglfwSetErrorCallback(NULL)
}
Expand Down Expand Up @@ -113,23 +113,23 @@ object glfw {

fun pollEvents() = glfwPollEvents()

val requiredInstanceExtensions: ArrayList<String>
get() {
val pCount = appBuffer.intBuffer
val ppNames = GLFWVulkan.nglfwGetRequiredInstanceExtensions(pCount.adr)
val count = pCount[0]
val pNames = MemoryUtil.memPointerBufferSafe(ppNames, count) ?: return arrayListOf()
val res = ArrayList<String>(count)
for (i in 0 until count)
res += MemoryUtil.memASCII(pNames[i])
return res
}

fun createWindowSurface(windowHandle: Long, instance: VkInstance): VkSurfaceKHR {
val pSurface = appBuffer.long
VK_CHECK_RESULT(GLFWVulkan.nglfwCreateWindowSurface(instance.adr, windowHandle, NULL, pSurface))
return memGetLong(pSurface)
}
// val requiredInstanceExtensions: ArrayList<String>
// get() {
// val pCount = appBuffer.intBuffer
// val ppNames = GLFWVulkan.nglfwGetRequiredInstanceExtensions(pCount.adr)
// val count = pCount[0]
// val pNames = MemoryUtil.memPointerBufferSafe(ppNames, count) ?: return arrayListOf()
// val res = ArrayList<String>(count)
// for (i in 0 until count)
// res += MemoryUtil.memASCII(pNames[i])
// return res
// }
//
// fun createWindowSurface(windowHandle: Long, instance: VkInstance): VkSurfaceKHR {
// val pSurface = appBuffer.long
// VK_CHECK_RESULT(GLFWVulkan.nglfwCreateWindowSurface(instance.adr, windowHandle, NULL, pSurface))
// return memGetLong(pSurface)
// }

enum class Error(val i: Int) {
none(GLFW_NO_ERROR),
Expand All @@ -149,8 +149,8 @@ object glfw {
}

val error: Error
get() {
val pointer = appBuffer.pointerBuffer
get() = stak {
val pointer = it.mallocPointer(1)
val code = glfwGetError(pointer)
errorDescription = when {
code != GLFW_NO_ERROR -> memUTF8(pointer[0])
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/uno/kotlin/buffers/DualPivotQuicksort.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package uno.kotlin.buffers

import glm_.b
import glm_.buffer.intBufferBig
import glm_.set
import uno.buffer.intBufferBig
import kool.intBufferBig
import java.nio.ByteBuffer
import java.nio.IntBuffer

Expand Down
5 changes: 1 addition & 4 deletions src/main/kotlin/uno/kotlin/buffers/TimSort.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ package uno.kotlin.buffers

import glm_.BYTES
import glm_.L
import glm_.b
import glm_.buffer.intBufferBig
import glm_.detail.Random.int
import glm_.set
import kool.intBufferBig
import org.lwjgl.system.MemoryUtil
import uno.buffer.intBufferBig
import java.nio.IntBuffer

/** A stable, adaptive, iterative mergesort that requires far fewer than n lg(n) comparisons when running on partially
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/uno/kotlin/util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ fun <T>treeSetOf() = java.util.TreeSet<T>()
fun <K, V>SortedMap<K, V>.getOrfirst(key: K): V? = get(key) ?: first
val <K, V>SortedMap<K, V>.first: V? get() = get(firstKey())

val version = "0.7.3"
val version = "0.7.4"

0 comments on commit c74defd

Please sign in to comment.