static Bool draw_main(ModeInfo *mi, cube21_conf *cp) 
{
  GLfloat theta = cp->ramount<0?cp->t:-cp->t;
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();
  if(wander)
    glTranslatef(3.0*cp->ratio*sin(13.0*cp->posarg), 3.0*sin(17.0*cp->posarg), zpos);
  else
    glTranslatef(0, 0, zpos);
  glScalef(size, size, size);
  glRotatef(cp->xrot, 1.0, 0.0, 0.0);
  glRotatef(cp->yrot, 0.0, 1.0, 0.0);
  if(cp->wire) glColor3f(0.7, 0.7, 0.7);
  switch(cp->state) {
    case CUBE21_PAUSE1:
    case CUBE21_PAUSE2:
      draw_top_face(mi, cp);
      draw_bottom_face(mi, cp);
      draw_middle(cp);
      break;
    case CUBE21_ROT_TOP:
      glRotatef(theta, 0.0, 0.0, 1.0);
      draw_top_face(mi, cp);
      glRotatef(-theta, 0.0, 0.0, 1.0);
      draw_bottom_face(mi, cp);
      draw_middle(cp);
      break;
    case CUBE21_ROT_BOTTOM:
      draw_top_face(mi, cp);
      glRotatef(theta, 0.0, 0.0, 1.0);
      draw_bottom_face(mi, cp);
      glRotatef(-theta, 0.0, 0.0, 1.0);
      draw_middle(cp);
      break;
    case CUBE21_HALF1:
      glRotatef(theta, 0.0, 1.0, 0.0);
    case CUBE21_HALF2:
      draw_half_face(mi, cp, 0, 0);
      glRotatef(-180.0, 0.0, 0.0, 1.0);
      draw_half_face(mi, cp, 1, 0);
      glRotatef(-180.0, 0.0, 0.0, 1.0);
      if(cp->hf[0]) glRotatef(180.0, 0.0, 1.0, 0.0);
      draw_middle_piece(cp, 0, cp->cind, cp->colors);
      if(cp->hf[0]) glRotatef(180.0, 0.0, 1.0, 0.0);
      if(cp->state==CUBE21_HALF1)
        glRotatef(-theta, 0.0, 1.0, 0.0);
      else
        glRotatef(theta, 0.0, 1.0, 0.0);
      glRotatef(180.0, 0.0, 0.0, 1.0);
      draw_half_face(mi, cp, 0, 6);
      glRotatef(-180.0, 0.0, 0.0, 1.0);
      draw_half_face(mi, cp, 1, 6);
      glRotatef(-180.0, 0.0, 0.0, 1.0);
      if(cp->hf[1]) glRotatef(180.0, 0.0, 1.0, 0.0);
      draw_middle_piece(cp, 1, cp->cind, cp->colors);
      break;
  }
  if(spin) {
    if((cp->xrot += spinspeed)>360.0) cp->xrot -= 360.0;
    if((cp->yrot += spinspeed)>360.0) cp->yrot -= 360.0;
  }
  if(wander)
    if((cp->posarg += wspeed/1000.0)>360.0) cp->posarg -= 360.0;
  if((cp->t += tspeed)>cp->tmax) finish(cp);
  return True;
}
Exemple #2
0
static Bool draw_main(ModeInfo *mi, cube21_conf *cp) 
{
  GLfloat theta = cp->ramount<0?cp->t:-cp->t;
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();
  if(wander)
    glTranslatef(3.0*cp->ratio*sin(13.0*cp->posarg), 3.0*sin(17.0*cp->posarg), zpos);
  else
    glTranslatef(0, 0, zpos);
  glScalef(size, size, size);

# ifdef HAVE_MOBILE	/* Keep it the same relative size when rotated. */
  {
    GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
    int o = (int) current_device_rotation();
    if (o != 0 && o != 180 && o != -180)
      glScalef (1/h, 1/h, 1/h);
  }
# endif

  glRotatef(cp->xrot, 1.0, 0.0, 0.0);
  glRotatef(cp->yrot, 0.0, 1.0, 0.0);

  gltrackball_rotate (cp->trackball);

  if(cp->wire) glColor3f(0.7, 0.7, 0.7);
  switch(cp->state) {
    case CUBE21_PAUSE1:
    case CUBE21_PAUSE2:
      draw_top_face(mi, cp);
      draw_bottom_face(mi, cp);
      draw_middle(cp);
      break;
    case CUBE21_ROT_TOP:
      glRotatef(theta, 0.0, 0.0, 1.0);
      draw_top_face(mi, cp);
      glRotatef(-theta, 0.0, 0.0, 1.0);
      draw_bottom_face(mi, cp);
      draw_middle(cp);
      break;
    case CUBE21_ROT_BOTTOM:
      draw_top_face(mi, cp);
      glRotatef(theta, 0.0, 0.0, 1.0);
      draw_bottom_face(mi, cp);
      glRotatef(-theta, 0.0, 0.0, 1.0);
      draw_middle(cp);
      break;
    case CUBE21_HALF1:
      glRotatef(theta, 0.0, 1.0, 0.0);
    case CUBE21_HALF2:
      draw_half_face(mi, cp, 0, 0);
      glRotatef(-180.0, 0.0, 0.0, 1.0);
      draw_half_face(mi, cp, 1, 0);
      glRotatef(-180.0, 0.0, 0.0, 1.0);
      if(cp->hf[0]) glRotatef(180.0, 0.0, 1.0, 0.0);
      draw_middle_piece(cp, 0, cp->cind, cp->colors);
      if(cp->hf[0]) glRotatef(180.0, 0.0, 1.0, 0.0);
      if(cp->state==CUBE21_HALF1)
        glRotatef(-theta, 0.0, 1.0, 0.0);
      else
        glRotatef(theta, 0.0, 1.0, 0.0);
      glRotatef(180.0, 0.0, 0.0, 1.0);
      draw_half_face(mi, cp, 0, 6);
      glRotatef(-180.0, 0.0, 0.0, 1.0);
      draw_half_face(mi, cp, 1, 6);
      glRotatef(-180.0, 0.0, 0.0, 1.0);
      if(cp->hf[1]) glRotatef(180.0, 0.0, 1.0, 0.0);
      draw_middle_piece(cp, 1, cp->cind, cp->colors);
      break;
  }
  if(spin) {
    if((cp->xrot += spinspeed)>360.0) cp->xrot -= 360.0;
    if((cp->yrot += spinspeed)>360.0) cp->yrot -= 360.0;
  }
  if(wander)
    if((cp->posarg += wspeed/1000.0)>360.0) cp->posarg -= 360.0;
  if((cp->t += tspeed)>cp->tmax) finish(cp);
  return True;
}