Skip to content

Commit 565d78e

Browse files
committed
added fast2d example to debug P2DX
1 parent 01773e6 commit 565d78e

File tree

20 files changed

+920
-1
lines changed

20 files changed

+920
-1
lines changed

studio/apps/fast2d/build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 26
5+
buildToolsVersion '27.0.3'
6+
defaultConfig {
7+
applicationId "processing.tests.fast2d"
8+
minSdkVersion 17
9+
targetSdkVersion 21
10+
versionCode 1
11+
versionName "1.0"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
productFlavors {
20+
}
21+
compileOptions {
22+
sourceCompatibility JavaVersion.VERSION_1_7
23+
targetCompatibility JavaVersion.VERSION_1_7
24+
}
25+
}
26+
27+
dependencies {
28+
implementation fileTree(include: ['*.jar'], dir: 'libs')
29+
testImplementation 'junit:junit:4.12'
30+
implementation project(':libs:processing-core')
31+
implementation 'com.android.support:appcompat-v7:26.0.2'
32+
}
Lines changed: 20 additions & 0 deletions
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" android:versionCode="1" android:versionName="1.0" package="fast2d">
3+
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="26"/>
4+
<application
5+
android:allowBackup="true"
6+
android:icon="@mipmap/ic_launcher"
7+
android:label="@string/app_name"
8+
android:supportsRtl="true"
9+
android:theme="@style/AppTheme"
10+
android:hardwareAccelerated="true"
11+
android:largeHeap="true">
12+
<activity android:name=".MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN"/>
15+
<category android:name="android.intent.category.LAUNCHER"/>
16+
</intent-filter>
17+
</activity>
18+
</application>
19+
20+
</manifest>
617 KB
Loading
Lines changed: 160 additions & 0 deletions
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifdef GL_ES
2+
precision mediump float;
3+
precision mediump int;
4+
#endif
5+
6+
#define PROCESSING_TEXTURE_SHADER
7+
8+
uniform sampler2D texture;
9+
uniform vec2 texOffset;
10+
11+
varying vec4 vertColor;
12+
varying vec4 vertTexCoord;
13+
14+
void main(void) {
15+
// Grouping texcoord variables in order to make it work in the GMA 950. See post #13
16+
// in this thread:
17+
// http://www.idevgames.com/forums/thread-3467.html
18+
vec2 tc0 = vertTexCoord.st + vec2(-texOffset.s, -texOffset.t);
19+
vec2 tc1 = vertTexCoord.st + vec2( 0.0, -texOffset.t);
20+
vec2 tc2 = vertTexCoord.st + vec2(+texOffset.s, -texOffset.t);
21+
vec2 tc3 = vertTexCoord.st + vec2(-texOffset.s, 0.0);
22+
vec2 tc4 = vertTexCoord.st + vec2( 0.0, 0.0);
23+
vec2 tc5 = vertTexCoord.st + vec2(+texOffset.s, 0.0);
24+
vec2 tc6 = vertTexCoord.st + vec2(-texOffset.s, +texOffset.t);
25+
vec2 tc7 = vertTexCoord.st + vec2( 0.0, +texOffset.t);
26+
vec2 tc8 = vertTexCoord.st + vec2(+texOffset.s, +texOffset.t);
27+
28+
vec4 col0 = texture2D(texture, tc0);
29+
vec4 col1 = texture2D(texture, tc1);
30+
vec4 col2 = texture2D(texture, tc2);
31+
vec4 col3 = texture2D(texture, tc3);
32+
vec4 col4 = texture2D(texture, tc4);
33+
vec4 col5 = texture2D(texture, tc5);
34+
vec4 col6 = texture2D(texture, tc6);
35+
vec4 col7 = texture2D(texture, tc7);
36+
vec4 col8 = texture2D(texture, tc8);
37+
38+
vec4 sum = 8.0 * col4 - (col0 + col1 + col2 + col3 + col5 + col6 + col7 + col8);
39+
gl_FragColor = vec4(sum.rgb, 1.0) * vertColor;
40+
}
904 Bytes
Loading
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package fast2d;
2+
3+
import android.os.Bundle;
4+
import android.content.Intent;
5+
import android.view.ViewGroup;
6+
import android.widget.FrameLayout;
7+
import android.support.v7.app.AppCompatActivity;
8+
9+
import processing.android.PFragment;
10+
import processing.android.CompatUtils;
11+
import processing.core.PApplet;
12+
13+
public class MainActivity extends AppCompatActivity {
14+
private PApplet sketch;
15+
16+
@Override
17+
protected void onCreate(Bundle savedInstanceState) {
18+
super.onCreate(savedInstanceState);
19+
FrameLayout frame = new FrameLayout(this);
20+
frame.setId(CompatUtils.getUniqueViewId());
21+
setContentView(frame, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
22+
ViewGroup.LayoutParams.MATCH_PARENT));
23+
24+
sketch = new Sketch();
25+
PFragment fragment = new PFragment(sketch);
26+
fragment.setView(frame, this);
27+
}
28+
29+
@Override
30+
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
31+
if (sketch != null) {
32+
sketch.onRequestPermissionsResult(
33+
requestCode, permissions, grantResults);
34+
}
35+
}
36+
37+
@Override
38+
public void onNewIntent(Intent intent) {
39+
if (sketch != null) {
40+
sketch.onNewIntent(intent);
41+
}
42+
}
43+
44+
@Override
45+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
46+
if (sketch != null) {
47+
sketch.onActivityResult(requestCode, resultCode, data);
48+
}
49+
}
50+
51+
@Override
52+
public void onBackPressed() {
53+
if (sketch != null) {
54+
sketch.onBackPressed();
55+
if (sketch.handledBackPressed) return;
56+
}
57+
super.onBackPressed();
58+
}
59+
}

0 commit comments

Comments
 (0)