diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml deleted file mode 100644 index 723f9fd..0000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml deleted file mode 100644 index 723f9fd..0000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml new file mode 100644 index 0000000..580ddd7 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml deleted file mode 100644 index 723f9fd..0000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml new file mode 100644 index 0000000..580ddd7 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 8ebd665..5e5bcd9 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -7,6 +7,7 @@ @@ -16,6 +17,7 @@ + diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml deleted file mode 100644 index 723f9fd..0000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml new file mode 100644 index 0000000..580ddd7 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 8ebd665..5e5bcd9 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -7,6 +7,7 @@ @@ -16,6 +17,7 @@ + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index f041fa4..6254f9b 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -3,33 +3,30 @@ - - + - + + - + @@ -38,6 +35,6 @@ - + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml deleted file mode 100644 index 723f9fd..0000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml new file mode 100644 index 0000000..580ddd7 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 8ebd665..5e5bcd9 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -7,6 +7,7 @@ @@ -16,6 +17,7 @@ + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index f041fa4..6254f9b 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -3,33 +3,30 @@ - - + - + + - + @@ -38,6 +35,6 @@ - + \ No newline at end of file diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 7ade846..f536305 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -9,23 +9,22 @@ - + @@ -35,7 +34,7 @@ - + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml deleted file mode 100644 index 723f9fd..0000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml new file mode 100644 index 0000000..580ddd7 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 8ebd665..5e5bcd9 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -7,6 +7,7 @@ @@ -16,6 +17,7 @@ + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index f041fa4..6254f9b 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -3,33 +3,30 @@ - - + - + + - + @@ -38,6 +35,6 @@ - + \ No newline at end of file diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 7ade846..f536305 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -9,23 +9,22 @@ - + @@ -35,7 +34,7 @@ - + \ No newline at end of file diff --git a/build.gradle b/build.gradle index bf7102f..adf57eb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.5-SNAPSHOT' +version '1.1.6-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' @@ -20,7 +20,7 @@ } buildscript { - ext.kotlin_version = '1.1.1' + ext.kotlin_version = '1.1.51' repositories { maven { url "http://nexus.astraeus.nl/nexus/content/groups/public" diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml deleted file mode 100644 index 723f9fd..0000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml new file mode 100644 index 0000000..580ddd7 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 8ebd665..5e5bcd9 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -7,6 +7,7 @@ @@ -16,6 +17,7 @@ + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index f041fa4..6254f9b 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -3,33 +3,30 @@ - - + - + + - + @@ -38,6 +35,6 @@ - + \ No newline at end of file diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 7ade846..f536305 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -9,23 +9,22 @@ - + @@ -35,7 +34,7 @@ - + \ No newline at end of file diff --git a/build.gradle b/build.gradle index bf7102f..adf57eb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.5-SNAPSHOT' +version '1.1.6-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' @@ -20,7 +20,7 @@ } buildscript { - ext.kotlin_version = '1.1.1' + ext.kotlin_version = '1.1.51' repositories { maven { url "http://nexus.astraeus.nl/nexus/content/groups/public" diff --git a/src/main/kotlin/games/perses/game/Game.kt b/src/main/kotlin/games/perses/game/Game.kt index 8376338..0961316 100644 --- a/src/main/kotlin/games/perses/game/Game.kt +++ b/src/main/kotlin/games/perses/game/Game.kt @@ -92,13 +92,13 @@ init { window.onfocus = { - println("GOT FOCUS!") + //println("GOT FOCUS!") focus = true "" } window.onblur = { - println("LOST FOCUS!") + //println("LOST FOCUS!") focus = false "" @@ -158,9 +158,9 @@ fun setScreen(screen: Screen) { currentScreen.unloadResources() - screen.loadResources() - currentScreen = screen + + screen.loadResources() } fun setClearColor(r: Float, g: Float, b: Float, a: Float) { @@ -211,7 +211,8 @@ } } } catch(e: Exception) { - console.log(e.message, e) + println("Some error...") + console.log(e) } window.requestAnimationFrame { diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml deleted file mode 100644 index 723f9fd..0000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml new file mode 100644 index 0000000..580ddd7 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 8ebd665..5e5bcd9 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -7,6 +7,7 @@ @@ -16,6 +17,7 @@ + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index f041fa4..6254f9b 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -3,33 +3,30 @@ - - + - + + - + @@ -38,6 +35,6 @@ - + \ No newline at end of file diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 7ade846..f536305 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -9,23 +9,22 @@ - + @@ -35,7 +34,7 @@ - + \ No newline at end of file diff --git a/build.gradle b/build.gradle index bf7102f..adf57eb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.5-SNAPSHOT' +version '1.1.6-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' @@ -20,7 +20,7 @@ } buildscript { - ext.kotlin_version = '1.1.1' + ext.kotlin_version = '1.1.51' repositories { maven { url "http://nexus.astraeus.nl/nexus/content/groups/public" diff --git a/src/main/kotlin/games/perses/game/Game.kt b/src/main/kotlin/games/perses/game/Game.kt index 8376338..0961316 100644 --- a/src/main/kotlin/games/perses/game/Game.kt +++ b/src/main/kotlin/games/perses/game/Game.kt @@ -92,13 +92,13 @@ init { window.onfocus = { - println("GOT FOCUS!") + //println("GOT FOCUS!") focus = true "" } window.onblur = { - println("LOST FOCUS!") + //println("LOST FOCUS!") focus = false "" @@ -158,9 +158,9 @@ fun setScreen(screen: Screen) { currentScreen.unloadResources() - screen.loadResources() - currentScreen = screen + + screen.loadResources() } fun setClearColor(r: Float, g: Float, b: Float, a: Float) { @@ -211,7 +211,8 @@ } } } catch(e: Exception) { - console.log(e.message, e) + println("Some error...") + console.log(e) } window.requestAnimationFrame { diff --git a/src/main/kotlin/games/perses/shader/ShaderProgram.kt b/src/main/kotlin/games/perses/shader/ShaderProgram.kt index a227158..cf07c0f 100644 --- a/src/main/kotlin/games/perses/shader/ShaderProgram.kt +++ b/src/main/kotlin/games/perses/shader/ShaderProgram.kt @@ -102,6 +102,8 @@ fun getUniformLocation(location: String) = webgl.getUniformLocation(shaderProgram, location); fun setUniform1f(location: String, value: Float) { webgl.uniform1f(getUniformLocation(location), value); } + fun setUniform2f(location: String, v1: Float, v2: Float) { webgl.uniform2f(getUniformLocation(location), v1, v2); } + fun setUniform3f(location: String, v1: Float, v2: Float, v3: Float) { webgl.uniform3f(getUniformLocation(location), v1, v2, v3); } fun setUniform4f(location: String, v1: Float, v2: Float, v3: Float, v4: Float) { webgl.uniform4f(getUniformLocation(location), v1, v2, v3, v4); } fun setUniform1i(location: String, value: Int) { webgl.uniform1i(getUniformLocation(location), value); } fun setUniformMatrix4fv(location: String, value: Float32Array) { webgl.uniformMatrix4fv(getUniformLocation(location), false, value); } diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml deleted file mode 100644 index 723f9fd..0000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml new file mode 100644 index 0000000..580ddd7 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 8ebd665..5e5bcd9 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -7,6 +7,7 @@ @@ -16,6 +17,7 @@ + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index f041fa4..6254f9b 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -3,33 +3,30 @@ - - + - + + - + @@ -38,6 +35,6 @@ - + \ No newline at end of file diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 7ade846..f536305 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -9,23 +9,22 @@ - + @@ -35,7 +34,7 @@ - + \ No newline at end of file diff --git a/build.gradle b/build.gradle index bf7102f..adf57eb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.5-SNAPSHOT' +version '1.1.6-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' @@ -20,7 +20,7 @@ } buildscript { - ext.kotlin_version = '1.1.1' + ext.kotlin_version = '1.1.51' repositories { maven { url "http://nexus.astraeus.nl/nexus/content/groups/public" diff --git a/src/main/kotlin/games/perses/game/Game.kt b/src/main/kotlin/games/perses/game/Game.kt index 8376338..0961316 100644 --- a/src/main/kotlin/games/perses/game/Game.kt +++ b/src/main/kotlin/games/perses/game/Game.kt @@ -92,13 +92,13 @@ init { window.onfocus = { - println("GOT FOCUS!") + //println("GOT FOCUS!") focus = true "" } window.onblur = { - println("LOST FOCUS!") + //println("LOST FOCUS!") focus = false "" @@ -158,9 +158,9 @@ fun setScreen(screen: Screen) { currentScreen.unloadResources() - screen.loadResources() - currentScreen = screen + + screen.loadResources() } fun setClearColor(r: Float, g: Float, b: Float, a: Float) { @@ -211,7 +211,8 @@ } } } catch(e: Exception) { - console.log(e.message, e) + println("Some error...") + console.log(e) } window.requestAnimationFrame { diff --git a/src/main/kotlin/games/perses/shader/ShaderProgram.kt b/src/main/kotlin/games/perses/shader/ShaderProgram.kt index a227158..cf07c0f 100644 --- a/src/main/kotlin/games/perses/shader/ShaderProgram.kt +++ b/src/main/kotlin/games/perses/shader/ShaderProgram.kt @@ -102,6 +102,8 @@ fun getUniformLocation(location: String) = webgl.getUniformLocation(shaderProgram, location); fun setUniform1f(location: String, value: Float) { webgl.uniform1f(getUniformLocation(location), value); } + fun setUniform2f(location: String, v1: Float, v2: Float) { webgl.uniform2f(getUniformLocation(location), v1, v2); } + fun setUniform3f(location: String, v1: Float, v2: Float, v3: Float) { webgl.uniform3f(getUniformLocation(location), v1, v2, v3); } fun setUniform4f(location: String, v1: Float, v2: Float, v3: Float, v4: Float) { webgl.uniform4f(getUniformLocation(location), v1, v2, v3, v4); } fun setUniform1i(location: String, value: Int) { webgl.uniform1i(getUniformLocation(location), value); } fun setUniformMatrix4fv(location: String, value: Float32Array) { webgl.uniformMatrix4fv(getUniformLocation(location), false, value); } diff --git a/src/main/kotlin/games/perses/shader/ShaderProgramMesh.kt b/src/main/kotlin/games/perses/shader/ShaderProgramMesh.kt index eb4203f..f7ad203 100644 --- a/src/main/kotlin/games/perses/shader/ShaderProgramMesh.kt +++ b/src/main/kotlin/games/perses/shader/ShaderProgramMesh.kt @@ -31,7 +31,7 @@ } fun queue(vararg vertices: Float) { - queueArray(vertices as Array) + queueArray(vertices.toTypedArray()) } fun queueArray(vertices: Array) { diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..5806fb3 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml deleted file mode 100644 index 723f9fd..0000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml new file mode 100644 index 0000000..580ddd7 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 8ebd665..5e5bcd9 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -7,6 +7,7 @@ @@ -16,6 +17,7 @@ + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index f041fa4..6254f9b 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -3,33 +3,30 @@ - - + - + + - + @@ -38,6 +35,6 @@ - + \ No newline at end of file diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 7ade846..f536305 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -9,23 +9,22 @@ - + @@ -35,7 +34,7 @@ - + \ No newline at end of file diff --git a/build.gradle b/build.gradle index bf7102f..adf57eb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.5-SNAPSHOT' +version '1.1.6-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' @@ -20,7 +20,7 @@ } buildscript { - ext.kotlin_version = '1.1.1' + ext.kotlin_version = '1.1.51' repositories { maven { url "http://nexus.astraeus.nl/nexus/content/groups/public" diff --git a/src/main/kotlin/games/perses/game/Game.kt b/src/main/kotlin/games/perses/game/Game.kt index 8376338..0961316 100644 --- a/src/main/kotlin/games/perses/game/Game.kt +++ b/src/main/kotlin/games/perses/game/Game.kt @@ -92,13 +92,13 @@ init { window.onfocus = { - println("GOT FOCUS!") + //println("GOT FOCUS!") focus = true "" } window.onblur = { - println("LOST FOCUS!") + //println("LOST FOCUS!") focus = false "" @@ -158,9 +158,9 @@ fun setScreen(screen: Screen) { currentScreen.unloadResources() - screen.loadResources() - currentScreen = screen + + screen.loadResources() } fun setClearColor(r: Float, g: Float, b: Float, a: Float) { @@ -211,7 +211,8 @@ } } } catch(e: Exception) { - console.log(e.message, e) + println("Some error...") + console.log(e) } window.requestAnimationFrame { diff --git a/src/main/kotlin/games/perses/shader/ShaderProgram.kt b/src/main/kotlin/games/perses/shader/ShaderProgram.kt index a227158..cf07c0f 100644 --- a/src/main/kotlin/games/perses/shader/ShaderProgram.kt +++ b/src/main/kotlin/games/perses/shader/ShaderProgram.kt @@ -102,6 +102,8 @@ fun getUniformLocation(location: String) = webgl.getUniformLocation(shaderProgram, location); fun setUniform1f(location: String, value: Float) { webgl.uniform1f(getUniformLocation(location), value); } + fun setUniform2f(location: String, v1: Float, v2: Float) { webgl.uniform2f(getUniformLocation(location), v1, v2); } + fun setUniform3f(location: String, v1: Float, v2: Float, v3: Float) { webgl.uniform3f(getUniformLocation(location), v1, v2, v3); } fun setUniform4f(location: String, v1: Float, v2: Float, v3: Float, v4: Float) { webgl.uniform4f(getUniformLocation(location), v1, v2, v3, v4); } fun setUniform1i(location: String, value: Int) { webgl.uniform1i(getUniformLocation(location), value); } fun setUniformMatrix4fv(location: String, value: Float32Array) { webgl.uniformMatrix4fv(getUniformLocation(location), false, value); } diff --git a/src/main/kotlin/games/perses/shader/ShaderProgramMesh.kt b/src/main/kotlin/games/perses/shader/ShaderProgramMesh.kt index eb4203f..f7ad203 100644 --- a/src/main/kotlin/games/perses/shader/ShaderProgramMesh.kt +++ b/src/main/kotlin/games/perses/shader/ShaderProgramMesh.kt @@ -31,7 +31,7 @@ } fun queue(vararg vertices: Float) { - queueArray(vertices as Array) + queueArray(vertices.toTypedArray()) } fun queueArray(vertices: Array) { diff --git a/src/main/kotlin/games/perses/texture/Textures.kt b/src/main/kotlin/games/perses/texture/Textures.kt index e27680a..9053d1f 100644 --- a/src/main/kotlin/games/perses/texture/Textures.kt +++ b/src/main/kotlin/games/perses/texture/Textures.kt @@ -89,12 +89,12 @@ val top = height / 2f fun queueDraw(x: Float, y: Float, scale: Float = 1f, rotation: Float = 0f) { - shaderProgramMesh.queue( x, y, left, bottom, 0f, 0f, scale, rotation) - shaderProgramMesh.queue( x, y, left, top, 0f, 1f, scale, rotation) - shaderProgramMesh.queue( x, y, right, top, 1f, 1f, scale, rotation) - shaderProgramMesh.queue( x, y, right, top, 1f, 1f, scale, rotation) - shaderProgramMesh.queue( x, y, right, bottom, 1f, 0f, scale, rotation) - shaderProgramMesh.queue( x, y, left, bottom, 0f, 0f, scale, rotation) + shaderProgramMesh.queueArray(arrayOf(x, y, left, bottom, 0f, 0f, scale, rotation)) + shaderProgramMesh.queueArray(arrayOf(x, y, left, top, 0f, 1f, scale, rotation)) + shaderProgramMesh.queueArray(arrayOf(x, y, right, top, 1f, 1f, scale, rotation)) + shaderProgramMesh.queueArray(arrayOf(x, y, right, top, 1f, 1f, scale, rotation)) + shaderProgramMesh.queueArray(arrayOf(x, y, right, bottom, 1f, 0f, scale, rotation)) + shaderProgramMesh.queueArray(arrayOf(x, y, left, bottom, 0f, 0f, scale, rotation)) if (shaderProgramMesh.remaining() < 36) { render() @@ -102,12 +102,12 @@ } fun queueTileDraw(x: Float, y: Float, tcLeft: Float, tcTop: Float, tcRight: Float, tcBottom: Float, scale: Float = 1f, rotation: Float = 0f) { - shaderProgramMesh.queue( x, y, left, bottom, tcLeft, tcBottom, scale, rotation) - shaderProgramMesh.queue( x, y, left, top, tcLeft, tcTop, scale, rotation) - shaderProgramMesh.queue( x, y, right, top, tcRight, tcTop, scale, rotation) - shaderProgramMesh.queue( x, y, right, top, tcRight, tcTop, scale, rotation) - shaderProgramMesh.queue( x, y, right, bottom, tcRight, tcBottom, scale, rotation) - shaderProgramMesh.queue( x, y, left, bottom, tcLeft, tcBottom, scale, rotation) + shaderProgramMesh.queueArray(arrayOf(x, y, left, bottom, tcLeft, tcBottom, scale, rotation)) + shaderProgramMesh.queueArray(arrayOf(x, y, left, top, tcLeft, tcTop, scale, rotation)) + shaderProgramMesh.queueArray(arrayOf(x, y, right, top, tcRight, tcTop, scale, rotation)) + shaderProgramMesh.queueArray(arrayOf(x, y, right, top, tcRight, tcTop, scale, rotation)) + shaderProgramMesh.queueArray(arrayOf(x, y, right, bottom, tcRight, tcBottom, scale, rotation)) + shaderProgramMesh.queueArray(arrayOf(x, y, left, bottom, tcLeft, tcBottom, scale, rotation)) if (shaderProgramMesh.remaining() < 36) { render()