Skip to content

Lesson One, ported to Kotlin #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions android/AndroidOpenGLESLessons/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 25
Expand All @@ -23,8 +24,33 @@ android {

buildTypes {
release {
minifyEnabled true
signingConfig signingConfigs.release
//minifyEnabled true
//signingConfig signingConfigs.release
}
}

packagingOptions {
exclude 'META-INF/build_main.kotlin_module' // will not include NOTICE file
// exclude 'META-INF/NOTICE' // will not include NOTICE file
// exclude 'META-INF/LICENSE' // will not include LICENSE file
// // as noted by @Vishnuvathsan you may also need to include
// // variations on the file name. It depends on your dependencies.
// // Some other common variations on notice and license file names
// exclude 'META-INF/notice'
// exclude 'META-INF/notice.txt'
// exclude 'META-INF/license'
// exclude 'META-INF/license.txt'
}
}

allprojects {
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.github.kotlin-graphics:uno-sdk:cd7941c0f7'
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,54 @@
import android.opengl.GLSurfaceView;
import android.os.Bundle;

public class LessonOneActivity extends Activity
{
/** Hold a reference to our GLSurfaceView */
private GLSurfaceView mGLSurfaceView;

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mGLSurfaceView = new GLSurfaceView(this);

// Check if the system supports OpenGL ES 2.0.
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;

if (supportsEs2)
{
// Request an OpenGL ES 2.0 compatible context.
mGLSurfaceView.setEGLContextClientVersion(2);

// Set the renderer to our demo renderer, defined below.
mGLSurfaceView.setRenderer(new LessonOneRenderer());
}
else
{
// This is where you could create an OpenGL ES 1.x compatible
// renderer if you wanted to support both ES 1 and ES 2.
return;
}

setContentView(mGLSurfaceView);
}

@Override
protected void onResume()
{
// The activity must call the GL surface view's onResume() on activity onResume().
super.onResume();
mGLSurfaceView.onResume();
}

@Override
protected void onPause()
{
// The activity must call the GL surface view's onPause() on activity onPause().
super.onPause();
mGLSurfaceView.onPause();
}
public class LessonOneActivity extends Activity {
/**
* Hold a reference to our GLSurfaceView
*/
private GLSurfaceView mGLSurfaceView;

private final boolean useKotlin = true;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

mGLSurfaceView = new GLSurfaceView(this);

// Check if the system supports OpenGL ES 2.0.
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;

if (supportsEs2) {
// Request an OpenGL ES 2.0 compatible context.
mGLSurfaceView.setEGLContextClientVersion(2);

// Set the renderer to our demo renderer, defined below.
if (useKotlin)
mGLSurfaceView.setRenderer(new LessonOneRendererKt());
else
mGLSurfaceView.setRenderer(new LessonOneRenderer());
} else {
// This is where you could create an OpenGL ES 1.x compatible
// renderer if you wanted to support both ES 1 and ES 2.
return;
}

setContentView(mGLSurfaceView);
}

@Override
protected void onResume() {
// The activity must call the GL surface view's onResume() on activity onResume().
super.onResume();
mGLSurfaceView.onResume();
}

@Override
protected void onPause() {
// The activity must call the GL surface view's onPause() on activity onPause().
super.onPause();
mGLSurfaceView.onPause();
}
}
Loading