[sample][polyhedron] use platform libs
This commit is contained in:
committed by
Vasily Levchenko
parent
3cdb101df6
commit
43f351d3e3
@@ -25,32 +25,13 @@ allprojects {
|
||||
|
||||
apply plugin: "konan"
|
||||
|
||||
konanInterop {
|
||||
arm32 {
|
||||
defFile "android.def"
|
||||
pkg "android"
|
||||
// TODO: launcher header will be part of the platform library.
|
||||
includeDirs "."
|
||||
target "android_arm32"
|
||||
}
|
||||
arm64 {
|
||||
defFile "android.def"
|
||||
pkg "android"
|
||||
// TODO: launcher header will be part of the platform library.
|
||||
includeDirs "."
|
||||
target "android_arm64"
|
||||
}
|
||||
}
|
||||
|
||||
konanArtifacts {
|
||||
PolyhedronArm32 {
|
||||
useInterop "arm32"
|
||||
target "android_arm32"
|
||||
outputDir 'PolyhedronArm32'
|
||||
outputName 'libpoly'
|
||||
}
|
||||
PolyhedronArm64 {
|
||||
useInterop "arm64"
|
||||
target "android_arm64"
|
||||
outputDir 'PolyhedronArm64'
|
||||
outputName 'libpoly'
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
import android.*
|
||||
import platform.android.*
|
||||
import platform.posix.*
|
||||
import platform.gles3.*
|
||||
import platform.linux.*
|
||||
|
||||
fun logError(message: String) {
|
||||
__android_log_write(ANDROID_LOG_ERROR, "KonanActivity", message)
|
||||
@@ -26,7 +29,7 @@ fun logInfo(message: String) {
|
||||
}
|
||||
|
||||
val errno: Int
|
||||
get() = interop_errno()
|
||||
get() = posix_errno()
|
||||
|
||||
fun getUnixError() = strerror(errno)!!.toKString()
|
||||
|
||||
@@ -95,7 +98,7 @@ class Engine(val arena: NativePlacement, val state: NativeActivityState) {
|
||||
|
||||
private fun processSysEvent(fd: IntVar): Boolean = memScoped {
|
||||
val eventPointer = alloc<COpaquePointerVar>()
|
||||
val readBytes = read(fd.value, eventPointer.ptr, pointerSize.signExtend<size_t>()).toLong()
|
||||
val readBytes = read(fd.value, eventPointer.ptr, pointerSize.signExtend<platform.posix.size_t>()).toLong()
|
||||
if (readBytes != pointerSize.toLong()) {
|
||||
logError("Failure reading event, $readBytes read: ${getUnixError()}")
|
||||
return true
|
||||
@@ -138,7 +141,7 @@ class Engine(val arena: NativePlacement, val state: NativeActivityState) {
|
||||
NativeActivityEventKind.SAVE_INSTANCE_STATE -> {
|
||||
val saveStateEvent = eventPointer.value.dereferenceAs<NativeActivitySaveStateEvent>()
|
||||
val state = renderer.getState()
|
||||
val dataSize = state.second.signExtend<size_t>()
|
||||
val dataSize = state.second.signExtend<platform.posix.size_t>()
|
||||
rendererState = realloc(rendererState, dataSize)
|
||||
memcpy(rendererState, state.first, dataSize)
|
||||
saveStateEvent.savedState = rendererState
|
||||
@@ -160,7 +163,7 @@ class Engine(val arena: NativePlacement, val state: NativeActivityState) {
|
||||
}
|
||||
|
||||
private fun getEventPoint(event: CPointer<AInputEvent>?, i: Int) =
|
||||
Vector2(AMotionEvent_getRawX(event, i.signExtend<size_t>()), AMotionEvent_getRawY(event, i.signExtend<size_t>()))
|
||||
Vector2(AMotionEvent_getRawX(event, i.signExtend<platform.posix.size_t>()), AMotionEvent_getRawY(event, i.signExtend<platform.posix.size_t>()))
|
||||
|
||||
private fun getEventTime(event: CPointer<AInputEvent>?) =
|
||||
AMotionEvent_getEventTime(event) / 1_000_000_000.0f
|
||||
|
||||
@@ -15,7 +15,46 @@
|
||||
*/
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
import android.*
|
||||
import platform.android.*
|
||||
import platform.egl.*
|
||||
import platform.posix.*
|
||||
import platform.gles3.*
|
||||
import platform.gles.GL_PERSPECTIVE_CORRECTION_HINT
|
||||
import platform.gles.GL_SMOOTH
|
||||
import platform.gles.GL_PROJECTION
|
||||
import platform.gles.glLoadIdentity
|
||||
import platform.gles.glFrustumf
|
||||
import platform.gles.glMatrixMode
|
||||
import platform.gles.GL_MODELVIEW
|
||||
import platform.gles.glTranslatef
|
||||
import platform.gles.glShadeModel
|
||||
import platform.gles.GL_LIGHT0
|
||||
import platform.gles.GL_POSITION
|
||||
import platform.gles.glMaterialfv
|
||||
import platform.gles.GL_DIFFUSE
|
||||
import platform.gles.GL_SHININESS
|
||||
import platform.gles.glPushMatrix
|
||||
import platform.gles.glRotatef
|
||||
import platform.gles.glMultMatrixf
|
||||
import platform.gles.GL_MODELVIEW_MATRIX
|
||||
import platform.gles.glPopMatrix
|
||||
import platform.gles.glTexEnvf
|
||||
import platform.gles.GL_TEXTURE_ENV
|
||||
import platform.gles.GL_TEXTURE_ENV_MODE
|
||||
import platform.gles.glLightfv
|
||||
import platform.gles.GL_LIGHTING
|
||||
import platform.gles.GL_SPECULAR
|
||||
import platform.gles.glMaterialf
|
||||
import platform.gles.glTexEnvfv
|
||||
import platform.gles.glEnableClientState
|
||||
import platform.gles.GL_VERTEX_ARRAY
|
||||
import platform.gles.GL_NORMAL_ARRAY
|
||||
import platform.gles.GL_TEXTURE_COORD_ARRAY
|
||||
import platform.gles.glVertexPointer
|
||||
import platform.gles.glTexCoordPointer
|
||||
import platform.gles.glNormalPointer
|
||||
import platform.gles.GL_TEXTURE_ENV_COLOR
|
||||
|
||||
|
||||
class Renderer(val parentArena: NativePlacement, val nativeActivity: ANativeActivity, val savedMatrix: COpaquePointer?) {
|
||||
|
||||
@@ -294,7 +333,7 @@ class Renderer(val parentArena: NativePlacement, val nativeActivity: ANativeActi
|
||||
surface = null
|
||||
context = null
|
||||
initialized = false
|
||||
|
||||
arena.clear()
|
||||
// TODO: What should be called here?
|
||||
//arena.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
import android.*
|
||||
import platform.android.*
|
||||
import platform.posix.*
|
||||
|
||||
class Vector2(val x: Float, val y: Float) {
|
||||
val length by lazy { sqrtf(x * x + y * y) }
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
|
||||
|
||||
Reference in New Issue
Block a user