From 640ff0593e482072a5836b60cc5828440b9ccfe5 Mon Sep 17 00:00:00 2001 From: Shih-wei Liao Date: Mon, 19 Jul 2010 15:23:13 -0700 Subject: Ported MagicSmoke to use the new build system. Change-Id: I1d6e23962f2f831b8822225ac1e8bc507bcc5038 --- src/com/android/magicsmoke/MagicSmokeRS.java | 2 +- src/com/android/magicsmoke/ScriptC_Clouds.java | 392 ------------------------- src/com/android/magicsmoke/clouds.rs | 354 ++++++++++++++++++++++ 3 files changed, 355 insertions(+), 393 deletions(-) delete mode 100644 src/com/android/magicsmoke/ScriptC_Clouds.java create mode 100644 src/com/android/magicsmoke/clouds.rs (limited to 'src') diff --git a/src/com/android/magicsmoke/MagicSmokeRS.java b/src/com/android/magicsmoke/MagicSmokeRS.java index 8c8322c..cc86898 100644 --- a/src/com/android/magicsmoke/MagicSmokeRS.java +++ b/src/com/android/magicsmoke/MagicSmokeRS.java @@ -312,7 +312,7 @@ class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChange @Override protected ScriptC createScript() { - mScript = new ScriptC_Clouds(mRS, mResources, R.raw.clouds_bc, true); + 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); diff --git a/src/com/android/magicsmoke/ScriptC_Clouds.java b/src/com/android/magicsmoke/ScriptC_Clouds.java deleted file mode 100644 index 4248734..0000000 --- a/src/com/android/magicsmoke/ScriptC_Clouds.java +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -package com.android.magicsmoke; - -import android.renderscript.*; -import android.content.res.Resources; -import android.util.Log; - -public class ScriptC_Clouds extends ScriptC { - // Constructor - public ScriptC_Clouds(RenderScript rs, Resources resources, int id, boolean isRoot) { - super(rs, resources, id, isRoot); - } - - private final static int mExportVarIdx_gXOffset = 0; - private float mExportVar_gXOffset; - public void set_gXOffset(float v) { - mExportVar_gXOffset = v; - setVar(mExportVarIdx_gXOffset, v); - } - - public float get_gXOffset() { - return mExportVar_gXOffset; - } - - private final static int mExportVarIdx_gTilt = 1; - private float mExportVar_gTilt; - public void set_gTilt(float v) { - mExportVar_gTilt = v; - setVar(mExportVarIdx_gTilt, v); - } - - public float get_gTilt() { - return mExportVar_gTilt; - } - - private final static int mExportVarIdx_gPreset = 2; - private int mExportVar_gPreset; - public void set_gPreset(int v) { - mExportVar_gPreset = v; - setVar(mExportVarIdx_gPreset, v); - } - - public int get_gPreset() { - return mExportVar_gPreset; - } - - private final static int mExportVarIdx_gTextureMask = 3; - private int mExportVar_gTextureMask; - public void set_gTextureMask(int v) { - mExportVar_gTextureMask = v; - setVar(mExportVarIdx_gTextureMask, v); - } - - public int get_gTextureMask() { - return mExportVar_gTextureMask; - } - - private final static int mExportVarIdx_gRotate = 4; - private int mExportVar_gRotate; - public void set_gRotate(int v) { - mExportVar_gRotate = v; - setVar(mExportVarIdx_gRotate, v); - } - - public int get_gRotate() { - return mExportVar_gRotate; - } - - private final static int mExportVarIdx_gTextureSwap = 5; - private int mExportVar_gTextureSwap; - public void set_gTextureSwap(int v) { - mExportVar_gTextureSwap = v; - setVar(mExportVarIdx_gTextureSwap, v); - } - - public int get_gTextureSwap() { - return mExportVar_gTextureSwap; - } - - private final static int mExportVarIdx_gProcessTextureMode = 6; - private int mExportVar_gProcessTextureMode; - public void set_gProcessTextureMode(int v) { - mExportVar_gProcessTextureMode = v; - setVar(mExportVarIdx_gProcessTextureMode, v); - } - - public int get_gProcessTextureMode() { - return mExportVar_gProcessTextureMode; - } - - private final static int mExportVarIdx_gBackCol = 7; - private int mExportVar_gBackCol; - public void set_gBackCol(int v) { - mExportVar_gBackCol = v; - setVar(mExportVarIdx_gBackCol, v); - } - - public int get_gBackCol() { - return mExportVar_gBackCol; - } - - private final static int mExportVarIdx_gLowCol = 8; - private int mExportVar_gLowCol; - public void set_gLowCol(int v) { - mExportVar_gLowCol = v; - setVar(mExportVarIdx_gLowCol, v); - } - - public int get_gLowCol() { - return mExportVar_gLowCol; - } - - private final static int mExportVarIdx_gHighCol = 9; - private int mExportVar_gHighCol; - public void set_gHighCol(int v) { - mExportVar_gHighCol = v; - setVar(mExportVarIdx_gHighCol, v); - } - - public int get_gHighCol() { - return mExportVar_gHighCol; - } - - private final static int mExportVarIdx_gAlphaMul = 10; - private float mExportVar_gAlphaMul; - public void set_gAlphaMul(float v) { - mExportVar_gAlphaMul = v; - setVar(mExportVarIdx_gAlphaMul, v); - } - - public float get_gAlphaMul() { - return mExportVar_gAlphaMul; - } - - private final static int mExportVarIdx_gPreMul = 11; - private int mExportVar_gPreMul; - public void set_gPreMul(int v) { - mExportVar_gPreMul = v; - setVar(mExportVarIdx_gPreMul, v); - } - - public int get_gPreMul() { - return mExportVar_gPreMul; - } - - private final static int mExportVarIdx_gBlendFunc = 12; - private int mExportVar_gBlendFunc; - public void set_gBlendFunc(int v) { - mExportVar_gBlendFunc = v; - setVar(mExportVarIdx_gBlendFunc, v); - } - - public int get_gBlendFunc() { - return mExportVar_gBlendFunc; - } - - private final static int mExportVarIdx_gPVBackground = 13; - private ProgramVertex mExportVar_gPVBackground; - public void set_gPVBackground(ProgramVertex v) { - mExportVar_gPVBackground = v; - setVar(mExportVarIdx_gPVBackground, (v == null) ? 0 : v.getID()); - } - - public ProgramVertex get_gPVBackground() { - return mExportVar_gPVBackground; - } - - private final static int mExportVarIdx_gPFBackground = 14; - private ProgramFragment mExportVar_gPFBackground; - public void set_gPFBackground(ProgramFragment v) { - mExportVar_gPFBackground = v; - setVar(mExportVarIdx_gPFBackground, (v == null) ? 0 : v.getID()); - } - - public ProgramFragment get_gPFBackground() { - return mExportVar_gPFBackground; - } - - private final static int mExportVarIdx_gPFSBackgroundOne = 15; - private ProgramStore mExportVar_gPFSBackgroundOne; - public void set_gPFSBackgroundOne(ProgramStore v) { - mExportVar_gPFSBackgroundOne = v; - setVar(mExportVarIdx_gPFSBackgroundOne, (v == null) ? 0 : v.getID()); - } - - public ProgramStore get_gPFSBackgroundOne() { - return mExportVar_gPFSBackgroundOne; - } - - private final static int mExportVarIdx_gPFSBackgroundSrc = 16; - private ProgramStore mExportVar_gPFSBackgroundSrc; - public void set_gPFSBackgroundSrc(ProgramStore v) { - mExportVar_gPFSBackgroundSrc = v; - setVar(mExportVarIdx_gPFSBackgroundSrc, (v == null) ? 0 : v.getID()); - } - - public ProgramStore get_gPFSBackgroundSrc() { - return mExportVar_gPFSBackgroundSrc; - } - - private final static int mExportVarIdx_gTnoise1 = 17; - private Allocation mExportVar_gTnoise1; - public void set_gTnoise1(Allocation v) { - mExportVar_gTnoise1 = v; - setVar(mExportVarIdx_gTnoise1, (v == null) ? 0 : v.getID()); - } - - public Allocation get_gTnoise1() { - return mExportVar_gTnoise1; - } - - private final static int mExportVarIdx_gTnoise2 = 18; - private Allocation mExportVar_gTnoise2; - public void set_gTnoise2(Allocation v) { - mExportVar_gTnoise2 = v; - setVar(mExportVarIdx_gTnoise2, (v == null) ? 0 : v.getID()); - } - - public Allocation get_gTnoise2() { - return mExportVar_gTnoise2; - } - - private final static int mExportVarIdx_gTnoise3 = 19; - private Allocation mExportVar_gTnoise3; - public void set_gTnoise3(Allocation v) { - mExportVar_gTnoise3 = v; - setVar(mExportVarIdx_gTnoise3, (v == null) ? 0 : v.getID()); - } - - public Allocation get_gTnoise3() { - return mExportVar_gTnoise3; - } - - private final static int mExportVarIdx_gTnoise4 = 20; - private Allocation mExportVar_gTnoise4; - public void set_gTnoise4(Allocation v) { - mExportVar_gTnoise4 = v; - setVar(mExportVarIdx_gTnoise4, (v == null) ? 0 : v.getID()); - } - - public Allocation get_gTnoise4() { - return mExportVar_gTnoise4; - } - - private final static int mExportVarIdx_gTnoise5 = 21; - private Allocation mExportVar_gTnoise5; - public void set_gTnoise5(Allocation v) { - mExportVar_gTnoise5 = v; - setVar(mExportVarIdx_gTnoise5, (v == null) ? 0 : v.getID()); - } - - public Allocation get_gTnoise5() { - return mExportVar_gTnoise5; - } - - private final static int mExportVarIdx_gNoisesrc1 = 22; - private Allocation mExportVar_gNoisesrc1; - public void bind_gNoisesrc1(Allocation v) { - mExportVar_gNoisesrc1 = v; - if(v == null) bindAllocation(null, mExportVarIdx_gNoisesrc1); - else bindAllocation(v, mExportVarIdx_gNoisesrc1); - } - - public Allocation get_gNoisesrc1() { - return mExportVar_gNoisesrc1; - } - - private final static int mExportVarIdx_gNoisesrc2 = 23; - private Allocation mExportVar_gNoisesrc2; - public void bind_gNoisesrc2(Allocation v) { - mExportVar_gNoisesrc2 = v; - if(v == null) bindAllocation(null, mExportVarIdx_gNoisesrc2); - else bindAllocation(v, mExportVarIdx_gNoisesrc2); - } - - public Allocation get_gNoisesrc2() { - return mExportVar_gNoisesrc2; - } - - private final static int mExportVarIdx_gNoisesrc3 = 24; - private Allocation mExportVar_gNoisesrc3; - public void bind_gNoisesrc3(Allocation v) { - mExportVar_gNoisesrc3 = v; - if(v == null) bindAllocation(null, mExportVarIdx_gNoisesrc3); - else bindAllocation(v, mExportVarIdx_gNoisesrc3); - } - - public Allocation get_gNoisesrc3() { - return mExportVar_gNoisesrc3; - } - - private final static int mExportVarIdx_gNoisesrc4 = 25; - private Allocation mExportVar_gNoisesrc4; - public void bind_gNoisesrc4(Allocation v) { - mExportVar_gNoisesrc4 = v; - if(v == null) bindAllocation(null, mExportVarIdx_gNoisesrc4); - else bindAllocation(v, mExportVarIdx_gNoisesrc4); - } - - public Allocation get_gNoisesrc4() { - return mExportVar_gNoisesrc4; - } - - private final static int mExportVarIdx_gNoisesrc5 = 26; - private Allocation mExportVar_gNoisesrc5; - public void bind_gNoisesrc5(Allocation v) { - mExportVar_gNoisesrc5 = v; - if(v == null) bindAllocation(null, mExportVarIdx_gNoisesrc5); - else bindAllocation(v, mExportVarIdx_gNoisesrc5); - } - - public Allocation get_gNoisesrc5() { - return mExportVar_gNoisesrc5; - } - - private final static int mExportVarIdx_gNoisedst1 = 27; - private Allocation mExportVar_gNoisedst1; - public void bind_gNoisedst1(Allocation v) { - mExportVar_gNoisedst1 = v; - if(v == null) bindAllocation(null, mExportVarIdx_gNoisedst1); - else bindAllocation(v, mExportVarIdx_gNoisedst1); - } - - public Allocation get_gNoisedst1() { - return mExportVar_gNoisedst1; - } - - private final static int mExportVarIdx_gNoisedst2 = 28; - private Allocation mExportVar_gNoisedst2; - public void bind_gNoisedst2(Allocation v) { - mExportVar_gNoisedst2 = v; - if(v == null) bindAllocation(null, mExportVarIdx_gNoisedst2); - else bindAllocation(v, mExportVarIdx_gNoisedst2); - } - - public Allocation get_gNoisedst2() { - return mExportVar_gNoisedst2; - } - - private final static int mExportVarIdx_gNoisedst3 = 29; - private Allocation mExportVar_gNoisedst3; - public void bind_gNoisedst3(Allocation v) { - mExportVar_gNoisedst3 = v; - if(v == null) bindAllocation(null, mExportVarIdx_gNoisedst3); - else bindAllocation(v, mExportVarIdx_gNoisedst3); - } - - public Allocation get_gNoisedst3() { - return mExportVar_gNoisedst3; - } - - private final static int mExportVarIdx_gNoisedst4 = 30; - private Allocation mExportVar_gNoisedst4; - public void bind_gNoisedst4(Allocation v) { - mExportVar_gNoisedst4 = v; - if(v == null) bindAllocation(null, mExportVarIdx_gNoisedst4); - else bindAllocation(v, mExportVarIdx_gNoisedst4); - } - - public Allocation get_gNoisedst4() { - return mExportVar_gNoisedst4; - } - - private final static int mExportVarIdx_gNoisedst5 = 31; - private Allocation mExportVar_gNoisedst5; - public void bind_gNoisedst5(Allocation v) { - mExportVar_gNoisedst5 = v; - if(v == null) bindAllocation(null, mExportVarIdx_gNoisedst5); - else bindAllocation(v, mExportVarIdx_gNoisedst5); - } - - public Allocation get_gNoisedst5() { - return mExportVar_gNoisedst5; - } - -} - diff --git a/src/com/android/magicsmoke/clouds.rs b/src/com/android/magicsmoke/clouds.rs new file mode 100644 index 0000000..9467638 --- /dev/null +++ b/src/com/android/magicsmoke/clouds.rs @@ -0,0 +1,354 @@ +// Copyright (C) 2009 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. + +#pragma version(1) + +#pragma rs java_package_name(com.android.magicsmoke) + +#include "rs_types.rsh" +#include "rs_math.rsh" +#include "rs_graphics.rsh" + +#define RSID_NOISESRC1 1 +#define RSID_NOISESRC2 2 +#define RSID_NOISESRC3 3 +#define RSID_NOISESRC4 4 +#define RSID_NOISESRC5 5 +#define RSID_NOISEDST1 6 +#define RSID_NOISEDST2 7 +#define RSID_NOISEDST3 8 +#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]; +float alphafactor; +int currentpreset; +int lastuptime; +float timedelta; +static float4 clearColor = {0.5f, 0.0f, 0.0f, 1.0f}; + +void drawCloud(rs_matrix4x4 *ident, rs_allocation allocat, int idx) { + rs_matrix4x4 mat1; + float z = -8.f * idx; + 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); + + rsgBindTexture(gPFBackground, 0, allocat); + rsgDrawQuadTexCoords( + -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 +} + +void drawClouds(rs_matrix4x4 *ident) { + rs_matrix4x4 mat1; + rsMatrixLoad(&mat1, ident); + + if (gRotate != 0) { + rotation[0] += 0.10 * timedelta; + rotation[1] += 0.102f * timedelta; + rotation[2] += 0.106f * timedelta; + rotation[3] += 0.114f * timedelta; + rotation[4] += 0.123f * timedelta; + } + + int mask = gTextureMask; + if (mask & 1) { + xshift[0] += 0.0010f * timedelta; + if (gTextureSwap != 0) { + drawCloud(&mat1, gTnoise5, 0); + } else { + drawCloud(&mat1, gTnoise1, 0); + } + } + + if (mask & 2) { + xshift[1] += 0.00106 * timedelta; + drawCloud(&mat1, gTnoise2, 1); + } + + if (mask & 4) { + xshift[2] += 0.00114f * timedelta; + drawCloud(&mat1, gTnoise3, 2); + } + + if (mask & 8) { + xshift[3] += 0.00118f * timedelta; + drawCloud(&mat1, gTnoise4, 3); + } + + if (mask & 16) { + xshift[4] += 0.00127f * timedelta; + drawCloud(&mat1, gTnoise5, 4); + } + + // Make sure the texture coordinates don't continuously increase + int i; + for(i = 0; i < 5; i++) { + 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++) { + if (rotation[i] > 360.f) { + float multiplier = floor(rotation[i]/360.f); + rotation[i] -= 360.f * multiplier; + } + } +} + +int premul(int rgb, int a) { + int r = (rgb >> 16) * a + 1; + r = (r + (r >> 8)) >> 8; + int g = ((rgb >> 8) & 0xff) * a + 1; + g = (g + (g >> 8)) >> 8; + int b = (rgb & 0xff) * a + 1; + b = (b + (b >> 8)) >> 8; + return r << 16 | g << 8 | b; +} + + +void makeTexture(int *src, int *dst, rs_allocation rsid) { + + int x; + int y; + int pm = gPreMul; + + if (gProcessTextureMode == 1) { + int lowcol = gLowCol; + int highcol = gHighCol; + + for (y=0;y<256;y++) { + for (x=0;x<256;x++) { + int pix = src[y*256+x]; + int lum = pix & 0x00ff; + int newpix; + if (lum < 128) { + newpix = lowcol; + int newalpha = 255 - (lum * 2); + newalpha /= alphafactor; + if (pm) newpix = premul(newpix, newalpha); + newpix = newpix | (newalpha << 24); + } else { + newpix = highcol; + int newalpha = (lum - 128) * 2; + newalpha /= alphafactor; + if (pm) newpix = premul(newpix, newalpha); + newpix = newpix | (newalpha << 24); + } + // have ARGB, need ABGR + newpix = (newpix & 0xff00ff00) | ((newpix & 0xff) << 16) | ((newpix >> 16) & 0xff); + dst[y*256+x] = newpix; + } + } + 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++) { + int pix = src[y*256+x]; + int alpha = pix & 0x00ff; + if (alpha < lowcol) { + alpha = 0; + } else { + alpha = (alpha - lowcol) * scale; + } + alpha /= alphafactor; + int newpix = highcol; + if (pm) newpix = premul(newpix, alpha); + newpix = newpix | (alpha << 24); + // have ARGB, need ABGR + newpix = (newpix & 0xff00ff00) | ((newpix & 0xff) << 16) | ((newpix >> 16) & 0xff); + dst[y*256+x] = newpix; + } + } + 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++) { + int pix = src[y*256+x]; + int lum = pix & 0x00ff; + int newpix; + if (lum < 128) lum *= 2; + else lum = (255 - (lum - 128) * 2); + if (lum < 128) { + newpix = lowcol; + int newalpha = 255 - (lum * 2); + newalpha /= alphafactor; + if (pm) newpix = premul(newpix, newalpha); + newpix = newpix | (newalpha << 24); + } else { + newpix = highcol; + int newalpha = (lum - 128) * 2; + newalpha /= alphafactor; + if (pm) newpix = premul(newpix, newalpha); + newpix = newpix | (newalpha << 24); + } + // have ARGB, need ABGR + newpix = (newpix & 0xff00ff00) | ((newpix & 0xff) << 16) | ((newpix >> 16) & 0xff); + dst[y*256+x] = newpix; + } + } + alphafactor *= gAlphaMul; + } else { + for (y=0;y<256;y++) { + for (x=0;x<256;x++) { + int rgb = *src++; + int a = (rgb >> 24) & 0xff; + rgb &= 0x00ffffff; + rgb = premul(rgb, a); + int newpix = (a << 24) | rgb; + newpix = (newpix & 0xff00ff00) | ((newpix & 0xff) << 16) | ((newpix >> 16) & 0xff); + *dst++ = newpix; + } + } + } + + rsgUploadToTexture(rsid, 0); +} + +void makeTextures() { + alphafactor = 1.f; + 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); +} + +void init() { + 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; + scale[3] = 3.8f; + scale[4] = 4.2f; + + currentpreset = -1; + lastuptime = (int)rsUptimeMillis(); + timedelta = 0; +} + + +int root(int launchID) { + int i; + 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 { + rsgBindProgramStore(gPFSBackgroundSrc); + } + + int now = (int)rsUptimeMillis(); + timedelta = ((float)(now - lastuptime)) / 44.f; + lastuptime = now; + if (timedelta > 3) { + // Limit the step adjustment factor to 3, so we don't get a sudden jump + // after coming back from sleep. + timedelta = 3; + } + + i = gPreset; + if (i != currentpreset) { + currentpreset = i; + 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 (gTextureSwap != 0) { + scale[0] = .25f; + } else { + scale[0] = 4.f; + } + drawClouds(&ident); + + return 55; +} -- cgit v1.2.3