summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk6
-rw-r--r--res/drawable-nodpi/noise1.png (renamed from res/drawable-hdpi/noise1.png)bin20835 -> 20835 bytes
-rw-r--r--res/drawable-nodpi/noise2.png (renamed from res/drawable-hdpi/noise2.png)bin31765 -> 31765 bytes
-rw-r--r--res/drawable-nodpi/noise3.png (renamed from res/drawable-hdpi/noise3.png)bin39258 -> 39258 bytes
-rw-r--r--res/drawable-nodpi/noise4.png (renamed from res/drawable-hdpi/noise4.png)bin48490 -> 48490 bytes
-rw-r--r--res/drawable-nodpi/noise5.png (renamed from res/drawable-hdpi/noise5.png)bin46264 -> 46264 bytes
-rw-r--r--res/raw/pf4tex.glslf23
-rw-r--r--res/raw/pf5tex.glslf26
-rw-r--r--res/raw/pv4tex.glslv20
-rw-r--r--res/raw/pv5tex.glslv22
-rw-r--r--src/com/android/magicsmoke/MagicSmokeRS.java319
-rw-r--r--src/com/android/magicsmoke/RenderScriptScene.java17
-rw-r--r--src/com/android/magicsmoke/RenderScriptWallpaper.java34
-rw-r--r--src/com/android/magicsmoke/clouds.rs (renamed from res/raw/clouds.rs)339
14 files changed, 519 insertions, 287 deletions
diff --git a/Android.mk b/Android.mk
index 068ddb4..affd0a5 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,12 +14,14 @@
# limitations under the License.
#
+ifneq ($(TARGET_SIMULATOR),true)
+
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_SRC_FILES := $(call all-subdir-java-files) $(call all-renderscript-files-under, src)
LOCAL_PACKAGE_NAME := MagicSmokeWallpapers
LOCAL_CERTIFICATE := shared
@@ -27,3 +29,5 @@ LOCAL_CERTIFICATE := shared
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
include $(BUILD_PACKAGE)
+
+endif
diff --git a/res/drawable-hdpi/noise1.png b/res/drawable-nodpi/noise1.png
index fee1cf9..fee1cf9 100644
--- a/res/drawable-hdpi/noise1.png
+++ b/res/drawable-nodpi/noise1.png
Binary files differ
diff --git a/res/drawable-hdpi/noise2.png b/res/drawable-nodpi/noise2.png
index 0d13662..0d13662 100644
--- a/res/drawable-hdpi/noise2.png
+++ b/res/drawable-nodpi/noise2.png
Binary files differ
diff --git a/res/drawable-hdpi/noise3.png b/res/drawable-nodpi/noise3.png
index c9c610b..c9c610b 100644
--- a/res/drawable-hdpi/noise3.png
+++ b/res/drawable-nodpi/noise3.png
Binary files differ
diff --git a/res/drawable-hdpi/noise4.png b/res/drawable-nodpi/noise4.png
index 02261c9..02261c9 100644
--- a/res/drawable-hdpi/noise4.png
+++ b/res/drawable-nodpi/noise4.png
Binary files differ
diff --git a/res/drawable-hdpi/noise5.png b/res/drawable-nodpi/noise5.png
index 2f9a713..2f9a713 100644
--- a/res/drawable-hdpi/noise5.png
+++ b/res/drawable-nodpi/noise5.png
Binary files differ
diff --git a/res/raw/pf4tex.glslf b/res/raw/pf4tex.glslf
new file mode 100644
index 0000000..32810dc
--- /dev/null
+++ b/res/raw/pf4tex.glslf
@@ -0,0 +1,23 @@
+precision mediump float;
+
+varying vec2 varTex0;
+varying vec2 varTex1;
+varying vec2 varTex2;
+varying vec2 varTex3;
+
+void main() {
+ lowp vec4 tex = texture2D(UNI_Tex0, varTex0);
+ lowp vec4 col = mix(UNI_clearColor, tex.rgba, tex.a);
+
+ tex = texture2D(UNI_Tex1, varTex1);
+ col = mix(col, tex.rgba, tex.a);
+
+ tex = texture2D(UNI_Tex2, varTex2);
+ col = mix(col, tex.rgba, tex.a);
+
+ tex = texture2D(UNI_Tex3, varTex3);
+ col = mix(col, tex.rgba, tex.a);
+
+ gl_FragColor = col;
+}
+
diff --git a/res/raw/pf5tex.glslf b/res/raw/pf5tex.glslf
new file mode 100644
index 0000000..b1da1f6
--- /dev/null
+++ b/res/raw/pf5tex.glslf
@@ -0,0 +1,26 @@
+precision mediump float;
+
+varying vec2 varTex0;
+varying vec2 varTex1;
+varying vec2 varTex2;
+varying vec2 varTex3;
+varying vec2 varTex4;
+
+void main() {
+ lowp vec4 tex = texture2D(UNI_Tex0, varTex0);
+ lowp vec4 col = mix(UNI_clearColor, tex.rgba, tex.a);
+
+ tex = texture2D(UNI_Tex1, varTex1);
+ col = mix(col, tex.rgba, tex.a);
+
+ tex = texture2D(UNI_Tex2, varTex2);
+ col = mix(col, tex.rgba, tex.a);
+
+ tex = texture2D(UNI_Tex3, varTex3);
+ col = mix(col, tex.rgba, tex.a);
+
+ tex = texture2D(UNI_Tex4, varTex4);
+ col = mix(col, tex.rgba, tex.a);
+ gl_FragColor = col;
+}
+
diff --git a/res/raw/pv4tex.glslv b/res/raw/pv4tex.glslv
new file mode 100644
index 0000000..5634efe
--- /dev/null
+++ b/res/raw/pv4tex.glslv
@@ -0,0 +1,20 @@
+varying vec2 varTex0;
+varying vec2 varTex1;
+varying vec2 varTex2;
+varying vec2 varTex3;
+
+vec2 mul(vec4 uni, vec2 attr, float idx, vec2 offset)
+{
+ float invz = 0.35 + idx*0.05;
+ return vec2(
+ 0.5 + 0.5 * invz * (uni.z * ( uni.y * (attr.x + offset.x) + uni.x * (attr.y + offset.y))) + uni.w,
+ 0.5 + 0.5 * invz * (uni.z * (-uni.x * (attr.x + offset.x) + uni.y * (attr.y + offset.y))));
+}
+
+void main() {
+ varTex0 = mul(UNI_layer0, ATTRIB_position.xy, 1.0, UNI_panoffset);
+ varTex1 = mul(UNI_layer1, ATTRIB_position.xy, 2.0, UNI_panoffset);
+ varTex2 = mul(UNI_layer2, ATTRIB_position.xy, 3.0, UNI_panoffset);
+ varTex3 = mul(UNI_layer3, ATTRIB_position.xy, 4.0, UNI_panoffset);
+ gl_Position = ATTRIB_position;
+}
diff --git a/res/raw/pv5tex.glslv b/res/raw/pv5tex.glslv
new file mode 100644
index 0000000..bb190e8
--- /dev/null
+++ b/res/raw/pv5tex.glslv
@@ -0,0 +1,22 @@
+varying vec2 varTex0;
+varying vec2 varTex1;
+varying vec2 varTex2;
+varying vec2 varTex3;
+varying vec2 varTex4;
+
+vec2 mul(vec4 uni, vec2 attr, float idx, vec2 offset)
+{
+ float invz = 0.5 + idx*0.05;
+ return vec2(
+ 0.5 + 0.5 * invz * (uni.z * ( uni.y * (attr.x + offset.x) + uni.x * (attr.y + offset.y))) + uni.w,
+ 0.5 + 0.5 * invz * (uni.z * (-uni.x * (attr.x + offset.x) + uni.y * (attr.y + offset.y))));
+}
+
+void main() {
+ varTex0 = mul(UNI_layer0, ATTRIB_position.xy, 1.0, UNI_panoffset);
+ varTex1 = mul(UNI_layer1, ATTRIB_position.xy, 2.0, UNI_panoffset);
+ varTex2 = mul(UNI_layer2, ATTRIB_position.xy, 3.0, UNI_panoffset);
+ varTex3 = mul(UNI_layer3, ATTRIB_position.xy, 4.0, UNI_panoffset);
+ varTex4 = mul(UNI_layer4, ATTRIB_position.xy, 5.0, UNI_panoffset);
+ gl_Position = ATTRIB_position;
+}
diff --git a/src/com/android/magicsmoke/MagicSmokeRS.java b/src/com/android/magicsmoke/MagicSmokeRS.java
index f11b704..201aacd 100644
--- a/src/com/android/magicsmoke/MagicSmokeRS.java
+++ b/src/com/android/magicsmoke/MagicSmokeRS.java
@@ -29,22 +29,14 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaPlayer;
import android.os.Handler;
-import android.renderscript.Allocation;
-import android.renderscript.Dimension;
-import android.renderscript.Element;
-import android.renderscript.Primitive;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.renderscript.Sampler;
-import android.renderscript.ScriptC;
-import android.renderscript.SimpleMesh;
-import android.renderscript.Type;
+import android.renderscript.Mesh.Primitive;
+import android.renderscript.*;
import android.renderscript.Element.Builder;
import android.renderscript.ProgramStore.BlendDstFunc;
import android.renderscript.ProgramStore.BlendSrcFunc;
import android.util.Log;
import android.view.MotionEvent;
+import android.os.Bundle;
import java.util.TimeZone;
@@ -52,7 +44,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
static class WorldState {
public float mXOffset;
- public float mTilt;
+ public float mYOffset;
public int mPreset;
public int mTextureMask;
public int mRotate;
@@ -63,21 +55,26 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
public int mHighCol;
public float mAlphaMul;
public int mPreMul;
- public int mBlendFunc;
}
WorldState mWorldState = new WorldState();
- private Type mStateType;
- private Allocation mState;
+ //private Type mStateType;
+ //private Allocation mState;
- private ProgramStore mPfsBackgroundOne;
- private ProgramStore mPfsBackgroundSrc;
- private ProgramFragment mPfBackground;
- private Sampler mSampler;
+ private ProgramStore mPStore;
+ private ProgramFragment mPF5tex;
+ private ProgramFragment mPF4tex;
+ private Sampler[] mSampler;
private Allocation[] mSourceTextures;
private Allocation[] mRealTextures;
- private ProgramVertex mPVBackground;
- private ProgramVertex.MatrixAllocation mPVAlloc;
+ private ScriptC_clouds mScript;
+
+ private ScriptField_VertexShaderConstants_s mVSConst;
+ private ScriptField_FragmentShaderConstants_s mFSConst;
+
+ private ProgramVertex mPV5tex;
+ private ProgramVertex mPV4tex;
+ private ProgramVertexFixedFunction.Constants mPVAlloc;
private static final int RSID_STATE = 0;
//private static final int RSID_PROGRAMVERTEX = 3;
@@ -97,7 +94,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
static class Preset {
Preset(int processmode, int backcol, int locol, int hicol, float mul, int mask,
- boolean rot, int blend, boolean texswap, boolean premul) {
+ boolean rot, boolean texswap, boolean premul) {
mProcessTextureMode = processmode;
mBackColor = backcol;
mLowColor = locol;
@@ -105,7 +102,6 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
mAlphaMul = mul;
mTextureMask = mask;
mRotate = rot;
- mBlendFunc = blend;
mTextureSwap = texswap;
mPreMul = premul;
}
@@ -116,34 +112,33 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
public float mAlphaMul;
public int mTextureMask;
public boolean mRotate;
- public int mBlendFunc;
public boolean mTextureSwap;
public boolean mPreMul;
}
public static final int DEFAULT_PRESET = 4;
public static final Preset [] mPreset = new Preset[] {
- // proc back low high alph mask rot blend swap premul
- new Preset(1, 0x000000, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, false),
- new Preset(1, 0x0000ff, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, false),
- new Preset(1, 0x00ff00, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, false),
- new Preset(1, 0x00ff00, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, true),
- new Preset(1, 0x00ff00, 0x00ff00, 0xffffff, 2.5f, 0x1f, true, 0, true, true),
- new Preset(1, 0x800000, 0xff0000, 0xffffff, 2.5f, 0x1f, true, 0, true, false),
- new Preset(0, 0x000000, 0x000000, 0xffffff, 0.0f, 0x1f, true, 0, false, false),
- new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 2.0f, 0x1f, true, 0, true, false),
- new Preset(1, 0x008000, 0x00ff00, 0xffffff, 2.5f, 0x1f, true, 0, true, false),
- new Preset(1, 0x800000, 0xff0000, 0xffffff, 2.5f, 0x1f, true, 0, true, true),
- new Preset(1, 0x808080, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, true),
- new Preset(1, 0x0000ff, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, true),
- new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 1.5f, 0x1f, false, 0, false, true),
- new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 2.0f, 0x1f, true, 0, true, true),
- new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 1.5f, 0x1f, true, 0, true, true),
- new Preset(1, 0x808080, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, false),
- new Preset(1, 0x000000, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, true, false),
- new Preset(2, 0x000000, 0x000070, 0xff2020, 2.5f, 0x1f, true, 0, false, false),
- new Preset(2, 0x6060ff, 0x000070, 0xffffff, 2.5f, 0x1f, true, 0, false, false),
- new Preset(3, 0x0000f0, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, true, false),
+ // proc back low high alph mask rot swap premul
+ new Preset(1, 0x000000, 0x000000, 0xffffff, 2.0f, 0x0f, true, false, false),
+ new Preset(1, 0x0000ff, 0x000000, 0xffffff, 2.0f, 0x0f, true, false, false),
+ new Preset(1, 0x00ff00, 0x000000, 0xffffff, 2.0f, 0x0f, true, false, false),
+ new Preset(1, 0x00ff00, 0x000000, 0xffffff, 2.0f, 0x0f, true, false, true),
+ new Preset(1, 0x00ff00, 0x00ff00, 0xffffff, 2.5f, 0x1f, true, true, true),
+ new Preset(1, 0x800000, 0xff0000, 0xffffff, 2.5f, 0x1f, true, true, false),
+ new Preset(0, 0x000000, 0x000000, 0xffffff, 0.0f, 0x1f, true, false, false),
+ new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 2.0f, 0x1f, true, true, false),
+ new Preset(1, 0x008000, 0x00ff00, 0xffffff, 2.5f, 0x1f, true, true, false),
+ new Preset(1, 0x800000, 0xff0000, 0xffffff, 2.5f, 0x1f, true, true, true),
+ new Preset(1, 0x808080, 0x000000, 0xffffff, 2.0f, 0x0f, true, false, true),
+ new Preset(1, 0x0000ff, 0x000000, 0xffffff, 2.0f, 0x0f, true, false, true),
+ new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 1.5f, 0x1f, false, false, true),
+ new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 2.0f, 0x1f, true, true, true),
+ new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 1.5f, 0x1f, true, true, true),
+ new Preset(1, 0x808080, 0x000000, 0xffffff, 2.0f, 0x0f, true, false, false),
+ new Preset(1, 0x000000, 0x000000, 0xffffff, 2.0f, 0x0f, true, true, false),
+ new Preset(2, 0x000000, 0x000070, 0xff2020, 2.5f, 0x1f, true, false, false),
+ new Preset(2, 0x6060ff, 0x000070, 0xffffff, 2.5f, 0x1f, true, false, false),
+ new Preset(3, 0x0000f0, 0x000000, 0xffffff, 2.0f, 0x0f, true, true, false),
};
private float mTouchY;
@@ -152,7 +147,6 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
super(width, height);
mWidth = width;
mHeight = height;
- mWorldState.mTilt = 0;
mContext = context;
mSharedPref = mContext.getSharedPreferences("magicsmoke", Context.MODE_PRIVATE);
makeNewState();
@@ -161,7 +155,6 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
makeNewState();
- mState.data(mWorldState);
}
void makeNewState() {
@@ -179,18 +172,42 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
mWorldState.mHighCol = mPreset[p].mHighColor;
mWorldState.mAlphaMul = mPreset[p].mAlphaMul;
mWorldState.mPreMul = mPreset[p].mPreMul ? 1 : 0;
- mWorldState.mBlendFunc = mPreset[p].mBlendFunc;
+
+ if(mScript != null) {
+ mScript.set_gPreset(mWorldState.mPreset);
+ mScript.set_gTextureMask(mWorldState.mTextureMask);
+ mScript.set_gRotate(mWorldState.mRotate);
+ mScript.set_gTextureSwap(mWorldState.mTextureSwap);
+ mScript.set_gProcessTextureMode(mWorldState.mProcessTextureMode);
+ mScript.set_gBackCol(mWorldState.mBackCol);
+ mScript.set_gLowCol(mWorldState.mLowCol);
+ mScript.set_gHighCol(mWorldState.mHighCol);
+ mScript.set_gAlphaMul(mWorldState.mAlphaMul);
+ mScript.set_gPreMul(mWorldState.mPreMul);
+ }
}
@Override
public void resize(int width, int height) {
super.resize(width, height);
if (mPVAlloc != null) {
- mPVAlloc.setupProjectionNormalized(width, height);
+ Matrix4f proj = new Matrix4f();
+ proj.loadProjectionNormalized(width, height);
+ mPVAlloc.setProjection(proj);
}
}
@Override
+ public Bundle onCommand(String action, int x, int y, int z, Bundle extras,
+ boolean resultRequested) {
+
+ if ("android.wallpaper.tap".equals(action)) {
+ mTouchY = y;
+ }
+ return null;
+ }
+
+ /*@Override
public void onTouchEvent(MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
@@ -200,23 +217,22 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
float dy = event.getY() - mTouchY;
mTouchY += dy;
dy /= 20;
- dy += mWorldState.mTilt;
if (dy > 4) {
dy = 4;
} else if (dy < -4) {
dy = -4;
}
- mWorldState.mTilt = dy;
- mState.data(mWorldState);
+ //mState.data(mWorldState);
}
- }
+ }*/
@Override
- public void setOffset(float xOffset, float yOffset, float xStep, float yStep,
- int xPixels, int yPixels) {
+ public void setOffset(float xOffset, float yOffset, float xStep, float yStep, int xPixels, int yPixels) {
// update our state, then push it to the renderscript
mWorldState.mXOffset = xOffset;
- mState.data(mWorldState);
+ mWorldState.mYOffset = yOffset;
+ mScript.set_gXOffset(mWorldState.mXOffset);
+ mScript.set_gYOffset(mWorldState.mYOffset);
}
@Override
@@ -230,7 +246,6 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
super.start();
mSharedPref.registerOnSharedPreferenceChangeListener(this);
makeNewState();
- mState.data(mWorldState);
}
float alphafactor;
@@ -241,13 +256,27 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap in = BitmapFactory.decodeResource(mResources, id, opts);
+ // Bitmaps are stored in memory in premultiplied form. We want non-premultiplied,
+ // which is what getPixels gives us.
int pixels[] = new int[65536];
in.getPixels(pixels, 0, 256, 0, 0, 256, 256);
- mRealTextures[index] = Allocation.createTyped(mRS, mTextureType);
- mSourceTextures[index] = Allocation.createTyped(mRS, mTextureType);
- mSourceTextures[index].setName(name+"_src");
- mSourceTextures[index].data(pixels);
- mRealTextures[index].setName(name);
+ mRealTextures[index] = Allocation.createTyped(mRS, mTextureType,
+ Allocation.MipmapControl.MIPMAP_NONE,
+ Allocation.USAGE_SCRIPT |
+ Allocation.USAGE_GRAPHICS_TEXTURE);
+ mSourceTextures[index] = Allocation.createTyped(mRS, mTextureType,
+ Allocation.MipmapControl.MIPMAP_NONE,
+ Allocation.USAGE_SCRIPT);
+
+ // copyFrom needs a byte[], not an int[], so we need to copy the data first
+ byte bpixels[] = new byte[65536*4];
+ for (int i = 0; i < 65536; i++) {
+ bpixels[i * 4 + 0] = (byte)(pixels[i] & 0xff);
+ bpixels[i * 4 + 1] = (byte)((pixels[i] >> 8) & 0xff);
+ bpixels[i * 4 + 2] = (byte)((pixels[i] >>16) & 0xff);
+ bpixels[i * 4 + 3] = (byte)((pixels[i] >> 24) & 0xff);
+ }
+ mSourceTextures[index].copyFrom(bpixels);
in.recycle();
}
@@ -265,101 +294,123 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
loadBitmap(R.drawable.noise3, 2, "Tnoise3", alphamul, lowcol, highcol);
loadBitmap(R.drawable.noise4, 3, "Tnoise4", alphamul, lowcol, highcol);
loadBitmap(R.drawable.noise5, 4, "Tnoise5", alphamul, lowcol, highcol);
+
+ mScript.set_gTnoise1(mRealTextures[0]);
+ mScript.set_gTnoise2(mRealTextures[1]);
+ mScript.set_gTnoise3(mRealTextures[2]);
+ mScript.set_gTnoise4(mRealTextures[3]);
+ mScript.set_gTnoise5(mRealTextures[4]);
+
+ mScript.bind_gNoisesrc1(mSourceTextures[0]);
+ mScript.bind_gNoisesrc2(mSourceTextures[1]);
+ mScript.bind_gNoisesrc3(mSourceTextures[2]);
+ mScript.bind_gNoisesrc4(mSourceTextures[3]);
+ mScript.bind_gNoisesrc5(mSourceTextures[4]);
+
+ mScript.bind_gNoisedst1(mRealTextures[0]);
+ mScript.bind_gNoisedst2(mRealTextures[1]);
+ mScript.bind_gNoisedst3(mRealTextures[2]);
+ mScript.bind_gNoisedst4(mRealTextures[3]);
+ mScript.bind_gNoisedst5(mRealTextures[4]);
}
@Override
protected ScriptC createScript() {
- // Create a renderscript type from a java class. The specified name doesn't
- // really matter; the name by which we refer to the object in RenderScript
- // will be specified later.
- mStateType = Type.createFromClass(mRS, WorldState.class, 1, "WorldState");
- // Create an allocation from the type we just created.
- mState = Allocation.createTyped(mRS, mStateType);
- mState.data(mWorldState);
-
- // First set up the coordinate system and such
- ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null);
- mPVBackground = pvb.create();
- mPVBackground.setName("PVBackground");
- mPVAlloc = new ProgramVertex.MatrixAllocation(mRS);
- mPVBackground.bindAllocation(mPVAlloc);
- mPVAlloc.setupProjectionNormalized(mWidth, mHeight);
+ mScript = new ScriptC_clouds(mRS, mResources, R.raw.clouds);
+
+ mVSConst = new ScriptField_VertexShaderConstants_s(mRS, 1);
+ mScript.bind_gVSConstants(mVSConst);
+
+ {
+ ProgramVertex.Builder builder = new ProgramVertex.Builder(mRS);
+ builder.setShader(mResources, R.raw.pv5tex);
+ builder.addConstant(mVSConst.getAllocation().getType());
+ builder.addInput(ScriptField_VertexInputs_s.createElement(mRS));
+
+ mPV5tex = builder.create();
+ mPV5tex.bindConstants(mVSConst.getAllocation(), 0);
+
+ builder.setShader(mResources, R.raw.pv4tex);
+ mPV4tex = builder.create();
+ mPV4tex.bindConstants(mVSConst.getAllocation(), 0);
+ }
+ mScript.set_gPV5tex(mPV5tex);
+ mScript.set_gPV4tex(mPV4tex);
mSourceTextures = new Allocation[5];
mRealTextures = new Allocation[5];
Type.Builder tb = new Type.Builder(mRS, Element.RGBA_8888(mRS));
- tb.add(Dimension.X, 256);
- tb.add(Dimension.Y, 256);
+ tb.setX(256);
+ tb.setY(256);
mTextureType = tb.create();
loadBitmaps();
Sampler.Builder samplerBuilder = new Sampler.Builder(mRS);
- samplerBuilder.setMin(LINEAR);
- samplerBuilder.setMag(LINEAR);
+ samplerBuilder.setMinification(LINEAR);
+ samplerBuilder.setMagnification(LINEAR);
samplerBuilder.setWrapS(WRAP);
samplerBuilder.setWrapT(WRAP);
- mSampler = samplerBuilder.create();
+ mSampler = new Sampler[5];
+ for (int i = 0; i < 5; i++)
+ mSampler[i] = samplerBuilder.create();
{
+ mFSConst = new ScriptField_FragmentShaderConstants_s(mRS, 1);
+ mScript.bind_gFSConstants(mFSConst);
+
ProgramFragment.Builder builder = new ProgramFragment.Builder(mRS);
- builder.setTexture(ProgramFragment.Builder.EnvMode.REPLACE,
- ProgramFragment.Builder.Format.RGBA, 0);
- mPfBackground = builder.create();
- mPfBackground.setName("PFBackground");
- mPfBackground.bindSampler(mSampler, 0);
+ builder.setShader(mResources, R.raw.pf5tex);
+ for (int texCount = 0; texCount < 5; texCount ++) {
+ builder.addTexture(Program.TextureType.TEXTURE_2D);
+ }
+ builder.addConstant(mFSConst.getAllocation().getType());
+
+ mPF5tex = builder.create();
+ for (int i = 0; i < 5; i++)
+ mPF5tex.bindSampler(mSampler[i], i);
+ mPF5tex.bindConstants(mFSConst.getAllocation(), 0);
+
+ builder = new ProgramFragment.Builder(mRS);
+ builder.setShader(mResources, R.raw.pf4tex);
+ for (int texCount = 0; texCount < 4; texCount ++) {
+ builder.addTexture(Program.TextureType.TEXTURE_2D);
+ }
+ builder.addConstant(mFSConst.getAllocation().getType());
+ mPF4tex = builder.create();
+ for (int i = 0; i < 4; i++)
+ mPF4tex.bindSampler(mSampler[i], i);
+ mPF4tex.bindConstants(mFSConst.getAllocation(), 0);
}
+ mScript.set_gPF5tex(mPF5tex);
+ mScript.set_gPF4tex(mPF4tex);
+
+
{
- ProgramStore.Builder builder = new ProgramStore.Builder(mRS, null, null);
- builder.setDepthFunc(ProgramStore.DepthFunc.EQUAL);
- builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ONE_MINUS_SRC_ALPHA);
- builder.setDitherEnable(true); // without dithering there is severe banding
- builder.setDepthMask(false);
- mPfsBackgroundOne = builder.create();
- mPfsBackgroundOne.setName("PFSBackgroundOne");
- builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA);
- mPfsBackgroundSrc = builder.create();
- mPfsBackgroundSrc.setName("PFSBackgroundSrc");
+ ProgramStore.Builder builder = new ProgramStore.Builder(mRS);
+ builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
+ builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO);
+ builder.setDitherEnabled(true); // without dithering there is severe banding
+ builder.setDepthMaskEnabled(false);
+ mPStore = builder.create();
}
- // Time to create the script
- ScriptC.Builder sb = new ScriptC.Builder(mRS);
- // Specify the name by which to refer to the WorldState object in the
- // renderscript.
- sb.setType(mStateType, "State", RSID_STATE);
- sb.setType(mTextureType, "noisesrc1", RSID_NOISESRC1);
- sb.setType(mTextureType, "noisedst1", RSID_NOISEDST1);
- sb.setType(mTextureType, "noisesrc2", RSID_NOISESRC2);
- sb.setType(mTextureType, "noisedst2", RSID_NOISEDST2);
- sb.setType(mTextureType, "noisesrc3", RSID_NOISESRC3);
- sb.setType(mTextureType, "noisedst3", RSID_NOISEDST3);
- sb.setType(mTextureType, "noisesrc4", RSID_NOISESRC4);
- sb.setType(mTextureType, "noisedst4", RSID_NOISEDST4);
- sb.setType(mTextureType, "noisesrc5", RSID_NOISESRC5);
- sb.setType(mTextureType, "noisedst5", RSID_NOISEDST5);
- sb.setScript(mResources, R.raw.clouds);
- sb.setRoot(true);
-
- ScriptC script = sb.create();
- script.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- script.setTimeZone(TimeZone.getDefault().getID());
-
- script.bindAllocation(mState, RSID_STATE);
- script.bindAllocation(mSourceTextures[0], RSID_NOISESRC1);
- script.bindAllocation(mRealTextures[0], RSID_NOISEDST1);
- script.bindAllocation(mSourceTextures[1], RSID_NOISESRC2);
- script.bindAllocation(mRealTextures[1], RSID_NOISEDST2);
- script.bindAllocation(mSourceTextures[2], RSID_NOISESRC3);
- script.bindAllocation(mRealTextures[2], RSID_NOISEDST3);
- script.bindAllocation(mSourceTextures[3], RSID_NOISESRC4);
- script.bindAllocation(mRealTextures[3], RSID_NOISEDST4);
- script.bindAllocation(mSourceTextures[4], RSID_NOISESRC5);
- script.bindAllocation(mRealTextures[4], RSID_NOISEDST5);
- //script.bindAllocation(mPVAlloc.mAlloc, RSID_PROGRAMVERTEX);
-
-
- return script;
+ mScript.set_gPStore(mPStore);
+
+ mScript.set_gPreset(mWorldState.mPreset);
+ mScript.set_gTextureMask(mWorldState.mTextureMask);
+ mScript.set_gRotate(mWorldState.mRotate);
+ mScript.set_gTextureSwap(mWorldState.mTextureSwap);
+ mScript.set_gProcessTextureMode(mWorldState.mProcessTextureMode);
+ mScript.set_gBackCol(mWorldState.mBackCol);
+ mScript.set_gLowCol(mWorldState.mLowCol);
+ mScript.set_gHighCol(mWorldState.mHighCol);
+ mScript.set_gAlphaMul(mWorldState.mAlphaMul);
+ mScript.set_gPreMul(mWorldState.mPreMul);
+ mScript.set_gXOffset(mWorldState.mXOffset);
+
+ return mScript;
}
}
diff --git a/src/com/android/magicsmoke/RenderScriptScene.java b/src/com/android/magicsmoke/RenderScriptScene.java
index 8a5e213..fdf4935 100644
--- a/src/com/android/magicsmoke/RenderScriptScene.java
+++ b/src/com/android/magicsmoke/RenderScriptScene.java
@@ -18,9 +18,10 @@
package com.android.magicsmoke;
import android.content.res.Resources;
+import android.os.Bundle;
import android.renderscript.RenderScriptGL;
import android.renderscript.ScriptC;
-import android.view.MotionEvent;
+//import android.view.MotionEvent;
public abstract class RenderScriptScene {
protected int mWidth;
@@ -69,11 +70,11 @@ public abstract class RenderScriptScene {
protected abstract ScriptC createScript();
public void stop() {
- mRS.contextBindRootScript(null);
+ mRS.bindRootScript(null);
}
public void start() {
- mRS.contextBindRootScript(mScript);
+ mRS.bindRootScript(mScript);
}
public void resize(int width, int height) {
@@ -82,10 +83,12 @@ public abstract class RenderScriptScene {
}
@SuppressWarnings({"UnusedDeclaration"})
- public void setOffset(float xOffset, float yOffset,
- float xStep, float yStep, int xPixels, int yPixels) {
- }
- public void onTouchEvent(MotionEvent event) {
+ public void setOffset(float xOffset, float yOffset, float xStep, float yStep, int xPixels, int yPixels) {
}
+ @SuppressWarnings({"UnusedDeclaration"})
+ public Bundle onCommand(String action, int x, int y, int z, Bundle extras,
+ boolean resultRequested) {
+ return null;
+ }
}
diff --git a/src/com/android/magicsmoke/RenderScriptWallpaper.java b/src/com/android/magicsmoke/RenderScriptWallpaper.java
index b4359e2..c9bbdd9 100644
--- a/src/com/android/magicsmoke/RenderScriptWallpaper.java
+++ b/src/com/android/magicsmoke/RenderScriptWallpaper.java
@@ -18,6 +18,7 @@
package com.android.magicsmoke;
import android.service.wallpaper.WallpaperService;
+import android.os.Bundle;
import android.graphics.PixelFormat;
import android.renderscript.RenderScriptGL;
import android.renderscript.RenderScript;
@@ -40,9 +41,9 @@ public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends
@Override
public void onCreate(SurfaceHolder surfaceHolder) {
super.onCreate(surfaceHolder);
- setTouchEventsEnabled(true);
+ setTouchEventsEnabled(false);
surfaceHolder.setSizeFromLayout();
- surfaceHolder.setFormat(PixelFormat.RGBX_8888);
+ surfaceHolder.setFormat(PixelFormat.RGB_565);
}
@Override
@@ -78,7 +79,7 @@ public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
super.onSurfaceChanged(holder, format, width, height);
if (mRs != null) {
- mRs.contextSetSurface(width, height, holder.getSurface());
+ mRs.setSurface(holder, width, height);
}
if (mRenderer == null) {
mRenderer = createScene(width, height);
@@ -90,30 +91,18 @@ public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends
}
@Override
- public void onTouchEvent(MotionEvent event) {
- if (mRenderer != null) {
- mRenderer.onTouchEvent(event);
- }
- }
-
- @Override
public void onOffsetsChanged(float xOffset, float yOffset,
float xStep, float yStep, int xPixels, int yPixels) {
- if (mRenderer != null) {
- mRenderer.setOffset(xOffset, yOffset, xStep, yStep, xPixels, yPixels);
- }
+ mRenderer.setOffset(xOffset, yOffset, xStep, yStep, xPixels, yPixels);
}
@Override
public void onSurfaceCreated(SurfaceHolder holder) {
super.onSurfaceCreated(holder);
- Surface surface = null;
- while (surface == null) {
- surface = holder.getSurface();
- }
- mRs = new RenderScriptGL(false, false);
- mRs.contextSetPriority(RenderScript.Priority.LOW);
+ RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
+ mRs = new RenderScriptGL(RenderScriptWallpaper.this, sc);
+ mRs.setPriority(RenderScript.Priority.LOW);
}
@Override
@@ -121,5 +110,12 @@ public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends
super.onSurfaceDestroyed(holder);
destroyRenderer();
}
+
+ @Override
+ public Bundle onCommand(String action, int x, int y, int z,
+ Bundle extras, boolean resultRequested) {
+ return mRenderer.onCommand(action, x, y, z, extras, resultRequested);
+ }
+
}
}
diff --git a/res/raw/clouds.rs b/src/com/android/magicsmoke/clouds.rs
index a1f3b18..b0d55bf 100644
--- a/res/raw/clouds.rs
+++ b/src/com/android/magicsmoke/clouds.rs
@@ -13,9 +13,10 @@
// limitations under the License.
#pragma version(1)
-#pragma stateVertex(PVBackground)
-#pragma stateRaster(parent)
-#pragma stateFragment(PFBackground)
+
+#pragma rs java_package_name(com.android.magicsmoke)
+
+#include "rs_graphics.rsh"
#define RSID_NOISESRC1 1
#define RSID_NOISESRC2 2
@@ -28,95 +29,206 @@
#define RSID_NOISEDST4 9
#define RSID_NOISEDST5 10
-float xshift[5];
-float rotation[5];
-float scale[5];
-float alphafactor;
-int currentpreset;
-int lastuptime;
-float timedelta;
-
-void drawCloud(float *ident, int id, int idx) {
- float mat1[16];
- float z = -8.f * idx;
- matrixLoadMat(mat1,ident);
- matrixTranslate(mat1, -State->mXOffset * 8.f * idx, -State->mTilt * idx / 3.f, 0.f);
- matrixRotate(mat1, rotation[idx], 0.f, 0.f, 1.f);
- vpLoadModelMatrix(mat1);
-
- bindTexture(NAMED_PFBackground, 0, id);
- drawQuadTexCoords(
- -1200.0f, -1200.0f, z, // space
- 0.f + xshift[idx], 0.f, // texture
- 1200, -1200.0f, z, // space
- scale[idx] + xshift[idx], 0.f, // texture
- 1200, 1200.0f, z, // space
- scale[idx] + xshift[idx], scale[idx], // texture
- -1200.0f, 1200.0f, z, // space
- 0.f + xshift[idx], scale[idx]); // texture
+// State set from java
+float gXOffset;
+float gYOffset;
+int gPreset;
+int gTextureMask;
+int gRotate;
+int gTextureSwap;
+int gProcessTextureMode;
+int gBackCol;
+int gLowCol;
+int gHighCol;
+float gAlphaMul;
+int gPreMul;
+
+typedef struct VertexShaderConstants_s {
+ float4 layer0;
+ float4 layer1;
+ float4 layer2;
+ float4 layer3;
+ float4 layer4;
+ float2 panoffset;
+} VertexShaderConstants;
+VertexShaderConstants *gVSConstants;
+
+typedef struct FragmentShaderConstants_s {
+ float4 clearColor;
+} FragmentShaderConstants;
+FragmentShaderConstants *gFSConstants;
+
+typedef struct VertexInputs_s {
+ float4 position;
+ float2 texture0;
+} VertexInputs;
+VertexInputs *gVS;
+
+
+rs_program_fragment gPF5tex;
+rs_program_vertex gPV5tex;
+rs_program_fragment gPF4tex;
+rs_program_vertex gPV4tex;
+
+rs_program_store gPStore;
+
+rs_allocation gTnoise1;
+rs_allocation gTnoise2;
+rs_allocation gTnoise3;
+rs_allocation gTnoise4;
+rs_allocation gTnoise5;
+
+int *gNoisesrc1;
+int *gNoisesrc2;
+int *gNoisesrc3;
+int *gNoisesrc4;
+int *gNoisesrc5;
+
+int *gNoisedst1;
+int *gNoisedst2;
+int *gNoisedst3;
+int *gNoisedst4;
+int *gNoisedst5;
+
+// Local script variables
+static float xshift[5];
+static float rotation[5];
+static float scale[5];
+static float alphafactor;
+static int currentpreset;
+static int lastuptime;
+static float timedelta;
+static float4 clearColor = {0.5f, 0.0f, 0.0f, 1.0f};
+static int countTextures()
+{
+ int pos = 0;
+ for (int i = 0; i < 5; i++)
+ {
+ if (gTextureMask & (1<<i))
+ pos++;
+ }
+ return pos;
+}
+#define rotate(s, a) \
+do { \
+ float __agl = (3.1415927f / 180.0f) * a; \
+ s.x = sin(__agl); \
+ s.y = cos(__agl); \
+} while (0)
+
+static void update()
+{
+ rs_program_vertex pv;
+ rsSetObject(&pv, gPV5tex);
+ rs_program_fragment pf;
+ rsSetObject(&pf, gPF5tex);
+
+ if (countTextures() == 4)
+ {
+ rsSetObject(&pv, gPV4tex);
+ rsSetObject(&pf, gPF4tex);
+ }
+ rsgBindProgramFragment(pf);
+ rsgBindProgramVertex(pv);
+ rsgBindProgramStore(gPStore);
+
+ rotate(gVSConstants->layer0, rotation[0]);
+ rotate(gVSConstants->layer1, rotation[1]);
+ rotate(gVSConstants->layer2, rotation[2]);
+ rotate(gVSConstants->layer3, rotation[3]);
+ rotate(gVSConstants->layer4, rotation[4]);
+
+ gVSConstants->layer0.w = xshift[0];
+ gVSConstants->layer1.w = xshift[1];
+ gVSConstants->layer2.w = xshift[2];
+ gVSConstants->layer3.w = xshift[3];
+ gVSConstants->layer4.w = xshift[4];
+
+ float m = 0.35f;
+ gVSConstants->layer0.z = m * scale[0];
+ gVSConstants->layer1.z = m * scale[1];
+ gVSConstants->layer2.z = m * scale[2];
+ gVSConstants->layer3.z = m * scale[3];
+ gVSConstants->layer4.z = m * scale[4];
+
+ gVSConstants->panoffset.x = gXOffset;
+ gVSConstants->panoffset.y = -gYOffset;
+
+ gFSConstants->clearColor = clearColor;
+
+ int pos = 0;
+ for (int i = 0; i < 5; i++)
+ {
+ if (gTextureMask & (1<<i))
+ {
+ switch (i)
+ {
+ case 0: rsgBindTexture(pf, pos, gTextureSwap != 0 ? gTnoise5 : gTnoise1); break;
+ case 1: rsgBindTexture(pf, pos, gTnoise2); break;
+ case 2: rsgBindTexture(pf, pos, gTnoise3); break;
+ case 3: rsgBindTexture(pf, pos, gTnoise4); break;
+ case 4: rsgBindTexture(pf, pos, gTnoise5); break;
+ default: break;
+ }
+ pos++;
+ }
+ }
}
-void drawClouds(float* ident) {
-
- int i;
-
- float mat1[16];
-
- matrixLoadMat(mat1,ident);
-
- if (State->mRotate != 0) {
- rotation[0] += 0.10 * timedelta;
+static void drawClouds() {
+ if (gRotate != 0)
+ {
+ rotation[0] += 0.100f * timedelta;
rotation[1] += 0.102f * timedelta;
rotation[2] += 0.106f * timedelta;
rotation[3] += 0.114f * timedelta;
rotation[4] += 0.123f * timedelta;
}
- int mask = State->mTextureMask;
+ int mask = gTextureMask;
if (mask & 1) {
- xshift[0] += 0.0010f * timedelta;
- if (State->mTextureSwap != 0) {
- drawCloud(mat1, NAMED_Tnoise5, 0);
- } else {
- drawCloud(mat1, NAMED_Tnoise1, 0);
- }
+ xshift[0] += 0.00100f * timedelta;
}
-
if (mask & 2) {
- xshift[1] += 0.00106 * timedelta;
- drawCloud(mat1, NAMED_Tnoise2, 1);
+ xshift[1] += 0.00106f * timedelta;
}
-
if (mask & 4) {
xshift[2] += 0.00114f * timedelta;
- drawCloud(mat1, NAMED_Tnoise3, 2);
}
-
if (mask & 8) {
xshift[3] += 0.00118f * timedelta;
- drawCloud(mat1, NAMED_Tnoise4, 3);
}
-
if (mask & 16) {
xshift[4] += 0.00127f * timedelta;
- drawCloud(mat1, NAMED_Tnoise5, 4);
}
+ update();
+
+ float z = 0;
+ rsgDrawQuad(
+ -1.0f, -1.0f, z,
+ 1.0f, -1.0f, z,
+ 1.0f, 1.0f, z,
+ -1.0f, 1.0f, z
+ );
+
// Make sure the texture coordinates don't continuously increase
+ int i;
for(i = 0; i < 5; i++) {
- while (xshift[i] >= 1.f) {
- xshift[i] -= 1.f;
+ if (xshift[i] > 1.f) {
+ xshift[i] -= floor(xshift[i]);
}
}
// Make sure the rotation angles don't continuously increase
for(i = 0; i < 5; i++) {
- while (rotation[i] >= 360.f) {
- rotation[i] -= 360.f;
+ if (rotation[i] > 360.f) {
+ float multiplier = floor(rotation[i]/360.f);
+ rotation[i] -= 360.f * multiplier;
}
}
}
-int premul(int rgb, int a) {
+static int premul(int rgb, int a) {
int r = (rgb >> 16) * a + 1;
r = (r + (r >> 8)) >> 8;
int g = ((rgb >> 8) & 0xff) * a + 1;
@@ -126,18 +238,19 @@ int premul(int rgb, int a) {
return r << 16 | g << 8 | b;
}
-void makeTexture(int *src, int *dst, int rsid) {
-
+
+static void makeTexture(int *src, int *dst, rs_allocation rsid) {
+
int x;
int y;
- int pm = State->mPreMul;
+ int pm = gPreMul;
+
+ if (gProcessTextureMode == 1) {
+ int lowcol = gLowCol;
+ int highcol = gHighCol;
- if (State->mProcessTextureMode == 1) {
- int lowcol = State->mLowCol;
- int highcol = State->mHighCol;
-
for (y=0;y<256;y++) {
- for (x=0;x<256;x++) {
+ for (x=0;x<256;x++) {
int pix = src[y*256+x];
int lum = pix & 0x00ff;
int newpix;
@@ -159,14 +272,14 @@ void makeTexture(int *src, int *dst, int rsid) {
dst[y*256+x] = newpix;
}
}
- alphafactor *= State->mAlphaMul;
- } else if (State->mProcessTextureMode == 2) {
- int lowcol = State->mLowCol;
- int highcol = State->mHighCol;
+ alphafactor *= gAlphaMul;
+ } else if (gProcessTextureMode == 2) {
+ int lowcol = gLowCol;
+ int highcol = gHighCol;
float scale = 255.f / (255.f - lowcol);
-
+
for (y=0;y<256;y++) {
- for (x=0;x<256;x++) {
+ for (x=0;x<256;x++) {
int pix = src[y*256+x];
int alpha = pix & 0x00ff;
if (alpha < lowcol) {
@@ -183,14 +296,14 @@ void makeTexture(int *src, int *dst, int rsid) {
dst[y*256+x] = newpix;
}
}
- alphafactor *= State->mAlphaMul;
- } else if (State->mProcessTextureMode == 3) {
- int lowcol = State->mLowCol;
- int highcol = State->mHighCol;
+ alphafactor *= gAlphaMul;
+ } else if (gProcessTextureMode == 3) {
+ int lowcol = gLowCol;
+ int highcol = gHighCol;
float scale = 255.f / (255.f - lowcol);
-
+
for (y=0;y<256;y++) {
- for (x=0;x<256;x++) {
+ for (x=0;x<256;x++) {
int pix = src[y*256+x];
int lum = pix & 0x00ff;
int newpix;
@@ -214,9 +327,8 @@ void makeTexture(int *src, int *dst, int rsid) {
dst[y*256+x] = newpix;
}
}
- alphafactor *= State->mAlphaMul;
+ alphafactor *= gAlphaMul;
} else {
-
for (y=0;y<256;y++) {
for (x=0;x<256;x++) {
int rgb = *src++;
@@ -229,33 +341,25 @@ void makeTexture(int *src, int *dst, int rsid) {
}
}
}
- uploadToTexture(rsid, 0);
+
+ rsgAllocationSyncAll(rsid);
}
-void makeTextures() {
- debugI32("makeTextures", State->mPreset);
+static void makeTextures() {
alphafactor = 1.f;
- makeTexture((int*)noisesrc1, (int*)noisedst1, NAMED_Tnoise1);
- makeTexture((int*)noisesrc2, (int*)noisedst2, NAMED_Tnoise2);
- makeTexture((int*)noisesrc3, (int*)noisedst3, NAMED_Tnoise3);
- makeTexture((int*)noisesrc4, (int*)noisedst4, NAMED_Tnoise4);
- makeTexture((int*)noisesrc5, (int*)noisedst5, NAMED_Tnoise5);
+ makeTexture((int*)gNoisesrc1, (int*)gNoisedst1, gTnoise1);
+ makeTexture((int*)gNoisesrc2, (int*)gNoisedst2, gTnoise2);
+ makeTexture((int*)gNoisesrc3, (int*)gNoisedst3, gTnoise3);
+ makeTexture((int*)gNoisesrc4, (int*)gNoisedst4, gTnoise4);
+ makeTexture((int*)gNoisesrc5, (int*)gNoisedst5, gTnoise5);
}
-
-
-struct color {
- float r;
- float g;
- float b;
-};
-
void init() {
- int i;
- for (i=0;i<4;i++) {
+ for (int i=0;i<5;i++) {
xshift[i] = 0.f;
rotation[i] = 360.f * i / 5.f;
}
+
scale[0] = 4.0f; // changed below based on preset
scale[1] = 3.0f;
scale[2] = 3.4f;
@@ -263,29 +367,15 @@ void init() {
scale[4] = 4.2f;
currentpreset = -1;
- lastuptime = uptimeMillis();
+ lastuptime = (int)rsUptimeMillis();
timedelta = 0;
}
-int main(int launchID) {
-
+int root(int launchID) {
int i;
- float ident[16];
- float masterscale = 0.0041f;// / (State->mXOffset * 4.f + 1.f);
- matrixLoadIdentity(ident);
- matrixTranslate(ident, -State->mXOffset, 0.f, 0.f);
- matrixScale(ident, masterscale, masterscale, masterscale);
- //matrixRotate(ident, 0.f, 0.f, 0.f, 1.f);
- matrixRotate(ident, -State->mTilt, 1.f, 0.f, 0.f);
-
- if (State->mBlendFunc) {
- bindProgramStore(NAMED_PFSBackgroundOne);
- } else {
- bindProgramStore(NAMED_PFSBackgroundSrc);
- }
- int now = uptimeMillis();
+ int now = (int)rsUptimeMillis();
timedelta = ((float)(now - lastuptime)) / 44.f;
lastuptime = now;
if (timedelta > 3) {
@@ -294,24 +384,21 @@ int main(int launchID) {
timedelta = 3;
}
- i = State->mPreset;
+ i = gPreset;
if (i != currentpreset) {
currentpreset = i;
- int rgb = State->mBackCol;
- pfClearColor(
- ((float)((rgb >> 16) & 0xff)) / 255.0f,
- ((float)((rgb >> 8) & 0xff)) / 255.0f,
- ((float)(rgb & 0xff)) / 255.0f,
- 1.0f);
+ clearColor.x = ((float)((gBackCol >> 16) & 0xff)) / 255.0f;
+ clearColor.y = ((float)((gBackCol >> 8) & 0xff)) / 255.0f;
+ clearColor.z = ((float)(gBackCol & 0xff)) / 255.0f;
makeTextures();
}
- if (State->mTextureSwap != 0) {
+ if (gTextureSwap != 0) {
scale[0] = .25f;
} else {
scale[0] = 4.f;
}
- drawClouds(ident);
+ drawClouds();
return 55;
}