Skip to content

Commit

Permalink
Too many changes to list 'em all. Forcing to use two-sided pages is the
Browse files Browse the repository at this point in the history
major one though.
  • Loading branch information
harism committed May 6, 2012
1 parent 0f489ed commit ef554ee
Show file tree
Hide file tree
Showing 6 changed files with 669 additions and 834 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
NOTE
====

As of this commit all "pages" will be 2-sided. Meaning indices { 0, 2, 4, 6, ...}
are front-facing and { 1, 3, 5, 7, ...} back-facing ones. This happens when page is on right side.
On left side page is "flipped over" similarly as a page does on a regular book.

Here's an example video from cags12 showing 2-sided page support in landscape mode;
[http://www.youtube.com/watch?v=iwu7P5PCpsw]

Introduction
============
Project for implementing 'page curl' effect on Android + OpenGL ES 1.0 (possibly 1.1/2.0 too if there's clear advantage in using them).
Expand Down Expand Up @@ -121,5 +131,3 @@ Not to forget many of the true real-time rendering heros. One day We're about to
* Rgba&Tbc - Elevated [http://www.youtube.com/watch?v=_YWMGuh15nE]
* Andromeda&Orb - Stargazer [http://www.youtube.com/watch?v=5u1cqYLNbJI]
* Cncd&Flt - Numb Res [http://www.youtube.com/watch?v=LTOC_ajkRkU]

// cags12 Edit: Added 2 pages landscape support - [http://www.youtube.com/watch?v=iwu7P5PCpsw]
2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
# project structure.

# Project target.
target=android-10
target=android-8
28 changes: 21 additions & 7 deletions src/fi/harism/curl/CurlActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2011 Harri Smått
Copyright 2012 Harri Smatt
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -12,7 +12,7 @@
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 fi.harism.curl;

Expand Down Expand Up @@ -50,10 +50,7 @@ public void onCreate(Bundle savedInstanceState) {

// This is something somewhat experimental. Before uncommenting next
// line, please see method comments in CurlView.
mCurlView.setEnableTouchPressure(true);

// CAGS: This is to allow 2 pages landscape mode, set to false for legacy mode
mCurlView.set2PagesLandscape(true);
// mCurlView.setEnableTouchPressure(true);
}

@Override
Expand Down Expand Up @@ -83,6 +80,21 @@ private class BitmapProvider implements CurlView.BitmapProvider {

@Override
public Bitmap getBitmap(int width, int height, int index) {

// For every "odd" bitmap (back-facing ones); 1, 3, 5, 7... Return a
// static few pixel default bitmap only.
if ((index & 0x01) == 0x01) {
final int colors[] = { 0xFF808080, 0xFFA0A0A0, 0xFFA0A0A0,
0xFF808080 };
Bitmap bitmap = Bitmap.createBitmap(colors, 2, 2,
Bitmap.Config.ARGB_8888);
return bitmap;
}

// For front facing bitmaps (even ones) change index --> index / 2
// --> 0, 1, 2, 3...
index >>= 1;

Bitmap b = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
b.eraseColor(0xFFFFFFFF);
Expand Down Expand Up @@ -122,7 +134,9 @@ public Bitmap getBitmap(int width, int height, int index) {

@Override
public int getBitmapCount() {
return mBitmapIds.length;
// Number of bitmaps * 2 for we have mBitmapIds.length bitmaps +
// same amount of static "back-facing" bitmaps.
return mBitmapIds.length * 2;
}
}

Expand Down
Loading

0 comments on commit ef554ee

Please sign in to comment.