blob: 6a417272220cb9157c102985254bf91e36ce8797 [file] [log] [blame]
Joe Onorato93839052009-08-06 20:34:32 -07001#pragma version(1)
2#pragma stateVertex(PV)
Jason Samscd689e12009-09-29 15:28:22 -07003#pragma stateFragment(PFTexLinear)
4#pragma stateStore(PSIcons)
Joe Onorato93839052009-08-06 20:34:32 -07005
Joe Onorato43e7bcf2009-08-08 18:53:53 -07006#define PI 3.14159f
7
Jason Sams86c87ed2009-09-18 13:55:55 -07008
9// Attraction to center values from page edge to page center.
10float g_AttractionTable[9];
11float g_FrictionTable[9];
12float g_PhysicsTableSize;
13
14float g_PosPage;
15float g_PosVelocity;
16float g_LastPositionX;
17int g_LastTouchDown;
18float g_DT;
19int g_LastTime;
Jason Sams86c87ed2009-09-18 13:55:55 -070020int g_PageCount;
Jason Samsfd22dac2009-09-20 17:24:16 -070021float g_Zoom;
Joe Onorato93839052009-08-06 20:34:32 -070022
Joe Onorato43e7bcf2009-08-08 18:53:53 -070023// Drawing constants, should be parameters ======
Joe Onoratoefabe002009-08-28 09:38:18 -070024#define VIEW_ANGLE 1.28700222f
Joe Onorato43e7bcf2009-08-08 18:53:53 -070025
Jason Sams12c14a82009-10-06 14:33:15 -070026float g_OldPosPage;
27float g_OldPosVelocity;
28float g_OldZoom;
29
Jason Sams267d4fa2009-10-07 19:58:03 -070030int g_DrawLastFrame;
31int lastFrame(int draw) {
32 // We draw one extra frame to work around the last frame post bug.
33 // We also need to track if we drew the last frame to deal with large DT
34 // in the physics.
35 int ret = g_DrawLastFrame | draw;
36 g_DrawLastFrame = draw;
37 return ret; // should return draw instead.
38}
39
Jason Sams12c14a82009-10-06 14:33:15 -070040void updateReadback() {
41 if ((g_OldPosPage != g_PosPage) ||
42 (g_OldPosVelocity != g_PosVelocity) ||
43 (g_OldZoom != g_Zoom)) {
44
45 g_OldPosPage = g_PosPage;
46 g_OldPosVelocity = g_PosVelocity;
47 g_OldZoom = g_Zoom;
48
49 int i[3];
50 i[0] = g_PosPage * (1 << 16);
51 i[1] = g_PosVelocity * (1 << 16);
52 i[2] = g_OldZoom * (1 << 16);
53 sendToClient(&i[0], 1, 12, 1);
54 }
55}
56
Jason Sams78aebd82009-09-15 13:06:59 -070057void init() {
Jason Sams0aa71662009-10-02 18:43:18 -070058 g_AttractionTable[0] = 6.5f;
59 g_AttractionTable[1] = 6.5f;
60 g_AttractionTable[2] = 7.0f;
61 g_AttractionTable[3] = 6.0f;
62 g_AttractionTable[4] = -6.0f;
63 g_AttractionTable[5] = -7.0f;
64 g_AttractionTable[6] = -6.5f;
65 g_AttractionTable[7] = -6.5f;
66 g_AttractionTable[8] = -6.5f; // dup 7 to avoid a clamp later
Jason Sams86c87ed2009-09-18 13:55:55 -070067 g_FrictionTable[0] = 3.5f;
68 g_FrictionTable[1] = 3.6f;
Jason Sams0aa71662009-10-02 18:43:18 -070069 g_FrictionTable[2] = 4.0f;
70 g_FrictionTable[3] = 5.0f;
71 g_FrictionTable[4] = 5.0f;
72 g_FrictionTable[5] = 4.0f;
Jason Sams86c87ed2009-09-18 13:55:55 -070073 g_FrictionTable[6] = 3.6f;
74 g_FrictionTable[7] = 3.5f;
75 g_FrictionTable[8] = 3.5f; // dup 7 to avoid a clamp later
76 g_PhysicsTableSize = 7;
77
78 g_PosVelocity = 0;
79 g_PosPage = 0;
80 g_LastTouchDown = 0;
81 g_LastPositionX = 0;
Jason Samsfd22dac2009-09-20 17:24:16 -070082 g_Zoom = 0;
Jason Sams86c87ed2009-09-18 13:55:55 -070083}
84
Jason Sams41b61c82009-10-15 15:40:54 -070085void resetHWWar() {
86}
87
Jason Sams86c87ed2009-09-18 13:55:55 -070088void move() {
89 if (g_LastTouchDown) {
90 float dx = -(state->newPositionX - g_LastPositionX);
91 g_PosVelocity = 0;
92 g_PosPage += dx;
Jason Samsfd22dac2009-09-20 17:24:16 -070093
94 float pmin = -0.25f;
95 float pmax = (g_PageCount - 1) + 0.25f;
96 g_PosPage = clampf(g_PosPage, pmin, pmax);
Jason Sams86c87ed2009-09-18 13:55:55 -070097 }
98 g_LastTouchDown = state->newTouchDown;
99 g_LastPositionX = state->newPositionX;
Jason Sams28870b72009-09-30 17:32:05 -0700100 //debugF("Move P", g_PosPage);
Jason Sams86c87ed2009-09-18 13:55:55 -0700101}
102
103void fling() {
104 g_LastTouchDown = 0;
105 g_PosVelocity = -state->flingVelocityX;
Jason Samsfd22dac2009-09-20 17:24:16 -0700106 float av = fabsf(g_PosVelocity);
Jason Sams0aa71662009-10-02 18:43:18 -0700107 float minVel = 3.5f;
Jason Samsfd22dac2009-09-20 17:24:16 -0700108
109 minVel *= 1.f - (fabsf(fracf(g_PosPage + 0.5f) - 0.5f) * 0.45f);
110
111 if (av < minVel && av > 0.2f) {
112 if (g_PosVelocity > 0) {
113 g_PosVelocity = minVel;
114 } else {
115 g_PosVelocity = -minVel;
116 }
117 }
118
Jason Sams86c87ed2009-09-18 13:55:55 -0700119 if (g_PosPage <= 0) {
120 g_PosVelocity = maxf(0, g_PosVelocity);
121 }
122 if (g_PosPage > (g_PageCount - 1)) {
Jason Samsfd22dac2009-09-20 17:24:16 -0700123 g_PosVelocity = minf(0, g_PosVelocity);
Jason Sams86c87ed2009-09-18 13:55:55 -0700124 }
Jason Sams28870b72009-09-30 17:32:05 -0700125 //debugF("fling v", g_PosVelocity);
Jason Sams78aebd82009-09-15 13:06:59 -0700126}
127
Joe Onorato360d0352009-09-28 14:37:53 -0400128void touchUp() {
129 g_LastTouchDown = 0;
130}
131
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700132int
133count_pages(int iconCount)
Joe Onorato93839052009-08-06 20:34:32 -0700134{
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700135 int iconsPerPage = COLUMNS_PER_PAGE * ROWS_PER_PAGE;
136 int pages = iconCount / iconsPerPage;
137 if (pages*iconsPerPage != iconCount) {
Joe Onoratod769a632009-08-11 17:09:02 -0700138 pages++;
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700139 }
Joe Onoratod769a632009-08-11 17:09:02 -0700140 return pages;
141}
142
Joe Onoratod769a632009-08-11 17:09:02 -0700143float
144modf(float x, float y)
145{
146 return x-(y*floorf(x/y));
Joe Onorato93839052009-08-06 20:34:32 -0700147}
148
Jason Sams86c87ed2009-09-18 13:55:55 -0700149void updatePos() {
150 if (g_LastTouchDown) {
151 return;
152 }
153
Jason Sams86c87ed2009-09-18 13:55:55 -0700154 float tablePosNorm = fracf(g_PosPage + 0.5f);
155 float tablePosF = tablePosNorm * g_PhysicsTableSize;
156 int tablePosI = tablePosF;
157 float tablePosFrac = tablePosF - tablePosI;
Jason Sams86c87ed2009-09-18 13:55:55 -0700158 float accel = lerpf(g_AttractionTable[tablePosI],
159 g_AttractionTable[tablePosI + 1],
160 tablePosFrac) * g_DT;
161 float friction = lerpf(g_FrictionTable[tablePosI],
162 g_FrictionTable[tablePosI + 1],
163 tablePosFrac) * g_DT;
164 //debugF(" accel", accel);
165 //debugF(" friction", friction);
166
Jason Samsfd22dac2009-09-20 17:24:16 -0700167 // If our velocity is low OR acceleration is opposing it, apply it.
Jason Sams0aa71662009-10-02 18:43:18 -0700168 if (fabsf(g_PosVelocity) < 1.0f || (g_PosVelocity * accel) < 0) {
Jason Samsfd22dac2009-09-20 17:24:16 -0700169 g_PosVelocity += accel;
170 }
171
Jason Sams86c87ed2009-09-18 13:55:55 -0700172 if ((friction > fabsf(g_PosVelocity)) && (friction > fabsf(accel))) {
173 // Special get back to center and overcome friction physics.
174 float t = tablePosNorm - 0.5f;
175 if (fabsf(t) < (friction * g_DT)) {
176 // really close, just snap
177 g_PosPage = roundf(g_PosPage);
178 g_PosVelocity = 0;
179 } else {
180 if (t > 0) {
181 g_PosVelocity = -friction;
182 } else {
183 g_PosVelocity = friction;
184 }
185 }
186 } else {
187 // Normal physics
188 if (g_PosVelocity > 0) {
189 g_PosVelocity -= friction;
Jason Samsfd22dac2009-09-20 17:24:16 -0700190 g_PosVelocity = maxf(g_PosVelocity, 0);
Jason Sams86c87ed2009-09-18 13:55:55 -0700191 } else {
192 g_PosVelocity += friction;
Jason Samsfd22dac2009-09-20 17:24:16 -0700193 g_PosVelocity = minf(g_PosVelocity, 0);
Jason Sams86c87ed2009-09-18 13:55:55 -0700194 }
195 }
196 g_PosPage += g_PosVelocity * g_DT;
197
198 // Check for out of boundry conditions.
199 if (g_PosPage < 0 && g_PosVelocity < 0) {
Jason Sams0aa71662009-10-02 18:43:18 -0700200 float damp = 1.0 + (g_PosPage * 4);
Jason Sams86c87ed2009-09-18 13:55:55 -0700201 damp = clampf(damp, 0.f, 0.9f);
202 g_PosVelocity *= damp;
203 }
204 if (g_PosPage > (g_PageCount-1) && g_PosVelocity > 0) {
Jason Sams0aa71662009-10-02 18:43:18 -0700205 float damp = 1.0 - ((g_PosPage - g_PageCount + 1) * 4);
Jason Sams86c87ed2009-09-18 13:55:55 -0700206 damp = clampf(damp, 0.f, 0.9f);
207 g_PosVelocity *= damp;
208 }
209}
210
Joe Onorato0d1c5632009-08-28 15:57:18 -0700211float
212far_size(float sizeAt0)
213{
214 return sizeAt0 * (RADIUS+2) / 2; // -2 is the camera z=(z-camZ)/z
215}
216
Joe Onoratoefabe002009-08-28 09:38:18 -0700217void
Jason Samsfd22dac2009-09-20 17:24:16 -0700218draw_page(int icon, int lastIcon, float centerAngle, float scale)
Joe Onoratoefabe002009-08-28 09:38:18 -0700219{
220 int row;
221 int col;
222
Jason Sams86c87ed2009-09-18 13:55:55 -0700223 //debugF("center angle", centerAngle);
Joe Onorato85a02a82009-09-08 12:34:22 -0700224
Joe Onoratoefabe002009-08-28 09:38:18 -0700225 float iconTextureWidth = ICON_WIDTH_PX / (float)ICON_TEXTURE_WIDTH_PX;
226 float iconTextureHeight = ICON_HEIGHT_PX / (float)ICON_TEXTURE_HEIGHT_PX;
227
228 float iconWidthAngle = VIEW_ANGLE * ICON_WIDTH_PX / SCREEN_WIDTH_PX;
Jason Samsfd22dac2009-09-20 17:24:16 -0700229 float columnGutterAngle = iconWidthAngle * 0.9f;
Joe Onoratoefabe002009-08-28 09:38:18 -0700230
Joe Onorato6665c0f2009-09-02 15:27:24 -0700231 float farIconSize = FAR_ICON_SIZE;
Jason Samsfd22dac2009-09-20 17:24:16 -0700232 float iconGutterHeight = farIconSize * 1.3f;
Joe Onorato0d1c5632009-08-28 15:57:18 -0700233
Joe Onorato6665c0f2009-09-02 15:27:24 -0700234 float farIconTextureSize = far_size(2 * ICON_TEXTURE_WIDTH_PX / (float)SCREEN_WIDTH_PX);
235
Jason Sams78aebd82009-09-15 13:06:59 -0700236 float normalizedLabelWidth = 2 * params->bubbleWidth / (float)SCREEN_WIDTH_PX;
Jason Sams78aebd82009-09-15 13:06:59 -0700237 float farLabelHeight = far_size(params->bubbleHeight * (normalizedLabelWidth / params->bubbleWidth));
Joe Onoratoefabe002009-08-28 09:38:18 -0700238
239 for (row=0; row<ROWS_PER_PAGE && icon<=lastIcon; row++) {
240 float angle = centerAngle;
241 angle -= (columnGutterAngle + iconWidthAngle) * 1.5f;
242
Jason Samsfd22dac2009-09-20 17:24:16 -0700243 float iconTop = (farIconSize + iconGutterHeight) * (1.85f + ICON_TOP_OFFSET)
Joe Onorato0d1c5632009-08-28 15:57:18 -0700244 - row * (farIconSize + iconGutterHeight);
Joe Onoratoefabe002009-08-28 09:38:18 -0700245 float iconBottom = iconTop - farIconSize;
246
Jason Sams28870b72009-09-30 17:32:05 -0700247 float labelY = iconBottom - farLabelHeight;
Joe Onorato6665c0f2009-09-02 15:27:24 -0700248 float iconTextureTop = iconTop + (0.5f * (farIconTextureSize - farIconSize));
249 float iconTextureBottom = iconTextureTop - farIconTextureSize;
250
Joe Onoratoefabe002009-08-28 09:38:18 -0700251 for (col=0; col<COLUMNS_PER_PAGE && icon<=lastIcon; col++) {
252 // icon
253 float sine = sinf(angle);
254 float cosine = cosf(angle);
255
Joe Onorato0d1c5632009-08-28 15:57:18 -0700256 float centerX = sine * RADIUS;
Jason Samsfd22dac2009-09-20 17:24:16 -0700257 float centerZ = cosine * RADIUS / scale;
258
259 if (scale > 1.f) {
260 centerX *= scale;
261 }
Joe Onorato0d1c5632009-08-28 15:57:18 -0700262
Jason Sams28870b72009-09-30 17:32:05 -0700263 float iconLeftX = centerX - (/*cosine * */ farIconTextureSize * .5);
264 float iconRightX = centerX + (/*cosine * */ farIconTextureSize * .5);
265 float iconLeftZ = centerZ;// + (sine * farIconTextureSize * .5);
266 float iconRightZ = centerZ;// - (sine * farIconTextureSize * .5);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700267
Jason Samsfd22dac2009-09-20 17:24:16 -0700268 color(1.0f, 1.0f, 1.0f, 0.99f);
Jason Sams78aebd82009-09-15 13:06:59 -0700269 if (state->selectedIconIndex == icon) {
Jason Samscd689e12009-09-29 15:28:22 -0700270 bindTexture(NAMED_PFTexLinear, 0, state->selectedIconTexture);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700271 drawQuadTexCoords(
272 iconLeftX, iconTextureTop, iconLeftZ, 0.0f, 0.0f,
273 iconRightX, iconTextureTop, iconRightZ, 1.0f, 0.0f,
274 iconRightX, iconTextureBottom, iconRightZ, 1.0f, 1.0f,
275 iconLeftX, iconTextureBottom, iconLeftZ, 0.0f, 1.0f);
Joe Onorato1291a8c2009-09-15 15:07:25 -0400276 } else {
Jason Samscd689e12009-09-29 15:28:22 -0700277 bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_ICON_IDS, icon));
Joe Onorato1291a8c2009-09-15 15:07:25 -0400278 drawQuadTexCoords(
279 iconLeftX, iconTextureTop, iconLeftZ, 0.0f, 0.0f,
280 iconRightX, iconTextureTop, iconRightZ, 1.0f, 0.0f,
281 iconRightX, iconTextureBottom, iconRightZ, 1.0f, 1.0f,
282 iconLeftX, iconTextureBottom, iconLeftZ, 0.0f, 1.0f);
Joe Onorato6665c0f2009-09-02 15:27:24 -0700283 }
Joe Onoratoefabe002009-08-28 09:38:18 -0700284
Joe Onoratoefabe002009-08-28 09:38:18 -0700285 // label
Jason Samsfd22dac2009-09-20 17:24:16 -0700286 if (scale < 1.2f) {
Jason Sams28870b72009-09-30 17:32:05 -0700287 float a = (1.2f - maxf(scale, 1.0f)) * 5;
Jason Samsfd22dac2009-09-20 17:24:16 -0700288 color(1.0f, 1.0f, 1.0f, a);
Jason Samscd689e12009-09-29 15:28:22 -0700289 bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_LABEL_IDS, icon));
Jason Sams28870b72009-09-30 17:32:05 -0700290 drawSprite(centerX, labelY, centerZ,
291 params->bubbleBitmapWidth, params->bubbleBitmapHeight);
Joe Onorato85a02a82009-09-08 12:34:22 -0700292 }
Joe Onoratoefabe002009-08-28 09:38:18 -0700293
Joe Onoratoefabe002009-08-28 09:38:18 -0700294 angle += columnGutterAngle + iconWidthAngle;
295 icon++;
296 }
297 }
298}
299
Joe Onoratobcbeab82009-10-01 21:45:43 -0700300void
301draw_home_button()
302{
303 color(1.0f, 1.0f, 1.0f, 1.0f);
Joe Onoratod63458b2009-10-15 21:19:09 -0700304 bindTexture(NAMED_PFTexLinear, 0, state->homeButtonId);
Joe Onoratobcbeab82009-10-01 21:45:43 -0700305
306 float scale = 2.0f / SCREEN_WIDTH_PX;
307
308 float x = 0.0f;
309
310 float y = -(SCREEN_HEIGHT_PX / (float)SCREEN_WIDTH_PX);
311 y += g_Zoom * (scale * params->homeButtonTextureHeight / 2);
312
313 float z = 0.0f;
314 drawSprite(x, y, z, params->homeButtonTextureWidth, params->homeButtonTextureHeight);
315}
316
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700317int
Joe Onoratod769a632009-08-11 17:09:02 -0700318main(int launchID)
Joe Onorato93839052009-08-06 20:34:32 -0700319{
Jason Samsfd22dac2009-09-20 17:24:16 -0700320 // Compute dt in seconds.
Jason Sams86c87ed2009-09-18 13:55:55 -0700321 int newTime = uptimeMillis();
322 g_DT = (newTime - g_LastTime) / 1000.f;
323 g_LastTime = newTime;
Jason Sams86c87ed2009-09-18 13:55:55 -0700324
Jason Sams267d4fa2009-10-07 19:58:03 -0700325 if (!g_DrawLastFrame) {
326 // If we stopped rendering we cannot use DT.
327 // assume 30fps in this case.
328 g_DT = 0.033f;
329 }
330 if (g_DT > 0.2f) {
331 // physics may break if DT is large.
332 g_DT = 0.2f;
333 }
334
Joe Onorato26646342009-09-23 15:15:48 -0700335 //debugF("zoom", g_Zoom);
Jason Sams12c14a82009-10-06 14:33:15 -0700336 if (g_Zoom != state->zoomTarget) {
337 float dz = (state->zoomTarget - g_Zoom) * g_DT * 5;
Jason Samsfd22dac2009-09-20 17:24:16 -0700338 if (dz && (fabsf(dz) < 0.03f)) {
339 if (dz > 0) {
340 dz = 0.03f;
341 } else {
342 dz = -0.03f;
343 }
344 }
Jason Sams12c14a82009-10-06 14:33:15 -0700345 if (fabsf(g_Zoom - state->zoomTarget) < fabsf(dz)) {
346 g_Zoom = state->zoomTarget;
Jason Samsfd22dac2009-09-20 17:24:16 -0700347 } else {
348 g_Zoom += dz;
349 }
Jason Sams12c14a82009-10-06 14:33:15 -0700350 updateReadback();
Joe Onorato006b25f2009-09-03 11:38:43 -0700351 }
352
Jason Samsfd22dac2009-09-20 17:24:16 -0700353 // Set clear value to dim the background based on the zoom position.
Jason Sams12c14a82009-10-06 14:33:15 -0700354 if ((g_Zoom < 0.001f) && (state->zoomTarget < 0.001f)) {
Joe Onorato7bb17492009-09-24 17:51:01 -0700355 pfClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Joe Onorato360d0352009-09-28 14:37:53 -0400356 // When we're zoomed out and not tracking motion events, reset the pos to 0.
357 if (!g_LastTouchDown) {
358 g_PosPage = 0;
359 }
Jason Sams267d4fa2009-10-07 19:58:03 -0700360 return lastFrame(0);
Jason Sams28870b72009-09-30 17:32:05 -0700361 } else if (g_Zoom < 0.85f) {
Jason Samsfd22dac2009-09-20 17:24:16 -0700362 pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
Jason Samsfd22dac2009-09-20 17:24:16 -0700363 } else {
Joe Onoratobcbeab82009-10-01 21:45:43 -0700364 pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
Jason Samsfd22dac2009-09-20 17:24:16 -0700365 }
366
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700367 // icons & labels
Jason Sams78aebd82009-09-15 13:06:59 -0700368 int iconCount = state->iconCount;
Jason Sams86c87ed2009-09-18 13:55:55 -0700369 g_PageCount = count_pages(iconCount);
Joe Onorato43e7bcf2009-08-08 18:53:53 -0700370
Jason Sams86c87ed2009-09-18 13:55:55 -0700371 updatePos(0.1f);
Jason Sams12c14a82009-10-06 14:33:15 -0700372 updateReadback();
Joe Onoratod769a632009-08-11 17:09:02 -0700373
Jason Sams86c87ed2009-09-18 13:55:55 -0700374 //debugF(" draw g_PosPage", g_PosPage);
Joe Onoratod769a632009-08-11 17:09:02 -0700375
Joe Onoratoc567acb2009-08-31 14:34:43 -0700376 // Draw the icons ========================================
Joe Onoratoefabe002009-08-28 09:38:18 -0700377
378 // Bug makes 1.0f alpha fail.
379 color(1.0f, 1.0f, 1.0f, 0.99f);
380
Jason Samsa9d176c2009-10-06 16:02:03 -0700381 if (iconCount <= 0) {
Jason Sams267d4fa2009-10-07 19:58:03 -0700382 return lastFrame(0);
Jason Samsa9d176c2009-10-06 16:02:03 -0700383 }
Joe Onoratoefabe002009-08-28 09:38:18 -0700384 int lastIcon = iconCount-1;
385
Jason Sams86c87ed2009-09-18 13:55:55 -0700386 int page = g_PosPage;
387 float currentPagePosition = g_PosPage - page;
Joe Onoratod769a632009-08-11 17:09:02 -0700388
Joe Onoratod769a632009-08-11 17:09:02 -0700389 int iconsPerPage = COLUMNS_PER_PAGE * ROWS_PER_PAGE;
Joe Onoratoefabe002009-08-28 09:38:18 -0700390 int icon = clamp(iconsPerPage * page, 0, lastIcon);
Joe Onorato93839052009-08-06 20:34:32 -0700391
Jason Samsfd22dac2009-09-20 17:24:16 -0700392 float scale = (1 / g_Zoom);
Jason Sams78aebd82009-09-15 13:06:59 -0700393
Jason Samsfd22dac2009-09-20 17:24:16 -0700394 float pageAngle = VIEW_ANGLE * 1.2f;
395 draw_page(icon, lastIcon, -pageAngle*currentPagePosition, scale);
396 draw_page(icon+iconsPerPage, lastIcon, (-pageAngle*currentPagePosition)+pageAngle, scale);
Jason Sams86c87ed2009-09-18 13:55:55 -0700397
Joe Onorato56848b02009-09-25 13:59:59 -0700398 // Draw the border lines for debugging ========================================
399 /*
400 bindProgramVertex(NAMED_PVOrtho);
401 bindProgramFragment(NAMED_PFOrtho);
402 bindProgramFragmentStore(NAMED_PFSText);
403
404 color(1.0f, 1.0f, 0.0f, 0.99f);
405 int i;
406 for (i=0; i<ROWS_PER_PAGE+1; i++) {
407 int y = loadI32(ALLOC_Y_BORDERS, i);
408 drawRect(0, y, SCREEN_WIDTH_PX, y+1, 0.0f);
409 }
410 for (i=0; i<COLUMNS_PER_PAGE+1; i++) {
411 int x = loadI32(ALLOC_X_BORDERS, i);
412 drawRect(x, 0, x+1, SCREEN_HEIGHT_PX, 0.0f);
413 }
414 */
Joe Onorato6665c0f2009-09-02 15:27:24 -0700415
Joe Onoratobcbeab82009-10-01 21:45:43 -0700416 // Draw the home button ========================================
417 draw_home_button();
418
Joe Onorato6665c0f2009-09-02 15:27:24 -0700419 /*
Joe Onorato56848b02009-09-25 13:59:59 -0700420 bindTexture(NAMED_PFOrtho, 0, loadI32(ALLOC_PARAMS, PARAM_SCROLL_HANDLE_ID));
Joe Onoratoc567acb2009-08-31 14:34:43 -0700421 float handleLeft = 40 + (320 * (scrollXPx/(float)(maxScrollXPx)));
422 float handleTop = 680;
423 float handleWidth = loadI32(ALLOC_PARAMS, PARAM_SCROLL_HANDLE_TEX_WIDTH);
424 float handleHeight = loadI32(ALLOC_PARAMS, PARAM_SCROLL_HANDLE_TEX_HEIGHT);
425 drawRect(handleLeft, handleTop, handleLeft+handleWidth, handleTop+handleHeight, 0.0f);
426 */
Joe Onorato93839052009-08-06 20:34:32 -0700427
Jason Sams86c87ed2009-09-18 13:55:55 -0700428 // Bug workaround where the last frame is not always displayed
Jason Samsfd22dac2009-09-20 17:24:16 -0700429 // So we keep rendering until the bug is fixed.
Jason Sams267d4fa2009-10-07 19:58:03 -0700430 return lastFrame((g_PosVelocity != 0) || fracf(g_PosPage) || (g_Zoom != state->zoomTarget));
Joe Onorato93839052009-08-06 20:34:32 -0700431}
432