Skip to content

Commit 3de2287

Browse files
authored
Merge pull request #23 from skyfe79/08-1.AmbientLight
make ambient light example
2 parents bc634e4 + 5c5a5d3 commit 3de2287

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1838
-1
lines changed

07-1.Texture/.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

08-1.AmbientLight/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures

08-1.AmbientLight/.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

08-1.AmbientLight/.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

08-1.AmbientLight/.idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

08-1.AmbientLight/.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

08-1.AmbientLight/.idea/gradle.xml

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

08-1.AmbientLight/.idea/misc.xml

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

08-1.AmbientLight/.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

08-1.AmbientLight/.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

08-1.AmbientLight/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

08-1.AmbientLight/app/build.gradle

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "23.0.3"
6+
7+
defaultConfig {
8+
applicationId "kr.pe.burt.android.ambientlight"
9+
minSdkVersion 17
10+
targetSdkVersion 23
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
testCompile 'junit:junit:4.12'
25+
compile 'com.android.support:appcompat-v7:23.4.0'
26+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/burt/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package kr.pe.burt.android.ambientlight;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="kr.pe.burt.android.ambientlight">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity android:name=".MainActivity">
12+
<intent-filter>
13+
<action android:name="android.intent.action.MAIN" />
14+
15+
<category android:name="android.intent.category.LAUNCHER" />
16+
</intent-filter>
17+
</activity>
18+
</application>
19+
20+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package kr.pe.burt.android.ambientlight;
2+
3+
4+
import kr.pe.burt.android.ambientlight.glkit.ShaderProgram;
5+
6+
/**
7+
* Created by burt on 2016. 6. 23..
8+
*/
9+
public class Cube extends Model {
10+
11+
static final float vertices[] = {
12+
// Front
13+
1, -1, 1, 1, 0, 0, 1, 1, 0, // 0
14+
1, 1, 1, 0, 1, 0, 1, 1, 1, // 1
15+
-1, 1, 1, 0, 0, 1, 1, 0, 1, // 2
16+
-1, -1, 1, 0, 0, 0, 1, 0, 0, // 3
17+
18+
// Back
19+
-1, -1, -1, 0, 0, 1, 1, 1, 0, // 4
20+
-1, 1, -1, 0, 1, 0, 1, 1, 1, // 5
21+
1, 1, -1, 1, 0, 0, 1, 0, 1, // 6
22+
1, -1, -1, 0, 0, 0, 1, 0, 0, // 7
23+
24+
// Left
25+
-1, -1, 1, 1, 0, 0, 1, 1, 0, // 8
26+
-1, 1, 1, 0, 1, 0, 1, 1, 1, // 9
27+
-1, 1, -1, 0, 0, 1, 1, 0, 1, // 10
28+
-1, -1, -1, 0, 0, 0, 1, 0, 0, // 11
29+
30+
// Right
31+
1, -1, -1, 1, 0, 0, 1, 1, 0, // 12
32+
1, 1, -1, 0, 1, 0, 1, 1, 1, // 13
33+
1, 1, 1, 0, 0, 1, 1, 0, 1, // 14
34+
1, -1, 1, 0, 0, 0, 1, 0, 0, // 15
35+
36+
// Top
37+
1, 1, 1, 1, 0, 0, 1, 1, 0, // 16
38+
1, 1, -1, 0, 1, 0, 1, 1, 1, // 17
39+
-1, 1, -1, 0, 0, 1, 1, 0, 1, // 18
40+
-1, 1, 1, 0, 0, 0, 1, 0, 0, // 19
41+
42+
// Bottom
43+
1, -1, -1, 1, 0, 0, 1, 1, 0, // 20
44+
1, -1, 1, 0, 1, 0, 1, 1, 1, // 21
45+
-1, -1, 1, 0, 0, 1, 1, 0, 1, // 22
46+
-1, -1, -1, 0, 0, 0, 1, 0, 0, // 23
47+
48+
};
49+
50+
static final short indices[] = {
51+
52+
// Front
53+
0, 1, 2,
54+
2, 3, 0,
55+
56+
// Back
57+
4, 5, 6,
58+
6, 7, 4,
59+
60+
// Left
61+
8, 9, 10,
62+
10, 11, 8,
63+
64+
// Right
65+
12, 13, 14,
66+
14, 15, 12,
67+
68+
// Top
69+
16, 17, 18,
70+
18, 19, 16,
71+
72+
// Bottom
73+
20, 21, 22,
74+
22, 23, 20
75+
};
76+
77+
public Cube(ShaderProgram shader) {
78+
super("cube", shader, vertices, indices);
79+
}
80+
81+
@Override
82+
void injectData(ShaderProgram shader) {
83+
shader.setUniformf("u_Light.Color", 0.0f, 1.0f, 1.0f);
84+
shader.setUniformf("u_Light.AmbientIntensity", 1.5f);
85+
}
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package kr.pe.burt.android.ambientlight;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
6+
public class MainActivity extends AppCompatActivity {
7+
8+
private OGLView oglView;
9+
10+
@Override
11+
protected void onCreate(Bundle savedInstanceState) {
12+
super.onCreate(savedInstanceState);
13+
setContentView(R.layout.activity_main);
14+
15+
oglView = (OGLView) findViewById(R.id.oglView);
16+
}
17+
18+
@Override
19+
protected void onPause() {
20+
super.onPause();
21+
oglView.onPause();
22+
}
23+
24+
@Override
25+
protected void onResume() {
26+
super.onResume();
27+
oglView.onResume();
28+
}
29+
}

0 commit comments

Comments
 (0)