Friday, 29 March 2019

Hello world OpenGL Kotlin app with kotlinc for Android on Mac, or with Gradle and Java

I have installed android with the latest stuff:

brew install ant
brew install maven
brew install gradle
brew install android-sdk
brew install android-ndk
brew install kotlin

I have a simple hello world example.kt file like this:

package foo.bar

fun ms() : Long {
  return System.currentTimeMillis()
}

And a test.kt like this:

package foo.bar

fun main(args: Array<String>) {
  println(ms())
}

which is compiled and run like this:

kotlinc src -include-runtime -d test.jar
kotlin test.jar

Next I would like to display a triangle using OpenGL on Android. A basic hello world example. I've checked through quite a few resources but haven't seen how to actually compile an Activity using kotlinc, which seems like the main "application object" in Android.

For reference, these imports seem relevant to android sdk OpenGL:

import android.opengl.GLES20
import android.opengl.GLES32
import android.graphics.SurfaceTexture
import android.opengl.GLSurfaceView

Anyways, basically what this boils down to is how to render an Activity using kotlinc, purely from the command line, without Android Studio or any UI/IDE. Once I get there then I can figure out how to do OpenGL.

So for example, this post shows this Activity boilerplate:

package me.mladenrakonjac.modernandroidapp

import android.support.v7.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
}

I would like to just render a HelloWorld Activity (without any AndroidManifest.xml if possible, just Kotlin instead of XML, unless XML is required, I'm new to Android), from the command line. Not sure how to take that MainActivity snippet and compile it and render it, maybe add a textarea with "hello world" in it.

If not possible with Kotlin, then wondering how to do it with Gradle/Java.



from Hello world OpenGL Kotlin app with kotlinc for Android on Mac, or with Gradle and Java

No comments:

Post a Comment