diff options
author | David Mikos <david@FAMILYCOMPUTER.(none)> | 2008-07-12 13:46:24 +0930 |
---|---|---|
committer | David Mikos <david@FAMILYCOMPUTER.(none)> | 2008-07-12 13:46:24 +0930 |
commit | 7a434c291293eb5720cd90cb1ce5f4aa5a8c6939 (patch) | |
tree | 29e27b82c7f5c2acf12262d9d3c5a367ce690e16 | |
parent | debea570dc39428eaaa0cc0bfe6323660ce17d95 (diff) | |
download | rubik-master.tar.gz rubik-master.tar.bz2 |
-rw-r--r-- | rubik-internal.h | 13 | ||||
-rw-r--r-- | rubik.c | 1556 | ||||
-rw-r--r-- | rubik.xml.in | 15 |
3 files changed, 755 insertions, 829 deletions
diff --git a/rubik-internal.h b/rubik-internal.h index e012ace..75e71e8 100644 --- a/rubik-internal.h +++ b/rubik-internal.h @@ -66,6 +66,9 @@ extern int cubeDisplayPrivateIndex; #define YELLOW 12 #define WHITE 13 +typedef struct _orderedFaceRec orderedFaceRec; + + typedef struct _RubikDisplay { int screenPrivateIndex; @@ -82,7 +85,6 @@ typedef struct _squareRec } squareRec; - typedef struct _faceRec { float color[4]; @@ -91,6 +93,12 @@ typedef struct _faceRec } faceRec; +struct _orderedFaceRec +{ //not used yet + squareRec *square; + orderedFaceRec *nextOrderedFace; + CompWindow *w; +}; typedef struct _RubikScreen @@ -131,6 +139,8 @@ typedef struct _RubikScreen float *psi; float *oldPsi; + float desktopOpacity; + CompWindow ** w; Box * oldClip; @@ -142,7 +152,6 @@ typedef struct _RubikScreen float radius; //radius on which the hSize points lie float speedFactor; // multiply rotation speed by this value - } RubikScreen; @@ -5,7 +5,7 @@ * * This plugin allows the cube to transform as a Rubik's cube. * - * Written in 2008 by David Mikos + * Copyright : (C) 2008 by David Mikos * * * This program is free software; you can redistribute it and/or @@ -20,9 +20,8 @@ * */ -/* - * Loosely based on freewins, atlantis, and anaglyph. - * Some texture code from cubedbus. +/* NOTE: at the moment this plugin includes some dirty hacks to + * achieve the Rubik's cube effect. The code is somewhat messy. */ #include <stdlib.h> @@ -221,712 +220,830 @@ rubikClearTargetOutput (CompScreen *s, } -static void rubikPaintInside (CompScreen *s, - const ScreenPaintAttrib *sAttrib, - const CompTransform *transform, - CompOutput *output, - int size) +/* Cut down version of moveScreenViewport in cube.c + * + * This code should be avoided in the future. + * It's here temporarily so that windowMoveNotify, etc are not called. + */ + +static void rubikMoveScreenViewport (CompScreen *, int); + +static void +rubikMoveScreenViewport (CompScreen *s, + int tx) { - RUBIK_SCREEN (s); - CUBE_SCREEN (s); + //return; + + CompWindow *w; + int wx, wy; - if (rs->hsize!=s->hsize) updateRubik (s); + tx = s->x - tx; + tx = MOD (tx, s->hsize); + tx -= s->x; - - /*static const float mat_shininess[] = { 60.0 }; - static const float mat_specular[] = { 0.8, 0.8, 0.8, 1.0 }; - static const float mat_diffuse[] = { 0.46, 0.66, 0.795, 1.0 }; - static const float mat_ambient[] = { 0.1, 0.1, 0.3, 1.0 }; - static const float lmodel_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; - static const float lmodel_localviewer[] = { 0.0 };*/ - - ScreenPaintAttrib sA = *sAttrib; - CompTransform mT = *transform; + if (!tx) + return; + + s->x += tx; + + tx *= -s->width; - sA.yRotate += cs->invert * (360.0f / size) * - (cs->xRotations - (s->x * cs->nOutput)); + for (w = s->windows; w; w = w->next) + { + if (windowOnAllViewports (w)) + continue; + + getWindowMovementForOffset (w, tx, 0, &wx, &wy); - (*s->applyScreenTransform) (s, &sA, output, &mT); + if (w->saveMask & CWX) + w->saveWc.x += wx; - glPushMatrix(); + if (wx) + { + w->attrib.x += wx; - glLoadMatrixf (mT.m); + w->matrix = w->texture->matrix; + w->matrix.x0 -= (w->attrib.x * w->matrix.xx); + w->matrix.y0 -= (w->attrib.y * w->matrix.yy); - glTranslatef (cs->outputXOffset, -cs->outputYOffset, 0.0f); + w->invisible = WINDOW_INVISIBLE (w); + } + } +} - glScalef (cs->outputXScale, cs->outputYScale, 1.0f); - Bool enabledCull = FALSE; +static void +rubikPaintInside (CompScreen *s, + const ScreenPaintAttrib *sAttrib, + const CompTransform *transform, + CompOutput *output, + int size) +{ + RUBIK_SCREEN (s); + CUBE_SCREEN (s); - glPushAttrib (GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT | GL_LIGHTING_BIT); + int i, j; + + if (rs->hsize!=s->hsize) updateRubik (s); - glEnable (GL_BLEND); - if (glIsEnabled (GL_CULL_FACE)) - { - enabledCull = TRUE; + ScreenPaintAttrib sA = *sAttrib; + CompTransform mT = *transform; + + sA.yRotate += cs->invert * (360.0f / size) * + (cs->xRotations - (s->x * cs->nOutput)); + + (*s->applyScreenTransform) (s, &sA, output, &mT); + + glPushMatrix(); + + glLoadMatrixf (mT.m); + + glTranslatef (cs->outputXOffset, -cs->outputYOffset, 0.0f); + + glScalef (cs->outputXScale, cs->outputYScale, 1.0f); + + Bool enabledCull = FALSE; + + glPushAttrib (GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT | GL_LIGHTING_BIT); + + + glEnable (GL_BLEND); + + + + if (glIsEnabled (GL_CULL_FACE)) + { + enabledCull = TRUE; + } + + int cull; + + glGetIntegerv (GL_CULL_FACE_MODE, &cull); + glEnable (GL_CULL_FACE); + + glCullFace (~cull & (GL_FRONT | GL_BACK)); + + glPushMatrix(); + + + glEnable (GL_NORMALIZE); + //glEnable (GL_LIGHTING); + //glEnable (GL_LIGHT1); + //glEnable (GL_LIGHT0); + + if (rs->initiated) { + + Bool coloredSides = rubikGetColoredSides(s); + + CompWindow *w; + //CompScreen *screen; + + int screenX = s->x; + + int viewport; + + + + + + + + + float xRot, vRot, progress; + (*cs->getRotation) (s, &(xRot), &(vRot), &progress); + + xRot = fmodf( xRot-cs->invert * (360.0f / s->hsize) * + ((s->x* cs->nOutput)), 360 ); + //printf ("%f", xRot); + //printf (" %f\n", vRot); + + int fv[6]; + float fvd[6]; + + float temp; + + fv[0] = 0; + fvd[0] = cos(xRot*toRadians)*cos(vRot*toRadians); + + //find farthest viewport (bubble sort) + for (viewport = 1; viewport<6; viewport++) { + if (viewport<4) + { + xRot = fmodf( xRot-cs->invert * (360.0f / s->hsize) * + ((-1* cs->nOutput)), 360 ); + temp = cos(xRot*toRadians)*cos(vRot*toRadians); + } + else if (viewport==4) + temp = sin(vRot*toRadians); + else + temp = -sin(vRot*toRadians); + + // printf (", %f", xRot); + + int vp; + + + fv[viewport] = viewport; + fvd[viewport] = temp; + + for (vp = 0; vp<viewport; vp++) + { + if (temp<fvd[vp]) + { + for (i=viewport; i>vp; i--) + { + float tfvd = fvd[i]; + fvd[i] = fvd[i-1]; + fvd[i-1] = tfvd; + + int tfv = fv[i]; + fv[i] = fv[i-1]; + fv[i-1] = tfv; + } + + break; + } + } } + //printf ("\n"); + //printf ("%i, %i, %i, %i\n", fv[0], fv[1], fv[2], fv[3]); + //printf ("%f, %f, %f, %f\n\n", fvd[0], fvd[1], fvd[2], fvd[3]); - int cull; + + + int numWindows=1; + + if (!coloredSides) { + rubikMoveScreenViewport (s, screenX); - glGetIntegerv (GL_CULL_FACE_MODE, &cull); - glEnable (GL_CULL_FACE); + for (viewport = 0; viewport<4; viewport++) { + rubikMoveScreenViewport (s, -1); - glCullFace (~cull & (GL_FRONT | GL_BACK)); + 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; + tempNumWindows++; + } + } + if (tempNumWindows > numWindows) numWindows = tempNumWindows; + } + rubikMoveScreenViewport (s, -screenX); - glPushMatrix(); + } - /*glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); - glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); - glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse); - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); - glLightModelfv (GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); - glLightModelfv (GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer); - */ - glEnable (GL_NORMALIZE); - //glEnable (GL_LIGHTING); - //glEnable (GL_LIGHT1); - //glEnable (GL_LIGHT0); + if (!coloredSides) + rubikMoveScreenViewport (s, screenX); - if (rs->initiated && rubikGetRotateDesktop(s)) { + for (j=0; j < 6; j++) { + + i = fv[j]; - Bool coloredSides = rubikGetColoredSides(s); int winCounter = 0, screenCounter = 0; - - CompWindow *w; - //CompScreen *screen; - int screenX = s->x; + + for (viewport = 0; viewport<4; viewport++) { + if (screenCounter>0 && coloredSides) + break; + + if (screenCounter>0 && !coloredSides) + { + //rubikMoveScreenViewport (s, viewport-1); + //rubikMoveScreenViewport (s, -viewport); + } + + //if (viewport>0) continue; + + screenCounter++; + winCounter = 0; - int viewport; - int numWindows=1; + + for (w = (cs->invert>0 ? s->windows : s->reverseWindows); w; + w = (cs->invert>0 ? w->next : w->prev)) { + + int attrX = 0, attrY = 0; //window x, y attributes if (!coloredSides) { - moveScreenViewport (s, screenX, 0, FALSE); - for (viewport = 0; viewport<4; viewport++) { - moveScreenViewport (s, -1, 0, FALSE); + attrX = (w)->attrib.x; + attrY = (w)->attrib.y; - 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; - tempNumWindows++; - } - } - if (tempNumWindows > numWindows) numWindows = tempNumWindows; - } - } + int tx = s->x +viewport-s->x; + tx = MOD (tx, s->hsize); + tx -= s->x; - //if (!coloredSides) - // moveScreenViewport (s, screenX, 0, FALSE); + int ty = 0; - - for (viewport = 0; viewport<4; viewport++) { - if (screenCounter>0 && coloredSides) - break; + //s->x += tx; - if (screenCounter>0 && !coloredSides) - moveScreenViewport (s, -1, 0, FALSE); - - screenCounter++; - winCounter = 0; - - for (w = (cs->invert>0 ? s->windows : s->reverseWindows); w; - w = (cs->invert>0 ? w->next : w->prev)) { - if (!coloredSides) { - - if (w->destroyed) continue; - if (w->hidden) continue; - if (w->invisible) continue; - //if (!w->desktop && !rubikGetPaintWindowContents(s)) continue; - - enableTexture (s, w->texture, - COMP_TEXTURE_FILTER_GOOD); - - //glEnable (w->texture->target); - } - else { - if (winCounter>0) - break; - } - winCounter++; - - glEnable (GL_NORMALIZE); - glDisable (GL_COLOR_MATERIAL); - glDisable (GL_CULL_FACE); - glEnable (GL_TEXTURE_2D); - glEnable (GL_DEPTH_TEST); - - if (coloredSides) { - glEnable (GL_COLOR_MATERIAL); - glDisable (GL_TEXTURE_2D); - } + tx *= -s->width; - // draw texture + int wx, wy; - float width = ((float) w->width) /((float) s->width); - float height = ((float) w->height)/((float) s->height); + if (!windowOnAllViewports (w) && viewport>0) + { - if (coloredSides) { - width = 1; - height = 1; - } - int texWidth = 1;//(rs->w[0].width)/vStrips; - int texHeight = 1;//(rs->w[0].height)/vStrips; + getWindowMovementForOffset (w, tx, ty, &wx, &wy); - - int i, hs, vs; - for (i=0; i < 6; i++) { - - - if (coloredSides) - glColor4fv (rs->faces[i].color); - - - if (rubikGetRotateAllAxes(s)) { - - for (vs=0; vs<vStrips; vs++) { - - for (hs=0; hs<hStrips; hs++) { - - int index = hs*hStrips+vs; - squareRec * square = &(rs->faces[i].square[index]); - - if (coloredSides) - glColor4fv (rs->faces[square->side].color); - else if (!rubikGetDesktopCaps(s) && square->side>=4) - continue; - else { - //float winX = WIN_REAL_X(w) + WIN_REAL_W(w)/2.0+((screen->x+screenCounter-1)%rs->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; - } - - glPushMatrix(); - - if (cs->invert<0) { - glRotatef (180,0,0,1); - glRotatef (180,1,0,0); - glScalef(-1.0f, 1.0f, 1.0f); - } - - if(rotationAxis==0) { - if (i<4) { - if (hs == currentHStrip) - glRotatef (currentStripCounter*currentStripDirection,0,1,0); - } - else if (i==4) { - if (currentHStrip==0) - glRotatef (currentStripCounter*currentStripDirection,0,1,0); - } - else if (i==5) { - if (currentHStrip==hStrips-1) - glRotatef (currentStripCounter*currentStripDirection,0,1,0); - } - } - else if(rotationAxis==1) { - if (i==3) { - if (currentHStrip==0) - glRotatef (-currentStripCounter*currentStripDirection,1,0,0); - } - else if (i==1) { - if (currentHStrip==hStrips-1) - glRotatef (-currentStripCounter*currentStripDirection,1,0,0); - } - else if (i==2){ - if (vStrips-1-vs == currentHStrip) - glRotatef (-currentStripCounter*currentStripDirection,1,0,0); - } - else { - if (vs == currentHStrip) - glRotatef (-currentStripCounter*currentStripDirection,1,0,0); - } - } - else if(rotationAxis==2) { - if (i==0) { - if (currentHStrip==0) - glRotatef (-currentStripCounter*currentStripDirection,0,0,1); - } - else if (i==1){ - if (vs == currentHStrip) - glRotatef (-currentStripCounter*currentStripDirection,0,0,1); - } - else if (i==2) { - if (currentHStrip==hStrips-1) - glRotatef (-currentStripCounter*currentStripDirection,0,0,1); - } - else if (i==3){ - if (vStrips-1-vs == currentHStrip) - glRotatef (-currentStripCounter*currentStripDirection,0,0,1); - } - else if (i==4){ - if (hStrips-1-hs == currentHStrip) - glRotatef (-currentStripCounter*currentStripDirection,0,0,1); - } - else if (i==5){ - if (hs == currentHStrip) - glRotatef (-currentStripCounter*currentStripDirection,0,0,1); - } - - } - - if (i<4) - glRotatef (90*i, 0, 1, 0); - else if (i==4) - glRotatef (-90, 1, 0, 0); - else if (i==5) { - glRotatef (90, 1, 0, 0); - //glRotatef (180, 0, 0, 1); - } - - - - /*if (i==0) - glRotatef (face->side[index]*90, 0, 1, 0); - if (i==2) - glRotatef (face->side[index]*90, 0, 1, 0); - if (i==1) - glRotatef (face->side[index]*90, 0, 1, 0); - 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 + tx=wx; + //ty=wy; + //if (w->saveMask & CWX) + // w->saveWc.x += wx; - glTranslatef (-0.5,0,0); - glTranslatef (0,0.5,0); + //if (w->saveMask & CWY) + // w->saveWc.y += wy; - glTranslatef (((float) vs+0.5 )/((float) hStrips),0,0); - glTranslatef (0,-((float) hs+0.5 )/((float) vStrips),0); - glRotatef (90*square->psi, 0, 0, 1); - - //glRotatef (90*NRAND(4), 0, 0, 1); - glTranslatef (-((float) vs+0.5 )/((float) hStrips),0,0); - glTranslatef (0,((float) hs+0.5 )/((float) vStrips),0); + //XOffsetRegion (w->region, dx, dy); - if (!coloredSides) { - glTranslatef (-((float) w->attrib.x)/((float) s->width),0,0); - glTranslatef (0,-((float) w->attrib.y)/((float) s->height),0); - } + attrX = (w)->attrib.x+tx; + //w->matrix = w->texture->matrix; + //w->matrix.x0 -= (w->attrib.x * w->matrix.xx); + //w->matrix.y0 -= (w->attrib.y * w->matrix.yy); - float h1 = ((float) square->y )/((float) hStrips); - float h2 = ((float) square->y+1 )/((float) hStrips); - - float v1 = ((float) square->x )/((float) vStrips); - float v2 = ((float) square->x+1 )/((float) vStrips); - float y = 0; - if (!coloredSides) - y = ((float) w->attrib.y)/((float) s->height); +#define RUBIK_WINDOW_INVISIBLE(w) \ + ((w)->attrib.map_state != IsViewable || \ + (!(w)->damaged) || \ + attrX + (w)->width + (w)->output.right <= 0 || \ + (w)->attrib.y + (w)->height + (w)->output.bottom <= 0 || \ + attrX - (w)->output.left >= (w)->screen->width || \ + (w)->attrib.y - (w)->output.top >= (w)->screen->height) - float x = 0; - if (!coloredSides) - x = ((float) w->attrib.x)/((float) s->width); - - float wh1 = MAX (y, h1); - float wh2 = MIN (y+height, h2); - - float wv1 = MAX (x, v1); - float wv2 = MIN (x+width, v2); + w->invisible = RUBIK_WINDOW_INVISIBLE (w); + } - if (y>h1) - h1=y; - if (y+height<h2) - h2=y+height; + if (w->destroyed) continue; + if (w->hidden) continue; + if (w->invisible) continue; + //if (!w->desktop && !rubikGetPaintWindowContents(s)) continue; - if (x>v1) - v1=x; - if (x+width<v2) - v2=x+width; + if (w->type & CompWindowTypeDesktopMask) + { + glEnable(GL_COLOR_MATERIAL); + glColor4us (0xffff, 0xffff, 0xffff, rs->desktopOpacity); - - if (wh1<wh2 && wv1<wv2) { + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - wh1-= y; - wh2-= y; + } + else + { + glEnable(GL_COLOR_MATERIAL); + glColor4us (0xffff, 0xffff, 0xffff, 0xffff); - h1 = wh1/height; - h2 = wh2/height; - - wh1+=((float) hs-square->y )/((float) hStrips); - wh2+=((float) hs-square->y )/((float) hStrips); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + enableTexture (s, w->texture, + COMP_TEXTURE_FILTER_GOOD); - //h2 = (h2-y)/height; - //h2 += y; - - + //glEnable (w->texture->target); + } + else { + if (winCounter>0) + break; + } + winCounter++; + + glEnable (GL_NORMALIZE); + glDisable (GL_COLOR_MATERIAL); + glDisable (GL_CULL_FACE); + glEnable (GL_TEXTURE_2D); + glEnable (GL_DEPTH_TEST); + + if (coloredSides) { + glEnable (GL_COLOR_MATERIAL); + glDisable (GL_TEXTURE_2D); + } + + // draw texture + + float width = ((float) w->width) /((float) s->width); + float height = ((float) w->height)/((float) s->height); + + if (coloredSides) { + width = 1; + height = 1; + } + int texWidth = 1;//(rs->w[0].width)/vStrips; + int texHeight = 1;//(rs->w[0].height)/vStrips; - - - //v1 = x; - //v2 = (v2-x)/width; - //v2 -= x/width; - - v1 = (wv1-x)/width; - v2 = (wv2-x)/width; - wv1+= x; - wv2+= x; + int hs, vs; - - wv1+=((float) vs-square->x )/((float) vStrips); - wv2+=((float) vs-square->x )/((float) vStrips); + if (coloredSides) + glColor4fv (rs->faces[i].color); - - glBegin(GL_QUADS); + for (vs=0; vs<vStrips; vs++) { - glNormal3f (1,1,0); - glTexCoord2f (v1*texWidth, h1*texHeight); - glVertex3f( wv1, -wh1,0 ); // Top Left Of The Texture and Quad + for (hs=0; hs<hStrips; hs++) { - //glNormal3f (0,0,1); - glTexCoord2f (v2*texWidth, h1*texHeight); - glVertex3f( wv2, -wh1,0); // Top Right Of The Texture and Quad + int index = hs*hStrips+vs; + squareRec * square = &(rs->faces[i].square[index]); - //glNormal3f (0,0,1); - glTexCoord2f (v2*texWidth, h2*texHeight); - glVertex3f( wv2, -wh2,0); // Bot Right Of The Texture and Quad + if (coloredSides) + glColor4fv (rs->faces[square->side].color); + else if (!rubikGetDesktopCaps(s) && square->side>=4) + continue; + else { + //float winX = WIN_REAL_X(w) + WIN_REAL_W(w)/2.0+((screen->x+screenCounter-1)%rs->hsize)*w->screen->width; + //float screenW = w->screen->width; - //glNormal3f (0,0,1); - glTexCoord2f ( v1*texWidth, h2*texHeight); - glVertex3f( wv1,-wh2,0); + //printf ("%i, %i\n", ((int) (winX/screenW)), w->screen->x); + //if (((int) (winX/screenW))!=square->side) - glEnd(); - } - - glPopMatrix(); - } - } + if (windowOnAllViewports (w) && rubikGetDesktopCaps(s) && square->side>=4) { + if (viewport!=screenX) + continue; + } + else if (viewport != square->side) + continue; + } + + glPushMatrix(); + + if (cs->invert<0) { + glRotatef (180,0,0,1); + glRotatef (180,1,0,0); + glScalef(-1.0f, 1.0f, 1.0f); + } + + if(rotationAxis==0) { + if (i<4) { + if (hs == currentHStrip) + glRotatef (currentStripCounter*currentStripDirection,0,1,0); + } + else if (i==4) { + if (currentHStrip==0) + glRotatef (currentStripCounter*currentStripDirection,0,1,0); + } + else if (i==5) { + if (currentHStrip==hStrips-1) + glRotatef (currentStripCounter*currentStripDirection,0,1,0); + } + } + else if(rotationAxis==1) { + if (i==3) { + if (currentHStrip==0) + glRotatef (-currentStripCounter*currentStripDirection,1,0,0); + } + else if (i==1) { + if (currentHStrip==hStrips-1) + glRotatef (-currentStripCounter*currentStripDirection,1,0,0); + } + else if (i==2){ + if (vStrips-1-vs == currentHStrip) + glRotatef (-currentStripCounter*currentStripDirection,1,0,0); } else { - if (i>=4) continue; - if (!w->desktop) continue; - - for (vs=0; vs<vStrips; vs++) { + if (vs == currentHStrip) + glRotatef (-currentStripCounter*currentStripDirection,1,0,0); + } + } + else if(rotationAxis==2) { + if (i==0) { + if (currentHStrip==0) + glRotatef (-currentStripCounter*currentStripDirection,0,0,1); + } + else if (i==1){ + if (vs == currentHStrip) + glRotatef (-currentStripCounter*currentStripDirection,0,0,1); + } + else if (i==2) { + if (currentHStrip==hStrips-1) + glRotatef (-currentStripCounter*currentStripDirection,0,0,1); + } + else if (i==3){ + if (vStrips-1-vs == currentHStrip) + glRotatef (-currentStripCounter*currentStripDirection,0,0,1); + } + else if (i==4){ + if (hStrips-1-hs == currentHStrip) + glRotatef (-currentStripCounter*currentStripDirection,0,0,1); + } + else if (i==5){ + if (hs == currentHStrip) + glRotatef (-currentStripCounter*currentStripDirection,0,0,1); + } + + } + + if (i<4) + glRotatef (90*i, 0, 1, 0); + else if (i==4) + glRotatef (-90, 1, 0, 0); + else if (i==5) { + glRotatef (90, 1, 0, 0); + //glRotatef (180, 0, 0, 1); + } - glPushMatrix(); - glRotatef (90*i, 0, 1, 0); - if (i==0) - glRotatef (rs->th[vs], 1, 0, 0); + /*if (i==0) + glRotatef (face->side[index]*90, 0, 1, 0); if (i==2) - glRotatef (-rs->th[vStrips-vs-1], 1, 0, 0); + glRotatef (face->side[index]*90, 0, 1, 0); if (i==1) - glRotatef (rs->th[vStrips-1], 0, 0, 1); + glRotatef (face->side[index]*90, 0, 1, 0); if (i==3) - glRotatef (-rs->th[0], 0, 0, 1); + 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 - if (coloredSides) { - glTranslatef (-0.5,0,0); - glTranslatef (0,0.5,0); - } - else { - glTranslatef (-((float) w->attrib.x)/((float) s->width)-0.5,0,0); - glTranslatef (0,-((float) w->attrib.y)/((float) s->height)+0.5,0); - } + glTranslatef (-0.5,0,0); + glTranslatef (0,0.5,0); - float s1 = ((float) vs )/((float) vStrips); - float s2 = ((float) vs+1 )/((float) vStrips); + glTranslatef (((float) vs+0.5 )/((float) hStrips),0,0); + glTranslatef (0,-((float) hs+0.5 )/((float) vStrips),0); - glBegin(GL_QUADS); + glRotatef (90*square->psi, 0, 0, 1); - glNormal3f (1,1,0); - glTexCoord2f (s1*texWidth, 0); - glVertex3f( s1*width, 0,0 ); // Top Left Of The Texture and Quad + //glRotatef (90*NRAND(4), 0, 0, 1); + glTranslatef (-((float) vs+0.5 )/((float) hStrips),0,0); + glTranslatef (0,((float) hs+0.5 )/((float) vStrips),0); - //glNormal3f (0,0,1); - glTexCoord2f (s2*texWidth, 0); - glVertex3f( s2*width, 0,0); // Top Right Of The Texture and Quad + if (!coloredSides) { + glTranslatef (-((float) attrX)/((float) s->width),0,0); + glTranslatef (0,-((float) attrY)/((float) s->height),0); + } - //glNormal3f (0,0,1); - glTexCoord2f (s2*texWidth, texHeight); - glVertex3f( s2*width, -height,0); // Bot Right Of The Texture and Quad - //glNormal3f (0,0,1); - glTexCoord2f ( s1*texWidth, texHeight); - glVertex3f( s1*width,-height,0); + float h1 = ((float) square->y )/((float) hStrips); + float h2 = ((float) square->y+1 )/((float) hStrips); - glEnd(); - - - glPopMatrix(); - } - } + float v1 = ((float) square->x )/((float) vStrips); + float v2 = ((float) square->x+1 )/((float) vStrips); + + float y = 0; + if (!coloredSides) + y = ((float) attrY)/((float) s->height); + + float x = 0; + if (!coloredSides) + x = ((float) attrX)/((float) s->width); + + + float wh1 = MAX (y, h1); + float wh2 = MIN (y+height, h2); + + float wv1 = MAX (x, v1); + float wv2 = MIN (x+width, v2); + + if (y>h1) + h1=y; + if (y+height<h2) + h2=y+height; + + if (x>v1) + v1=x; + if (x+width<v2) + v2=x+width; - } - if (!coloredSides) { - disableTexture (s, w->texture); + if (wh1<wh2 && wv1<wv2) { + + 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 = (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); + + //glColor4us (0xffff, 0xffff, 0xffff, cs->desktopOpacity); + //glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + //glEnable (GL_COLOR_MATERIAL); + //glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glBegin(GL_QUADS); + + glTexCoord2f (v1*texWidth, h1*texHeight); + glVertex3f( wv1, -wh1,0 ); // Top Left Of The Texture and Quad + + glTexCoord2f (v2*texWidth, h1*texHeight); + glVertex3f( wv2, -wh1,0); // Top Right Of The Texture and Quad + + glTexCoord2f (v2*texWidth, h2*texHeight); + glVertex3f( wv2, -wh2,0); // Bot Right Of The Texture and Quad + + glTexCoord2f ( v1*texWidth, h2*texHeight); + glVertex3f( wv1,-wh2,0); + + glEnd(); + } + + glPopMatrix(); } + } + + + + if (!coloredSides) { + disableTexture (s, w->texture); } - } - if (!coloredSides) - moveScreenViewport (s, -screenX-1, 0, FALSE); + } } + } + + if (!coloredSides) + rubikMoveScreenViewport (s, -screenX); + } - glPopMatrix(); + glPopMatrix(); - /*glDisable (GL_LIGHT1); + /*glDisable (GL_LIGHT1); glDisable (GL_NORMALIZE); if (!s->lighting) glDisable (GL_LIGHTING);*/ - glDisable (GL_DEPTH_TEST); + glDisable (GL_DEPTH_TEST); - if (enabledCull) - glDisable (GL_CULL_FACE); + if (enabledCull) + glDisable (GL_CULL_FACE); + + glPopMatrix(); - glPopMatrix(); + + glColor3usv (defaultColor); + glDisable (GL_BLEND); + glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + screenTexEnvMode (s, GL_REPLACE); - glPopAttrib(); + + glPopAttrib(); - rs->damage = TRUE; + rs->damage = TRUE; - UNWRAP (rs, cs, paintInside); - (*cs->paintInside) (s, sAttrib, transform, output, size); - WRAP (rs, cs, paintInside, rubikPaintInside); + UNWRAP (rs, cs, paintInside); + (*cs->paintInside) (s, sAttrib, transform, output, size); + WRAP (rs, cs, paintInside, rubikPaintInside); } static void rubikPreparePaintScreen (CompScreen *s, int ms) { - RUBIK_SCREEN (s); - CUBE_SCREEN (s); + RUBIK_SCREEN (s); + CUBE_SCREEN (s); - //rotationAxis=2; //TESTING - //currentStripDirection=-1; //TESTING - - if (rs->hsize!=4) rs->initiated = FALSE; - - int i; - if (rs->initiated) { - if (rubikGetRotateAllAxes(s)) { - i= currentHStrip; - float increment = rs->speedFactor; - rs->psi[i] += currentStripDirection*increment; - currentStripCounter +=increment; - - if (currentStripCounter>90) { - rs->psi[i]=rs->oldPsi[i]+currentStripDirection*90; - currentStripCounter -=90; - - - int j,k; - if (rotationAxis==0) { - for (k=0; k<vStrips; k++) { - if (currentStripDirection==1) { - squareRec tempSquare = (rs->faces[4-1].square[i*hStrips+k]); - - for (j=4-1; j>0; j--) { - rs->faces[j].square[i*hStrips+k] = rs->faces[j-1].square[i*hStrips+k]; - } - - rs->faces[0].square[i*hStrips+k] = tempSquare; - - - if (i==0) { - - if (k==0) - rotateClockwise ((rs->faces[4].square)); - } - if (i==hStrips-1) { - if (k==0) - rotateAnticlockwise ((rs->faces[5].square)); - } - - } - else { - squareRec tempSquare = (rs->faces[0].square[i*hStrips+k]); - - for (j=0; j<4-1; j++) { - rs->faces[j].square[i*hStrips+k] = rs->faces[j+1].square[i*hStrips+k]; - } - - rs->faces[4-1].square[i*hStrips+k] = tempSquare; - - - if (i==0) { - if (k==0) - rotateAnticlockwise ((rs->faces[4].square)); - } - if (i==hStrips-1) { - if (k==0) - rotateClockwise ((rs->faces[5].square)); - } - - } - - - } + //rotationAxis=2; //TESTING + //currentStripDirection=-1; //TESTING - } - else if (rotationAxis==1) { - for (k=0; k<vStrips; k++) { - if (currentStripDirection==1) { - - squareRec tempSquare = (rs->faces[4].square[k*hStrips+i]); - - rs->faces[4].square[k*hStrips+i] = rs->faces[0].square[k*hStrips+i]; - rs->faces[0].square[k*hStrips+i] = rs->faces[5].square[k*hStrips+i]; - rs->faces[5].square[k*hStrips+i] = rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]; - rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)] = tempSquare; - - rs->faces[5].square[k*hStrips+i].psi = (rs->faces[5].square[k*hStrips+i].psi+2)%4; - rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi = (rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi+2)%4; - - - if (i==hStrips-1) { - - if (k==0) - rotateAnticlockwise ((rs->faces[1].square)); - } - if (i==0) { - if (k==0) - rotateClockwise ((rs->faces[3].square)); - } - } - else { - - squareRec tempSquare = (rs->faces[4].square[k*hStrips+i]); - - rs->faces[4].square[k*hStrips+i] = rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]; - rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)] = rs->faces[5].square[k*hStrips+i]; - rs->faces[5].square[k*hStrips+i] = rs->faces[0].square[k*hStrips+i]; - rs->faces[0].square[k*hStrips+i] = tempSquare; - - rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi = (rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi+2)%4; - rs->faces[4].square[k*hStrips+i].psi = (rs->faces[4].square[k*hStrips+i].psi+2)%4; - - - - if (i==0) { - if (k==0) - rotateAnticlockwise ((rs->faces[3].square)); - } - if (i==hStrips-1) { - if (k==0) - rotateClockwise ((rs->faces[1].square)); - } - } - - } + if (rs->hsize!=4) rs->initiated = FALSE; - } - else if (rotationAxis==2) { - for (k=0; k<vStrips; k++) { - if (currentStripDirection==1) { - squareRec tempSquare = (rs->faces[4].square[(vStrips-1-i)*hStrips+k]); - - rs->faces[4].square[(vStrips-1-i)*hStrips+k] = rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]; - rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]=rs->faces[5].square[i*hStrips+(vStrips-1-k)]; - rs->faces[5].square[i*hStrips+(vStrips-1-k)]=rs->faces[1].square[k*hStrips+i]; - rs->faces[1].square[k*hStrips+i]=tempSquare; - - - rs->faces[4].square[(vStrips-1-i)*hStrips+k].psi = (rs->faces[4].square[(vStrips-1-i)*hStrips+k].psi+3)%4; - rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi = (rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi+3)%4; - rs->faces[5].square[i*hStrips+(vStrips-1-k)].psi = (rs->faces[5].square[i*hStrips+(vStrips-1-k)].psi+3)%4; - rs->faces[1].square[k*hStrips+i].psi = (rs->faces[1].square[k*hStrips+i].psi+3)%4; - - if (i==0) { - if (k==0) - rotateAnticlockwise ((rs->faces[0].square)); - } - if (i==hStrips-1) { - if (k==0) - rotateClockwise ((rs->faces[2].square)); - } - } - else { - squareRec tempSquare = (rs->faces[4].square[(vStrips-1-i)*hStrips+k]); - - rs->faces[4].square[(vStrips-1-i)*hStrips+k] = rs->faces[1].square[k*hStrips+i]; - rs->faces[1].square[k*hStrips+i] = rs->faces[5].square[i*hStrips+(vStrips-1-k)]; - rs->faces[5].square[i*hStrips+(vStrips-1-k)] = rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]; - rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]= tempSquare; - - - rs->faces[4].square[(vStrips-1-i)*hStrips+k].psi = (rs->faces[4].square[(vStrips-1-i)*hStrips+k].psi+1)%4; - rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi = (rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi+1)%4; - rs->faces[5].square[i*hStrips+(vStrips-1-k)].psi = (rs->faces[5].square[i*hStrips+(vStrips-1-k)].psi+1)%4; - rs->faces[1].square[k*hStrips+i].psi = (rs->faces[1].square[k*hStrips+i].psi+1)%4; - - - if (i==0) { - if (k==0) - rotateClockwise ((rs->faces[0].square)); - } - if (i==hStrips-1) { - if (k==0) - rotateAnticlockwise ((rs->faces[2].square)); - } - } - } - } - - currentHStrip = NRAND(hStrips); - currentStripDirection = NRAND(2)*2-1; - rotationAxis = NRAND(3); - rs->oldPsi[i]= rs->psi[i]; + int i; + if (rs->initiated) { + i= currentHStrip; + float increment = rs->speedFactor; + rs->psi[i] += currentStripDirection*increment; + currentStripCounter +=increment; + + if (currentStripCounter>90) { + rs->psi[i]=rs->oldPsi[i]+currentStripDirection*90; + currentStripCounter -=90; + + + int j,k; + if (rotationAxis==0) { + for (k=0; k<vStrips; k++) { + if (currentStripDirection==1) { + squareRec tempSquare = (rs->faces[4-1].square[i*hStrips+k]); + + for (j=4-1; j>0; j--) { + rs->faces[j].square[i*hStrips+k] = rs->faces[j-1].square[i*hStrips+k]; + } + + rs->faces[0].square[i*hStrips+k] = tempSquare; + + + if (i==0) { + + if (k==0) + rotateClockwise ((rs->faces[4].square)); + } + if (i==hStrips-1) { + if (k==0) + rotateAnticlockwise ((rs->faces[5].square)); + } + + } + else { + squareRec tempSquare = (rs->faces[0].square[i*hStrips+k]); + + for (j=0; j<4-1; j++) { + rs->faces[j].square[i*hStrips+k] = rs->faces[j+1].square[i*hStrips+k]; } - rs->psi[i] = fmodf(rs->psi[i], 360); + + rs->faces[4-1].square[i*hStrips+k] = tempSquare; + + + if (i==0) { + if (k==0) + rotateAnticlockwise ((rs->faces[4].square)); + } + if (i==hStrips-1) { + if (k==0) + rotateClockwise ((rs->faces[5].square)); + } + + } + + } - else { - i= currentVStrip; - float increment = 2*rs->speedFactor; - rs->th[i] += currentStripDirection*increment; - currentStripCounter +=increment; - - if (currentStripCounter>90) { - rs->th[i]=rs->oldTh[i]+currentStripDirection*90; - currentStripCounter -=90; - currentVStrip = NRAND(vStrips); - currentStripDirection = NRAND(2)*2-1; - rs->oldTh[i]= rs->th[i]; + } + else if (rotationAxis==1) { + for (k=0; k<vStrips; k++) { + if (currentStripDirection==1) { + + squareRec tempSquare = (rs->faces[4].square[k*hStrips+i]); + + rs->faces[4].square[k*hStrips+i] = rs->faces[0].square[k*hStrips+i]; + rs->faces[0].square[k*hStrips+i] = rs->faces[5].square[k*hStrips+i]; + rs->faces[5].square[k*hStrips+i] = rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]; + rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)] = tempSquare; + + rs->faces[5].square[k*hStrips+i].psi = (rs->faces[5].square[k*hStrips+i].psi+2)%4; + rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi = (rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi+2)%4; + + + if (i==hStrips-1) { + + if (k==0) + rotateAnticlockwise ((rs->faces[1].square)); + } + if (i==0) { + if (k==0) + rotateClockwise ((rs->faces[3].square)); + } + } + else { + + squareRec tempSquare = (rs->faces[4].square[k*hStrips+i]); + + rs->faces[4].square[k*hStrips+i] = rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]; + rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)] = rs->faces[5].square[k*hStrips+i]; + rs->faces[5].square[k*hStrips+i] = rs->faces[0].square[k*hStrips+i]; + rs->faces[0].square[k*hStrips+i] = tempSquare; + + rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi = (rs->faces[2].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi+2)%4; + rs->faces[4].square[k*hStrips+i].psi = (rs->faces[4].square[k*hStrips+i].psi+2)%4; + + + + if (i==0) { + if (k==0) + rotateAnticlockwise ((rs->faces[3].square)); } - rs->th[i] = fmodf(rs->th[i], 360); + if (i==hStrips-1) { + if (k==0) + rotateClockwise ((rs->faces[1].square)); + } + } + } - } - UNWRAP (rs, s, preparePaintScreen); - (*s->preparePaintScreen) (s, ms); - WRAP (rs, s, preparePaintScreen, rubikPreparePaintScreen); - - if (rs->initiated && cs->rotationState!=RotationNone && rubikGetRotateDesktop(s)) { - cs->toOpacity = 0; - cs->desktopOpacity = 0; + } + else if (rotationAxis==2) { + for (k=0; k<vStrips; k++) { + if (currentStripDirection==1) { + squareRec tempSquare = (rs->faces[4].square[(vStrips-1-i)*hStrips+k]); + + rs->faces[4].square[(vStrips-1-i)*hStrips+k] = rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]; + rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]=rs->faces[5].square[i*hStrips+(vStrips-1-k)]; + rs->faces[5].square[i*hStrips+(vStrips-1-k)]=rs->faces[1].square[k*hStrips+i]; + rs->faces[1].square[k*hStrips+i]=tempSquare; + + + rs->faces[4].square[(vStrips-1-i)*hStrips+k].psi = (rs->faces[4].square[(vStrips-1-i)*hStrips+k].psi+3)%4; + rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi = (rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi+3)%4; + rs->faces[5].square[i*hStrips+(vStrips-1-k)].psi = (rs->faces[5].square[i*hStrips+(vStrips-1-k)].psi+3)%4; + rs->faces[1].square[k*hStrips+i].psi = (rs->faces[1].square[k*hStrips+i].psi+3)%4; + + if (i==0) { + if (k==0) + rotateAnticlockwise ((rs->faces[0].square)); + } + if (i==hStrips-1) { + if (k==0) + rotateClockwise ((rs->faces[2].square)); + } + } + else { + squareRec tempSquare = (rs->faces[4].square[(vStrips-1-i)*hStrips+k]); + + rs->faces[4].square[(vStrips-1-i)*hStrips+k] = rs->faces[1].square[k*hStrips+i]; + rs->faces[1].square[k*hStrips+i] = rs->faces[5].square[i*hStrips+(vStrips-1-k)]; + rs->faces[5].square[i*hStrips+(vStrips-1-k)] = rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]; + rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)]= tempSquare; + + + rs->faces[4].square[(vStrips-1-i)*hStrips+k].psi = (rs->faces[4].square[(vStrips-1-i)*hStrips+k].psi+1)%4; + rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi = (rs->faces[3].square[(vStrips-1-k)*hStrips+(vStrips-1-i)].psi+1)%4; + rs->faces[5].square[i*hStrips+(vStrips-1-k)].psi = (rs->faces[5].square[i*hStrips+(vStrips-1-k)].psi+1)%4; + rs->faces[1].square[k*hStrips+i].psi = (rs->faces[1].square[k*hStrips+i].psi+1)%4; + + + if (i==0) { + if (k==0) + rotateClockwise ((rs->faces[0].square)); + } + if (i==hStrips-1) { + if (k==0) + rotateAnticlockwise ((rs->faces[2].square)); + } + } + } + } + + currentHStrip = NRAND(hStrips); + currentStripDirection = NRAND(2)*2-1; + rotationAxis = NRAND(3); + rs->oldPsi[i]= rs->psi[i]; } + rs->psi[i] = fmodf(rs->psi[i], 360); + } + + UNWRAP (rs, s, preparePaintScreen); + (*s->preparePaintScreen) (s, ms); + WRAP (rs, s, preparePaintScreen, rubikPreparePaintScreen); + + if (rs->initiated && cs->rotationState!=RotationNone) { + cs->toOpacity = 0; + cs->desktopOpacity = 0; + } } static Bool RubikDamageWindowRect(CompWindow *w, Bool initial, BoxPtr rect){ @@ -936,7 +1053,7 @@ static Bool RubikDamageWindowRect(CompWindow *w, Bool initial, BoxPtr rect){ CUBE_SCREEN (w->screen); //RUBIK_WINDOW(w); - if (w->damaged || (rs->initiated && (cs->rotationState!=RotationNone || !rubikGetEnableOnManualRotate(w->screen)))) + if (w->damaged || (rs->initiated && cs->rotationState!=RotationNone)) damageScreen(w->screen); UNWRAP(rs, w->screen, damageWindowRect); @@ -970,7 +1087,7 @@ toggleRubikEffect (CompScreen *s) { RUBIK_SCREEN(s); - //CUBE_SCREEN (s); + CUBE_SCREEN (s); rs->initiated = !(rs->initiated); @@ -980,12 +1097,16 @@ toggleRubikEffect (CompScreen *s) currentStripDirection = NRAND(2)*2-1; rotationAxis = NRAND(3); - + rs->desktopOpacity = cs->toOpacity; + cs->toOpacity = 0; + cs->desktopOpacity = 0; + //cs->rotationState = RotationManual; //WRAP( rs, cs, getRotation, rubikGetRotation ); } else { initFaces (s); + cs->desktopOpacity = rs->desktopOpacity; //cs->rotationState = RotationNone; @@ -1038,10 +1159,10 @@ static Bool RubikPaintOutput(CompScreen *s, const ScreenPaintAttrib *sAttrib, RUBIK_SCREEN(s); - //if(rs->initiated) { + if(rs->initiated) { mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK; //mask |= PAINT_SCREEN_REGION_MASK; - //} + } UNWRAP(rs, s, paintOutput); status = (*s->paintOutput)(s, sAttrib, transform, region, output, mask); @@ -1066,12 +1187,8 @@ RubikDrawWindow (CompWindow *w, CUBE_SCREEN (s); if (rs->initiated) { - if (w->desktop && cs->rotationState!=RotationNone && rubikGetRotateDesktop(s)) - fA.opacity = 0; - - if (!w->desktop && rubikGetRotateAllAxes(s) && cs->rotationState!=RotationNone) - fA.opacity = 0; - + if (cs->rotationState!=RotationNone) + fA.opacity = 0; } if (rs->initiated) { @@ -1121,7 +1238,7 @@ RubikAddWindowGeometry(CompWindow * w, clip->rects[i].x1 = 1280*((int) (winX/screenW)-w->screen->x); clip->rects[i].x2 = 1280*((int) (winX/screenW)+1-w->screen->x); } - if (rubikGetRotateAllAxes(w->screen) && cs->rotationState!=RotationNone) { + if (cs->rotationState!=RotationNone) { for (i=0; i<clip->numRects; i++) { clip->rects[i].x1 = 0; clip->rects[i].x2 = 0; @@ -1129,7 +1246,7 @@ RubikAddWindowGeometry(CompWindow * w, } } - else if (w->desktop && cs->rotationState!=RotationNone && rubikGetRotateDesktop(w->screen)) { + else if (w->desktop && cs->rotationState!=RotationNone) { for (i=0; i<clip->numRects; i++) { clip->rects[i].x1 = 0; clip->rects[i].x2 = 0; @@ -1171,197 +1288,13 @@ RubikPaintTransformedOutput (CompScreen *s, static Bool RubikPaintWindow(CompWindow *w, const WindowPaintAttrib *attrib, const CompTransform *transform, Region region, unsigned int mask) { + RUBIK_SCREEN(w->screen); - CompTransform wTransform = *transform; - - Bool wasCulled = glIsEnabled(GL_CULL_FACE); - Bool status; - - RUBIK_SCREEN(w->screen); - CUBE_SCREEN (w->screen); - //RUBIK_WINDOW(w); - - - int i; - - UNWRAP(rs, w->screen, paintWindow); - - if (rs->initiated && !(rubikGetEnableOnManualRotate(w->screen) && cs->rotationState==RotationNone)) { - - mask |= PAINT_WINDOW_TRANSFORMED_MASK; - //mask |= PAINT_SCREEN_REGION_MASK; - - if(wasCulled) - glDisable(GL_CULL_FACE); - - float winX = WIN_REAL_X(w) + WIN_REAL_W(w)/2.0+w->screen->x*w->screen->width; - float screenW = w->screen->width; - - //printf ("\nwin: %f\n",winX); - //printf ("screen: %f\n",screenW); - - if (!w->desktop && !w->hidden) { - - GLboolean oldDepthTestStatus = glIsEnabled(GL_DEPTH_TEST); - if (rubikGetEnableDepthTest(w->screen) && cs->rotationState!=RotationNone) - glEnable (GL_DEPTH_TEST); - - GLdouble oldClipPlane4[4]; - GLdouble oldClipPlane5[4]; - glGetClipPlane(GL_CLIP_PLANE4, oldClipPlane4); - glGetClipPlane(GL_CLIP_PLANE5, oldClipPlane5); - - GLboolean oldClipPlane0status = glIsEnabled(GL_CLIP_PLANE0); - GLboolean oldClipPlane1status = glIsEnabled(GL_CLIP_PLANE1); - GLboolean oldClipPlane2status = glIsEnabled(GL_CLIP_PLANE2); - GLboolean oldClipPlane3status = glIsEnabled(GL_CLIP_PLANE3); - - GLboolean oldClipPlane4status = glIsEnabled(GL_CLIP_PLANE4); - GLboolean oldClipPlane5status = glIsEnabled(GL_CLIP_PLANE5); - - - GLdouble clipPlane4[] = { 1.0, 0, 0, 0 }; - GLdouble clipPlane5[] = { -1, 0.0, 0, w->screen->width }; - - glClipPlane (GL_CLIP_PLANE4, clipPlane4); - glClipPlane (GL_CLIP_PLANE5, clipPlane5); - - glDisable (GL_CLIP_PLANE0); - glDisable (GL_CLIP_PLANE1); - glDisable (GL_CLIP_PLANE2); - glDisable (GL_CLIP_PLANE3); - - glEnable (GL_CLIP_PLANE4); - glEnable (GL_CLIP_PLANE5); - - - if (((int) (winX/screenW))%2==0) { - - memcpy (rs->tempTransform, &wTransform, sizeof (CompTransform)); - - for (i=0; i<vStrips; i++) { - - if (i!=0) memcpy (&wTransform, rs->tempTransform, sizeof (CompTransform)); - - clipPlane4[3] = -i*w->screen->width/vStrips; - clipPlane5[3] = (i+1)*w->screen->width/vStrips; - glClipPlane (GL_CLIP_PLANE4, clipPlane4); - glClipPlane (GL_CLIP_PLANE5, clipPlane5); - - matrixScale (&wTransform, 1.0f, 1.0f, 1.0f/ w->screen->width); - - matrixTranslate(&wTransform, - (WIN_REAL_X(w) + WIN_REAL_W(w)/2.0), - (WIN_REAL_Y(w) + WIN_REAL_H(w)/2.0), - -rs->distance*w->screen->width); - - - //matrixRotate(&wTransform, rs->psi, 0.0, 0.0, 1.0); - if ((int) (winX/screenW)==0) - matrixRotate(&wTransform, -rs->th[i], 1.0, 0.0, 0.0); - else - matrixRotate(&wTransform, rs->th[i], 1.0, 0.0, 0.0); - - matrixTranslate(&wTransform, - -(WIN_REAL_X(w) + WIN_REAL_W(w)/2.0), - -(WIN_REAL_Y(w) + WIN_REAL_H(w)/2.0), - rs->distance*w->screen->width); - - matrixTranslate(&wTransform, 0, 0, 0.005*w->activeNum); - - - status = (*w->screen->paintWindow)(w, attrib, &wTransform, region, mask); - } - - } - else { - matrixScale (&wTransform, 1.0f, 1.0f, 1.0f/ w->screen->width); - - matrixTranslate(&wTransform, - (WIN_REAL_X(w) + WIN_REAL_W(w)/2.0), - (WIN_REAL_Y(w) + WIN_REAL_H(w)/2.0), - 0); - - if ((int) (winX/screenW)==1) - matrixRotate(&wTransform, -rs->th[vStrips-1], 0.0, 0.0, 1); - else - matrixRotate(&wTransform, rs->th[0], 0.0, 0.0, 1); - - matrixTranslate(&wTransform, - -(WIN_REAL_X(w) + WIN_REAL_W(w)/2.0), - -(WIN_REAL_Y(w) + WIN_REAL_H(w)/2.0), - 0); - - matrixTranslate(&wTransform, 0, 0, 0.005*w->activeNum); - - status = (*w->screen->paintWindow)(w, attrib, &wTransform, region, mask); - - } - - if (oldClipPlane0status) - glEnable (GL_CLIP_PLANE0); - - if (oldClipPlane1status) - glEnable (GL_CLIP_PLANE1); - - if (oldClipPlane2status) - glEnable (GL_CLIP_PLANE2); - - if (oldClipPlane3status) - glEnable (GL_CLIP_PLANE3); - - - glDisable (GL_CLIP_PLANE4); - glDisable (GL_CLIP_PLANE5); - - glClipPlane(GL_CLIP_PLANE4, oldClipPlane4); - glClipPlane(GL_CLIP_PLANE5, oldClipPlane5); - - if (oldClipPlane4status) - glEnable(GL_CLIP_PLANE4); - - if (oldClipPlane5status) - glEnable(GL_CLIP_PLANE5); - - if (!oldDepthTestStatus) - glDisable(GL_DEPTH_TEST); - - } - else { - status = (*w->screen->paintWindow)(w, attrib, &wTransform, region, mask); - } - } - else { - if (!rs->initiated) { - int i; - for (i=0; i<vStrips; i++) { - rs->th[i] = 0; - rs->oldTh[i] = rs->th[i]; - } - for (i=0; i<hStrips; i++) { - rs->psi[i] = 0; - rs->oldPsi[i] = rs->psi[i]; - } - - } - - - - - if(wasCulled) - glDisable(GL_CULL_FACE); - - status = (*w->screen->paintWindow)(w, attrib, &wTransform, region, mask); - } - - WRAP(rs, w->screen, paintWindow, RubikPaintWindow); - - - if(wasCulled) - glEnable(GL_CULL_FACE); - + UNWRAP(rs, w->screen, paintWindow); + Bool status = (*w->screen->paintWindow)(w, attrib, transform, region, mask); + WRAP(rs, w->screen, paintWindow, RubikPaintWindow); - return status; + return status; } @@ -1433,30 +1366,29 @@ rubikInitScreen (CompPlugin *p, return FALSE; } - s->base.privates[rd->screenPrivateIndex].ptr = rs; + s->base.privates[rd->screenPrivateIndex].ptr = rs; - rs->damage = FALSE; + rs->damage = FALSE; - glLightfv (GL_LIGHT1, GL_AMBIENT, ambient); - glLightfv (GL_LIGHT1, GL_DIFFUSE, diffuse); - glLightfv (GL_LIGHT1, GL_POSITION, position); + glLightfv (GL_LIGHT1, GL_AMBIENT, ambient); + glLightfv (GL_LIGHT1, GL_DIFFUSE, diffuse); + glLightfv (GL_LIGHT1, GL_POSITION, position); - initRubik (s); + initRubik (s); - rubikSetSpeedFactorNotify (s, rubikSpeedFactorOptionChange); - rubikSetNumberStripsNotify (s, rubikScreenOptionChange); - rubikSetRotateAllAxesNotify (s, rubikScreenOptionChange); + rubikSetSpeedFactorNotify (s, rubikSpeedFactorOptionChange); + rubikSetNumberStripsNotify (s, rubikScreenOptionChange); rs->initiated = FALSE; - - - WRAP (rs, s, donePaintScreen, rubikDonePaintScreen); - WRAP (rs, s, preparePaintScreen, rubikPreparePaintScreen); - WRAP (rs, cs, clearTargetOutput, rubikClearTargetOutput); - WRAP (rs, cs, paintInside, rubikPaintInside); - - WRAP (rs, s, paintWindow, RubikPaintWindow); + + + WRAP (rs, s, donePaintScreen, rubikDonePaintScreen); + WRAP (rs, s, preparePaintScreen, rubikPreparePaintScreen); + WRAP (rs, cs, clearTargetOutput, rubikClearTargetOutput); + WRAP (rs, cs, paintInside, rubikPaintInside); + + //WRAP (rs, s, paintWindow, RubikPaintWindow); WRAP (rs, s, paintOutput, RubikPaintOutput); WRAP (rs, s, drawWindow, RubikDrawWindow); WRAP (rs, s, paintTransformedOutput, RubikPaintTransformedOutput); @@ -1484,7 +1416,7 @@ rubikFiniScreen (CompPlugin *p, UNWRAP (rs, cs, clearTargetOutput); UNWRAP (rs, cs, paintInside); - UNWRAP (rs, s, paintWindow); + //UNWRAP (rs, s, paintWindow); UNWRAP (rs, s, paintOutput); UNWRAP (rs, s, drawWindow); UNWRAP (rs, s, paintTransformedOutput); diff --git a/rubik.xml.in b/rubik.xml.in index 6bf7c07..281f296 100644 --- a/rubik.xml.in +++ b/rubik.xml.in @@ -39,21 +39,6 @@ <min>1</min> <max>10</max> </option> - <option name="rotate_all_axes" type="bool"> - <short>Rotate around all axes</short> - <long>Rotate Rubik's cube around all axes (convert windows to pixmaps also).</long> - <default>true</default> - </option> - <option name="enable_on_manual_rotate" type="bool"> - <short>On manual rotate</short> - <long>Enable effect only on cube rotate.</long> - <default>true</default> - </option> - <option name="rotate_desktop" type="bool"> - <short>Rotate desktop</short> - <long>Rotate desktop as well as windows.</long> - <default>true</default> - </option> <option name="colored_sides" type="bool"> <short>Colored Sides</short> <long>Replace wallpaper with colored sides.</long> |