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/values-da/strings.xml2
-rw-r--r--res/values-es-rUS/strings.xml2
-rw-r--r--res/values-rm/strings.xml28
-rw-r--r--src/com/android/magicsmoke/MagicSmokeRS.java137
-rw-r--r--src/com/android/magicsmoke/RenderScriptScene.java13
-rw-r--r--src/com/android/magicsmoke/RenderScriptWallpaper.java22
-rw-r--r--src/com/android/magicsmoke/clouds.rs (renamed from res/raw/clouds.rs)223
13 files changed, 262 insertions, 171 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/values-da/strings.xml b/res/values-da/strings.xml
index d52d305..f9a6c65 100644
--- a/res/values-da/strings.xml
+++ b/res/values-da/strings.xml
@@ -19,7 +19,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="wallpapers" msgid="9040514152147134380">"Tapeter med magisk røg"</string>
+ <string name="wallpapers" msgid="9040514152147134380">"Tapeter med magisk røg "</string>
<string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Magisk røg"</string>
<string name="author" msgid="3728706901510651795">"Google"</string>
<string name="magicsmoke_desc" msgid="4882321171007683983">"Tegner røg, skyer, vand og plasma."</string>
diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml
index 4011417..f6a58e5 100644
--- a/res/values-es-rUS/strings.xml
+++ b/res/values-es-rUS/strings.xml
@@ -19,7 +19,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="wallpapers" msgid="9040514152147134380">"Fondos de pantalla humo mágico"</string>
+ <string name="wallpapers" msgid="9040514152147134380">"Fondos de pantalla humo mágico "</string>
<string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Humo mágico"</string>
<string name="author" msgid="3728706901510651795">"Google"</string>
<string name="magicsmoke_desc" msgid="4882321171007683983">"Dibuja humo, nubes, agua y plasmas."</string>
diff --git a/res/values-rm/strings.xml b/res/values-rm/strings.xml
new file mode 100644
index 0000000..683c23e
--- /dev/null
+++ b/res/values-rm/strings.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+* Copyright (C) 2008 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="wallpapers" msgid="9040514152147134380">"Funds davos fim magic"</string>
+ <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Fim magic"</string>
+ <string name="author" msgid="3728706901510651795">"Google"</string>
+ <string name="magicsmoke_desc" msgid="4882321171007683983">"\"Dissegna fim, nivlas, aua e plasmas.\""</string>
+ <string name="ok" msgid="2096612745586722488">"OK"</string>
+ <string name="taptochange" msgid="2128130912969723119">"Tutgar per midar"</string>
+</resources>
diff --git a/src/com/android/magicsmoke/MagicSmokeRS.java b/src/com/android/magicsmoke/MagicSmokeRS.java
index f11b704..6183ec3 100644
--- a/src/com/android/magicsmoke/MagicSmokeRS.java
+++ b/src/com/android/magicsmoke/MagicSmokeRS.java
@@ -38,13 +38,13 @@ 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.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;
@@ -66,8 +66,8 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
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;
@@ -76,6 +76,8 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
private Allocation[] mSourceTextures;
private Allocation[] mRealTextures;
+ private ScriptC_clouds mScript;
+
private ProgramVertex mPVBackground;
private ProgramVertex.MatrixAllocation mPVAlloc;
@@ -161,7 +163,6 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
makeNewState();
- mState.data(mWorldState);
}
void makeNewState() {
@@ -180,6 +181,20 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
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);
+ mScript.set_gBlendFunc(mWorldState.mBlendFunc);
+ }
}
@Override
@@ -191,6 +206,18 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
}
@Override
+ public Bundle onCommand(String action, int x, int y, int z, Bundle extras,
+ boolean resultRequested) {
+
+ if ("android.wallpaper.tap".equals(action)) {
+ mTouchY = y;
+ }
+ mWorldState.mTilt = 0;
+ mScript.set_gTilt(mWorldState.mTilt);
+ return null;
+ }
+
+ /*@Override
public void onTouchEvent(MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
@@ -207,16 +234,16 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
dy = -4;
}
mWorldState.mTilt = dy;
- mState.data(mWorldState);
+ mScript.set_gTilt(mWorldState.mTilt);
+ //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, int xPixels, int yPixels) {
// update our state, then push it to the renderscript
mWorldState.mXOffset = xOffset;
- mState.data(mWorldState);
+ mScript.set_gXOffset(mWorldState.mXOffset);
}
@Override
@@ -230,7 +257,6 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
super.start();
mSharedPref.registerOnSharedPreferenceChangeListener(this);
makeNewState();
- mState.data(mWorldState);
}
float alphafactor;
@@ -245,9 +271,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
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);
in.recycle();
}
@@ -265,27 +289,40 @@ 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);
+ mScript = new ScriptC_clouds(mRS, mResources, R.raw.clouds, true);
// 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.set_gPVBackground(mPVBackground);
+
mSourceTextures = new Allocation[5];
mRealTextures = new Allocation[5];
@@ -307,10 +344,11 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
builder.setTexture(ProgramFragment.Builder.EnvMode.REPLACE,
ProgramFragment.Builder.Format.RGBA, 0);
mPfBackground = builder.create();
- mPfBackground.setName("PFBackground");
mPfBackground.bindSampler(mSampler, 0);
}
+ mScript.set_gPFBackground(mPfBackground);
+
{
ProgramStore.Builder builder = new ProgramStore.Builder(mRS, null, null);
builder.setDepthFunc(ProgramStore.DepthFunc.EQUAL);
@@ -318,48 +356,27 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange
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");
}
- // 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_gPFSBackgroundOne(mPfsBackgroundOne);
+ mScript.set_gPFSBackgroundSrc(mPfsBackgroundSrc);
+
+ 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_gBlendFunc(mWorldState.mBlendFunc);
+ mScript.set_gTilt(mWorldState.mTilt);
+ 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..23b3360 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;
@@ -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, 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..4779fba 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,7 +41,7 @@ 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);
}
@@ -89,19 +90,15 @@ public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends
}
}
- @Override
+ /*@Override
public void onTouchEvent(MotionEvent event) {
- if (mRenderer != null) {
- mRenderer.onTouchEvent(event);
- }
- }
+ 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, xPixels, yPixels);
}
@Override
@@ -121,5 +118,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..9383efb 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,6 +29,48 @@
#define RSID_NOISEDST4 9
#define RSID_NOISEDST5 10
+// State set from java
+float gXOffset;
+float gTilt;
+int gPreset;
+int gTextureMask;
+int gRotate;
+int gTextureSwap;
+int gProcessTextureMode;
+int gBackCol;
+int gLowCol;
+int gHighCol;
+float gAlphaMul;
+int gPreMul;
+int gBlendFunc;
+
+rs_program_vertex gPVBackground;
+rs_program_fragment gPFBackground;
+rs_program_store gPFSBackgroundOne;
+rs_program_store gPFSBackgroundSrc;
+
+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;
+
+#pragma rs export_var(gXOffset, gTilt, gPreset, gTextureMask, gRotate, gTextureSwap, gProcessTextureMode, gBackCol, gLowCol, gHighCol, gAlphaMul, gPreMul, gBlendFunc, gPVBackground, gPFBackground, gPFSBackgroundOne, gPFSBackgroundSrc, gTnoise1, gTnoise2, gTnoise3, gTnoise4, gTnoise5, gNoisesrc1, gNoisesrc2, gNoisesrc3, gNoisesrc4, gNoisesrc5, gNoisedst1, gNoisedst2, gNoisedst3, gNoisedst4, gNoisedst5)
+#pragma rs_export_func()
+
+// Local script variables
float xshift[5];
float rotation[5];
float scale[5];
@@ -35,17 +78,18 @@ float alphafactor;
int currentpreset;
int lastuptime;
float timedelta;
+static float4 clearColor = {0.5f, 0.0f, 0.0f, 1.0f};
-void drawCloud(float *ident, int id, int idx) {
- float mat1[16];
+void drawCloud(rs_matrix4x4 *ident, rs_allocation allocat, int idx) {
+ rs_matrix4x4 mat1;
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);
+ rsMatrixLoad(&mat1, ident);
+ rsMatrixTranslate(&mat1, -gXOffset * 8.f * idx, -gTilt * idx / 3.f, 0.f);
+ rsMatrixRotate(&mat1, rotation[idx], 0.f, 0.f, 1.f);
+ rsgProgramVertexLoadModelMatrix(&mat1);
- bindTexture(NAMED_PFBackground, 0, id);
- drawQuadTexCoords(
+ rsgBindTexture(gPFBackground, 0, allocat);
+ rsgDrawQuadTexCoords(
-1200.0f, -1200.0f, z, // space
0.f + xshift[idx], 0.f, // texture
1200, -1200.0f, z, // space
@@ -56,15 +100,11 @@ void drawCloud(float *ident, int id, int idx) {
0.f + xshift[idx], scale[idx]); // texture
}
-void drawClouds(float* ident) {
-
- int i;
+void drawClouds(rs_matrix4x4 *ident) {
+ rs_matrix4x4 mat1;
+ rsMatrixLoad(&mat1, ident);
- float mat1[16];
-
- matrixLoadMat(mat1,ident);
-
- if (State->mRotate != 0) {
+ if (gRotate != 0) {
rotation[0] += 0.10 * timedelta;
rotation[1] += 0.102f * timedelta;
rotation[2] += 0.106f * timedelta;
@@ -72,46 +112,48 @@ void drawClouds(float* ident) {
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);
+ if (gTextureSwap != 0) {
+ drawCloud(&mat1, gTnoise5, 0);
} else {
- drawCloud(mat1, NAMED_Tnoise1, 0);
+ drawCloud(&mat1, gTnoise1, 0);
}
}
if (mask & 2) {
xshift[1] += 0.00106 * timedelta;
- drawCloud(mat1, NAMED_Tnoise2, 1);
+ drawCloud(&mat1, gTnoise2, 1);
}
if (mask & 4) {
xshift[2] += 0.00114f * timedelta;
- drawCloud(mat1, NAMED_Tnoise3, 2);
+ drawCloud(&mat1, gTnoise3, 2);
}
if (mask & 8) {
xshift[3] += 0.00118f * timedelta;
- drawCloud(mat1, NAMED_Tnoise4, 3);
+ drawCloud(&mat1, gTnoise4, 3);
}
if (mask & 16) {
xshift[4] += 0.00127f * timedelta;
- drawCloud(mat1, NAMED_Tnoise5, 4);
+ drawCloud(&mat1, gTnoise5, 4);
}
// 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;
}
}
}
@@ -126,18 +168,19 @@ int premul(int rgb, int a) {
return r << 16 | g << 8 | b;
}
-void makeTexture(int *src, int *dst, int rsid) {
-
+
+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 +202,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 +226,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 +257,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 +271,25 @@ void makeTexture(int *src, int *dst, int rsid) {
}
}
}
- uploadToTexture(rsid, 0);
+
+ rsgUploadToTexture(rsid, 0);
}
void makeTextures() {
- debugI32("makeTextures", State->mPreset);
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 +297,32 @@ 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);
+ rs_matrix4x4 ident;
+ float masterscale = 0.0041f;// / (gXOffset * 4.f + 1.f);
+
+ rsgBindProgramVertex(gPVBackground);
+ rsgBindProgramFragment(gPFBackground);
+
+ rsMatrixLoadIdentity(&ident);
+ rsMatrixTranslate(&ident, -gXOffset, 0.f, 0.f);
+ rsMatrixScale(&ident, masterscale, masterscale, masterscale);
+ //rsMatrixRotate(&ident, 0.f, 0.f, 0.f, 1.f);
+ rsMatrixRotate(&ident, -gTilt, 1.f, 0.f, 0.f);
+
+ if (gBlendFunc) {
+ rsgBindProgramStore(gPFSBackgroundOne);
} else {
- bindProgramStore(NAMED_PFSBackgroundSrc);
+ rsgBindProgramStore(gPFSBackgroundSrc);
}
- int now = uptimeMillis();
+ int now = (int)rsUptimeMillis();
timedelta = ((float)(now - lastuptime)) / 44.f;
lastuptime = now;
if (timedelta > 3) {
@@ -294,24 +331,22 @@ 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();
}
+ rsgClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
- if (State->mTextureSwap != 0) {
+ if (gTextureSwap != 0) {
scale[0] = .25f;
} else {
scale[0] = 4.f;
}
- drawClouds(ident);
+ drawClouds(&ident);
return 55;
}