Water live wallpaper now runs correctly in landscape.
Orientation change still to be tested.
Change-Id: I07befb15a72a5f3e5c00276f5b9826603b2fc3a1
diff --git a/res/raw/fall.rs b/res/raw/fall.rs
index 028bb3c..a54e3b5 100644
--- a/res/raw/fall.rs
+++ b/res/raw/fall.rs
@@ -247,7 +247,9 @@
}
}
-void drawLeaf(struct Leaves_s *leaf, int meshWidth, int meshHeight, float glWidth, float glHeight) {
+void drawLeaf(struct Leaves_s *leaf, int meshWidth, int meshHeight, float glWidth, float glHeight,
+ int rotate) {
+
float x = leaf->x;
float x1 = x - LEAF_SIZE;
float x2 = x + LEAF_SIZE;
@@ -282,8 +284,12 @@
if (a > 0.0f) {
color(0.0f, 0.0f, 0.0f, 0.15f);
-
- matrixLoadIdentity(matrix);
+
+ if (rotate) {
+ matrixLoadRotate(matrix, 90.0f, 0.0f, 0.0f, 1.0f);
+ } else {
+ matrixLoadIdentity(matrix);
+ }
matrixTranslate(matrix, x, y, 0.0f);
matrixScale(matrix, s, s, 1.0f);
matrixRotate(matrix, r, 0.0f, 0.0f, 1.0f);
@@ -301,7 +307,11 @@
color(1.0f, 1.0f, 1.0f, 1.0f);
}
- matrixLoadIdentity(matrix);
+ if (rotate) {
+ matrixLoadRotate(matrix, 90.0f, 0.0f, 0.0f, 1.0f);
+ } else {
+ matrixLoadIdentity(matrix);
+ }
matrixTranslate(matrix, x, y, tz);
matrixScale(matrix, s, s, 1.0f);
matrixRotate(matrix, r, 0.0f, 0.0f, 1.0f);
@@ -363,12 +373,13 @@
int height = State->meshHeight;
float glWidth = State->glWidth;
float glHeight = State->glHeight;
+ int rotate = State->rotate;
struct Leaves_s *leaf = Leaves;
int i = 0;
for ( ; i < leavesCount; i += 1) {
- drawLeaf(leaf, width, height, glWidth, glHeight);
+ drawLeaf(leaf, width, height, glWidth, glHeight, rotate);
leaf += 1;
}
@@ -475,6 +486,12 @@
generateRipples();
updateSimpleMesh(NAMED_WaterMesh);
+ if (State->rotate) {
+ float matrix[16];
+ matrixLoadRotate(matrix, 90.0f, 0.0f, 0.0f, 1.0f);
+ vpLoadModelMatrix(matrix);
+ }
+
drawRiverbed();
drawSky();
drawLighting();
diff --git a/src/com/android/wallpaper/fall/FallRS.java b/src/com/android/wallpaper/fall/FallRS.java
index e4e1913..10e12f6 100644
--- a/src/com/android/wallpaper/fall/FallRS.java
+++ b/src/com/android/wallpaper/fall/FallRS.java
@@ -114,7 +114,7 @@
mWorldState.width = width;
mWorldState.height = height;
- mWorldState.rotate = 1;
+ mWorldState.rotate = width > height ? 1 : 0;
mState.data(mWorldState);
mPvOrthoAlloc.setupOrthoWindow(width, height);
@@ -399,8 +399,13 @@
}
void addDrop(float x, float y) {
- mDrop.dropX = (int) ((x / mWidth) * mMeshWidth);
- mDrop.dropY = (int) ((y / mHeight) * mMeshHeight);
+ if (mWorldState.rotate == 0) {
+ mDrop.dropX = (int) ((x / mWidth) * mMeshWidth);
+ mDrop.dropY = (int) ((y / mHeight) * mMeshHeight);
+ } else {
+ mDrop.dropY = (int) ((x / mWidth) * mMeshHeight);
+ mDrop.dropX = mMeshWidth - (int) ((y / mHeight) * mMeshWidth);
+ }
mDropState.data(mDrop);
}
}
\ No newline at end of file