Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Spasi committed Feb 20, 2017
0 parents commit aa4b603
Show file tree
Hide file tree
Showing 55 changed files with 3,379 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
22 changes: 22 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Copyright (c) 2012-present Lightweight Java Game Library
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

- Neither the name Lightweight Java Game Library nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[![License](https://img.shields.io/badge/license-BSD-blue.svg)](https://github.com/LWJGL/android-test/blob/master/LICENSE.md)
![Size](https://reposs.herokuapp.com/?path=lwjgl/android-test)
[![Slack Status](https://slack.lwjgl.org/badge.svg)](https://slack.lwjgl.org/)

## LWJGL 3 - Android example project and tests

Build instructions for the Android version of lwjgl3:

- `clone` [lwjgl3](https://github.com/LWJGL/lwjgl3) and `checkout` the `android` branch.
- `SET/export` the `ANDROID_SDK_HOME` environment variable. Its value should be the root of the Android SDK. The Android NDK must also be installed under the root, in the default `ndk-bundle` subdirectory.
- Run `ant compile-templates`. This will take 1-2 minutes.
- Run `ant aar`. This will produce an `lwjgl.aar` file in the `bin/android/` folder.
- Copy `lwjgl.aar` to the `android-test` repository, in the `lwjgl` folder.

Build instructions for the Android demos:

- Open the root in Android Studio.
- Wait for gradle synchronization and indexing to complete.
- Build the project.
- Connect a platform 24 compatible device, either via USB or Wi-Fi.
- Launch either the `gears` or `hellovulkan` run configurations. (shortcut: `Alt+Shift+F10`)

Installation of Vulkan validation layers:

- Create a JNI library folder for the target architecture. For example:
* `hellovulkan/src/main/jniLibs/arm64-v8a/` or
* `hellovulkan/src/main/jniLibs/armeabi-v7a/`
- Copy the shared libraries from the corresponding folder in the Android NDK. For example:
* `<sdkroot>/ndk-bundle/sources/third_party/vulkan/src/build-android/jniLibs/arm64-v8a/` or
* `<sdkroot>/ndk-bundle/sources/third_party/vulkan/src/build-android/jniLibs/armeabi-v7a/`
- Set the `VALIDATE` variable to `true` in `HelloVulkan.java:53`
23 changes: 23 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0-beta3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
1 change: 1 addition & 0 deletions gears/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
36 changes: 36 additions & 0 deletions gears/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
applicationId "org.lwjgl.demo.android.gears"
minSdkVersion 24
targetSdkVersion 25
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles 'proguard-rules.pro', getDefaultProguardFile('proguard-android.txt')
}
}
}

repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'org.joml:joml:1.9.3-SNAPSHOT'
compile project(':lwjgl')
}
26 changes: 26 additions & 0 deletions gears/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in G:\PROGRAMS\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

-optimizations !field/*,!class/merging,*
-optimizationpasses 5

-keepclassmembers class org.lwjgl.system.** { *; }
-keepclassmembernames class org.lwjgl.system.** { *; }

-keepclassmembers class sun.misc.Unsafe { *; }
-keepclassmembernames class sun.misc.Unsafe { *; }
20 changes: 20 additions & 0 deletions gears/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.lwjgl.demo.android.gears">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
13 changes: 13 additions & 0 deletions gears/src/main/assets/gears.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#version 300 es

precision mediump float;

uniform vec4 u_COLOR;

in float v_Shade;

layout(location = 0) out vec4 out_Color;

void main() {
out_Color = vec4(u_COLOR.xyz * v_Shade, u_COLOR.w);
}
17 changes: 17 additions & 0 deletions gears/src/main/assets/gears.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#version 300 es

uniform mat4 u_MVP;
uniform mat3 u_NORMAL;

uniform vec3 u_LIGHT;

layout(location = 0) in vec3 in_Position;
layout(location = 1) in vec3 in_Normal;

out float v_Shade;

void main() {
vec3 normal = normalize(u_NORMAL * in_Normal);
v_Shade = max(dot(normal, u_LIGHT), 0.0);
gl_Position = u_MVP * vec4(in_Position, 1.0);
}
Loading

0 comments on commit aa4b603

Please sign in to comment.