summaryrefslogtreecommitdiff
path: root/rubik.c
diff options
context:
space:
mode:
authorDavid Mikos <metastability@opencompositing.org>2008-01-12 11:12:32 +1030
committerDavid Mikos <metastability@opencompositing.org>2008-01-12 11:12:32 +1030
commitefd6804ea24aef32bb9f983eb54b3a3ec0c4c307 (patch)
treec7b844247dae425480459779db01f37e2f10929f /rubik.c
parentc8986593fc2b1af3ba507aa2d1d462b0f5cfa992 (diff)
downloadrubik-efd6804ea24aef32bb9f983eb54b3a3ec0c4c307.tar.gz
rubik-efd6804ea24aef32bb9f983eb54b3a3ec0c4c307.tar.bz2
Windows contents on all viewports rotate with Rubik's cube.
Diffstat (limited to 'rubik.c')
-rw-r--r--rubik.c92
1 files changed, 74 insertions, 18 deletions
diff --git a/rubik.c b/rubik.c
index 2f0ade6..81b52ff 100644
--- a/rubik.c
+++ b/rubik.c
@@ -287,33 +287,64 @@ static void rubikPaintInside (CompScreen *s,
if (rs->initiated && rubikGetRotateDesktop(s)) {
Bool coloredSides = rubikGetColoredSides(s);
- int winCounter = 0;
+ int winCounter = 0, screenCounter = 0;
+
CompWindow *w;
+ //CompScreen *screen;
+
+ int screenX = s->x;
+
+ int viewport;
int numWindows=1;
+
if (!coloredSides) {
- for (w = s->windows; w; w = w->next) {
+ moveScreenViewport (s, screenX, 0, FALSE);
+
+ for (viewport = 0; viewport<4; viewport++) {
+ moveScreenViewport (s, -1, 0, FALSE);
+
+ int tempNumWindows = 0;
+ if (!coloredSides) {
+ for (w = s->windows; w; w = w->next) {
if (w->destroyed) continue;
if (w->hidden) continue;
if (w->invisible) continue;
- if (!w->desktop && !rubikGetPaintWindowContents(s)) continue;
-
- numWindows++;
+ //if (!w->desktop && !rubikGetPaintWindowContents(s)) continue;
+
+ tempNumWindows++;
+ }
}
+ if (tempNumWindows > numWindows) numWindows = tempNumWindows;
+ }
}
+
+ //if (!coloredSides)
+ // moveScreenViewport (s, screenX, 0, FALSE);
+
+ for (viewport = 0; viewport<4; viewport++) {
+ if (screenCounter>0 && coloredSides)
+ break;
+
+ if (screenCounter>0 && !coloredSides)
+ moveScreenViewport (s, -1, 0, FALSE);
+
+ screenCounter++;
+ winCounter = 0;
+
for (w = s->windows; w; w = w->next) {
if (!coloredSides) {
if (w->destroyed) continue;
if (w->hidden) continue;
if (w->invisible) continue;
- if (!w->desktop && !rubikGetPaintWindowContents(s)) continue;
+ //if (!w->desktop && !rubikGetPaintWindowContents(s)) continue;
enableTexture (s, w->texture,
COMP_TEXTURE_FILTER_GOOD);
- glEnable (w->texture->target);
+ //glEnable (w->texture->target);
}
else {
if (winCounter>0)
@@ -366,10 +397,18 @@ static void rubikPaintInside (CompScreen *s,
glColor4fv (rs->faces[square->side].color);
else if (!rubikGetDesktopCaps(s) && square->side>=4)
continue;
- else if (!w->desktop) {
- float winX = WIN_REAL_X(w) + WIN_REAL_W(w)/2.0+w->screen->x*w->screen->width;
- float screenW = w->screen->width;
- if (((int) (winX/screenW))!=square->side)
+ else {
+ //float winX = WIN_REAL_X(w) + WIN_REAL_W(w)/2.0+((screen->x+screenCounter-1)%hSize)*w->screen->width;
+ //float screenW = w->screen->width;
+
+ //printf ("%i, %i\n", ((int) (winX/screenW)), w->screen->x);
+ //if (((int) (winX/screenW))!=square->side)
+
+ if (windowOnAllViewports (w) && rubikGetDesktopCaps(s) && square->side>=4) {
+ if (viewport!=screenX)
+ continue;
+ }
+ else if (viewport != square->side)
continue;
}
@@ -456,6 +495,7 @@ static void rubikPaintInside (CompScreen *s,
if (i==3)
glRotatef (face->side[index]*90, 0, 1, 0);
*/
+ //glTranslatef (0,0,0.5-0.00005*(numWindows+1-winCounter)); //allow for layers
glTranslatef (0,0,0.5-0.00005*(numWindows+1-winCounter)); //allow for layers
@@ -511,21 +551,33 @@ static void rubikPaintInside (CompScreen *s,
if (wh1<wh2 && wv1<wv2) {
- h1 -= y;
- h2 = (h2-y)/height;
wh1-= y;
wh2-= y;
-
-
+
+ h1 = wh1/height;
+ h2 = wh2/height;
wh1+=((float) hs-square->y )/((float) hStrips);
wh2+=((float) hs-square->y )/((float) hStrips);
- v1 -= x;
- v2 = (v2-x)/width;
+ //h2 = (h2-y)/height;
+ //h2 += y;
+
+
+
+
+
+ //v1 = x;
+ //v2 = (v2-x)/width;
+ //v2 -= x/width;
+
+ v1 = (wv1-x)/width;
+ v2 = (wv2-x)/width;
+
wv1+= x;
wv2+= x;
+
wv1+=((float) vs-square->x )/((float) vStrips);
wv2+=((float) vs-square->x )/((float) vStrips);
@@ -559,6 +611,7 @@ static void rubikPaintInside (CompScreen *s,
}
else {
if (i>=4) continue;
+ if (!w->desktop) continue;
for (vs=0; vs<vStrips; vs++) {
@@ -619,7 +672,10 @@ static void rubikPaintInside (CompScreen *s,
if (!coloredSides) {
disableTexture (s, w->texture);
}
- }
+ }
+ }
+ if (!coloredSides)
+ moveScreenViewport (s, -screenX-1, 0, FALSE);
}
glPopMatrix();