Exemple #1
0
ENTRYPOINT void
draw_moebius (ModeInfo * mi)
{
	moebiusstruct *mp;

	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);

        if (moebius == NULL)
	    return;
	mp = &moebius[MI_SCREEN(mi)];

	MI_IS_DRAWN(mi) = True;

	if (!mp->glx_context)
		return;

	glXMakeCurrent(display, window, *(mp->glx_context));

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glPushMatrix();

	glTranslatef(0.0, 0.0, -10.0);

    /* Do it twice because we don't track the device's orientation. */
    glRotatef( current_device_rotation(), 0, 0, 1);
    gltrackball_rotate (mp->trackball);
    glRotatef(-current_device_rotation(), 0, 0, 1);

	if (!MI_IS_ICONIC(mi)) {
		glScalef(Scale4Window * mp->WindH / mp->WindW, Scale4Window, Scale4Window);
	} else {
		glScalef(Scale4Iconic * mp->WindH / mp->WindW, Scale4Iconic, Scale4Iconic);
	}

    {
      double x, y, z;
      get_rotation (mp->rot, &x, &y, &z, !mp->button_down_p);
      glRotatef (x * 360, 1.0, 0.0, 0.0);
      glRotatef (y * 360, 0.0, 1.0, 0.0);
      glRotatef (z * 360, 0.0, 0.0, 1.0);
    }

	/* moebius */
	if (!draw_moebius_strip(mi)) {
		release_moebius(mi);
		return;
	}

	glPopMatrix();

    if (MI_IS_FPS(mi)) do_fps (mi);
	glFlush();

	glXSwapBuffers(display, window);

	mp->step += 0.025;
}
Exemple #2
0
static void
userRot(gfluxstruct *gp)
{
  /* Do it twice because we don't track the device's orientation. */
  glRotatef( current_device_rotation(), 0, 0, 1);
  gltrackball_rotate (gp->trackball);
  glRotatef(-current_device_rotation(), 0, 0, 1);
}
Exemple #3
0
ENTRYPOINT void draw_jigglypuff(ModeInfo *mi)
{
    jigglystruct *js = &jss[MI_SCREEN(mi)];

    glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(js->glx_context));

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0,0,-10);

    glRotatef(js->angle, sin(js->axis), cos(js->axis), -sin(js->axis));
    glTranslatef(0, 0, 5);
    if(!(js->button_down)) {
        if((js->angle += js->speed) >= 360.0f ) {
            js->angle -= 360.0f;
        }
        if((js->axis+=0.01f) >= 2*M_PI ) {
            js->axis -= 2*M_PI;
        }
    }

    /* Do it twice because we don't track the device's orientation. */
    glRotatef( current_device_rotation(), 0, 0, 1);
    gltrackball_rotate(js->trackball);
    glRotatef(-current_device_rotation(), 0, 0, 1);

    if(js->color_style == COLOR_STYLE_CYCLE) {
        int i;
        vector_add(js->jiggly_color, js->color_dir, js->jiggly_color);

        for(i=0; i<3; i++) {
            if(js->jiggly_color[i] > 1.0 || js->jiggly_color[i] < 0.3) {
                js->color_dir[i] = (-js->color_dir[i]);
                js->jiggly_color[i] += js->color_dir[i];
            }
        }
        glColor4fv(js->jiggly_color);
    }

    mi->polygon_count = jigglypuff_render(js);
    if(MI_IS_FPS(mi))
        do_fps(mi);
    glFinish();
    update_shape(js);
    glXSwapBuffers(MI_DISPLAY(mi), MI_WINDOW(mi));
}
Exemple #4
0
/* Window management, etc
 */
ENTRYPOINT void
reshape_spheremonics (ModeInfo *mi, int width, int height)
{
    GLfloat h = (GLfloat) height / (GLfloat) width;

    glViewport (0, 0, (GLint) width, (GLint) height);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective (30.0, 1/h, 1.0, 100.0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt( 0.0, 0.0, 30.0,
               0.0, 0.0, 0.0,
               0.0, 1.0, 0.0);

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

# endif
    glClear(GL_COLOR_BUFFER_BIT);
}
ENTRYPOINT void
draw_bubble3d(ModeInfo * mi)
{
	struct context *c = &contexts[MI_SCREEN(mi)];
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);

	MI_IS_DRAWN(mi) = True;

	if (!c->glx_context)
		return;

	glXMakeCurrent(display, window, *(c->glx_context));

        glb_config.polygon_count = 0;
        glPushMatrix();
        glRotatef(current_device_rotation(), 0, 0, 1);
	do_display(c);
        glPopMatrix();
        mi->polygon_count = glb_config.polygon_count;

        if (mi->fps_p) do_fps (mi);
	glFinish();
	glXSwapBuffers(display, window);
}
Exemple #6
0
/* Device rotation interacts very strangely with mouse positions.
   I'm not entirely sure this is the right fix.
 */
static void
adjust_for_device_rotation (trackball_state *ts,
                            double *x, double *y, double *w, double *h)
{
  int rot = (int) current_device_rotation();
  int swap;

  if (ts->ignore_device_rotation_p) return;

  while (rot <= -180) rot += 360;
  while (rot >   180) rot -= 360;

  if (rot > 135 || rot < -135)		/* 180 */
    {
      *x = *w - *x;
      *y = *h - *y;
    }
  else if (rot > 45)			/* 90 */
    {
      swap = *x; *x = *y; *y = swap;
      swap = *w; *w = *h; *h = swap;
      *x = *w - *x;
    }
  else if (rot < -45)			/* 270 */
    {
      swap = *x; *x = *y; *y = swap;
      swap = *w; *w = *h; *h = swap;
      *y = *h - *y;
    }
}
ENTRYPOINT void
reshape_slideshow (ModeInfo *mi, int width, int height)
{
  slideshow_state *ss = &sss[MI_SCREEN(mi)];
  GLfloat s;
  glViewport (0, 0, width, height);
  glMatrixMode (GL_PROJECTION);
  glLoadIdentity();
  glRotatef (current_device_rotation(), 0, 0, 1);
  glMatrixMode (GL_MODELVIEW);
  glLoadIdentity();

  s = 2;

  if (debug_p)
    {
      s *= (zoom / 100.0) * 0.75;
      if (s < 0.1) s = 0.1;
    }

  glScalef (s, s, s);
  glTranslatef (-0.5, -0.5, 0);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  ss->redisplay_needed_p = True;
}
static void
draw_stars (ModeInfo *mi)
{
  sws_configuration *sc = &scs[MI_SCREEN(mi)];

  glMatrixMode (GL_PROJECTION);
  glPushMatrix ();
  {
    glLoadIdentity ();

    glMatrixMode (GL_MODELVIEW);
    glPushMatrix ();
    {
      glLoadIdentity ();
      glOrtho (-0.5 * MI_WIDTH(mi),  0.5 * MI_WIDTH(mi),
               -0.5 * MI_HEIGHT(mi), 0.5 * MI_HEIGHT(mi),
               -100.0, 100.0);
      glRotatef (sc->star_theta, 0.0, 0.0, 1.0);
      if (textures_p) glDisable (GL_TEXTURE_2D);

      /* Keep the stars pointing in the same direction after rotation */
      glRotatef(current_device_rotation(), 0, 0, 1);

      glCallList (sc->star_list);
      if (textures_p) glEnable (GL_TEXTURE_2D);
    }
    glPopMatrix ();
  }
  glMatrixMode (GL_PROJECTION);
  glPopMatrix ();
}
Exemple #9
0
/* Window management, etc
 */
ENTRYPOINT void
reshape_ball (ModeInfo *mi, int width, int height)
{
  GLfloat h = (GLfloat) height / (GLfloat) width;
  int y = 0;

  if (width > height * 5) {   /* tiny window: show middle */
    height = width * 9/16;
    y = -height/2;
    h = height / (GLfloat) width;
  }

  glViewport (0, y, (GLint) width, (GLint) height);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective (30.0, 1/h, 1.0, 100.0);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt( 0.0, 0.0, 30.0,
             0.0, 0.0, 0.0,
             0.0, 1.0, 0.0);

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

  glClear(GL_COLOR_BUFFER_BIT);
}
Exemple #10
0
/*
 *-----------------------------------------------------------------------------
 *    Called by the mainline code periodically to update the display.
 *-----------------------------------------------------------------------------
 */
ENTRYPOINT void
draw_atlantis(ModeInfo * mi)
{
	atlantisstruct *ap = &atlantis[MI_SCREEN(mi)];

	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);

	MI_IS_DRAWN(mi) = True;

	if (!ap->glx_context)
		return;

	glXMakeCurrent(display, window, *(ap->glx_context));

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glPushMatrix();
        glRotatef(current_device_rotation(), 0, 0, 1);
        AllDisplay(ap);
        Animate(ap);
        glPopMatrix();

        if (mi->fps_p) do_fps (mi);
	glXSwapBuffers(display, window);
}
Exemple #11
0
ENTRYPOINT void
reshape_planet (ModeInfo *mi, int width, int height)
{
  planetstruct *gp = &planets[MI_SCREEN(mi)];
  GLfloat h = (GLfloat) height / (GLfloat) width;

  glXMakeCurrent(MI_DISPLAY(mi), gp->window, *gp->glx_context);

  glViewport(0, 0, (GLint) width, (GLint) height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glFrustum(-1.0, 1.0, -h, h, 5.0, 200.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glTranslatef(0.0, 0.0, -40);

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

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
Exemple #12
0
ENTRYPOINT void
draw_ball (ModeInfo *mi)
{
  ball_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glShadeModel(GL_SMOOTH);

  glEnable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  glEnable(GL_CULL_FACE);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix ();

  glRotatef(current_device_rotation(), 0, 0, 1);

  {
    double x, y, z;
    get_position (bp->rot, &x, &y, &z, !bp->button_down_p);
    glTranslatef((x - 0.5) * 6,
                 (y - 0.5) * 6,
                 (z - 0.5) * 2);

    gltrackball_rotate (bp->trackball);

    get_rotation (bp->rot, &x, &y, &z, !bp->button_down_p);
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

  mi->polygon_count = 0;

  glRotatef (50, 1, 0, 0);

  glScalef (4, 4, 4);
  glRotatef (bp->th, 0, 0, 1);
  if (! bp->button_down_p)
    {
      bp->th += (bp->th > 0 ? speed : -speed);
      while (bp->th >  360) bp->th -= 360;
      while (bp->th < -360) bp->th += 360;
    }

  mi->polygon_count += draw_ball_1 (mi);
  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
Exemple #13
0
/* Window management, etc
 */
ENTRYPOINT void
reshape_splitflap (ModeInfo *mi, int width, int height)
{
  GLfloat h = (GLfloat) height / (GLfloat) width;

  glViewport (0, 0, (GLint) width, (GLint) height);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective (40.0, 1/h, 0.5, 25);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt( 0, 0, 3,  /* 10x lower than traditional, for better depth rez */
             0, 0, 0,
             0, 1, 0);

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

  glClear(GL_COLOR_BUFFER_BIT);
}
Exemple #14
0
ENTRYPOINT void draw_antinspect(ModeInfo * mi) 
{
  antinspectstruct *mp;
  
  Display    *display = MI_DISPLAY(mi);
  Window      window = MI_WINDOW(mi);
  
  if(!antinspect)
    return;
  mp = &antinspect[MI_SCREEN(mi)];
  
  MI_IS_DRAWN(mi) = True;
  
  if(!mp->glx_context)
	return;
  
  glXMakeCurrent(display, window, *(mp->glx_context));
  
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix();

  mi->polygon_count = 0;

  /* position camera --- this works well, we can peer inside 
     the antbubble */
  glTranslatef(0.0, 0.0, -10.0);

# 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);
    glRotatef(o, 0, 0, 1);
  }
# endif

  gltrackball_rotate(mp->trackball);
  glRotatef((15.0/2.0 + 15.0*sin(mp->ant_step/100.0)), 1.0, 0.0, 0.0);
  glRotatef(30.0, 1.0, 0.0, 0.0);
  glRotatef(180.0, 0.0, 1.0, 0.0);
  
  if (!draw_antinspect_strip(mi)) {
	MI_ABORT(mi);
	return;
  }
  
  glPopMatrix();
  
  if (MI_IS_FPS(mi)) do_fps (mi);
  glFlush();
  
  glXSwapBuffers(display, window);
  
  mp->step += 0.025;
}
Exemple #15
0
ENTRYPOINT void draw_jigglypuff(ModeInfo *mi)
{
    jigglystruct *js = &jss[MI_SCREEN(mi)];
    
    glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(js->glx_context));
    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0,0,-10);


# 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(js->angle, sin(js->axis), cos(js->axis), -sin(js->axis));
    glTranslatef(0, 0, 5);
    if(!(js->button_down)) {
	if((js->angle += js->speed) >= 360.0f ) {
	    js->angle -= 360.0f;
	}
	if((js->axis+=0.01f) >= 2*M_PI ) {
	    js->axis -= 2*M_PI;
	}
    }

    gltrackball_rotate(js->trackball);

    if(js->color_style == COLOR_STYLE_CYCLE) {
	int i;
	vector_add(js->jiggly_color, js->color_dir, js->jiggly_color);
	
	for(i=0; i<3; i++) {
	    if(js->jiggly_color[i] > 1.0 || js->jiggly_color[i] < 0.3) {
		js->color_dir[i] = (-js->color_dir[i]);
		js->jiggly_color[i] += js->color_dir[i];
	    }
	}
	glColor4fv(js->jiggly_color);
    }
    
    mi->polygon_count = jigglypuff_render(js);
    if(MI_IS_FPS(mi))
	do_fps(mi);
    glFinish();
    update_shape(js);
    glXSwapBuffers(MI_DISPLAY(mi), MI_WINDOW(mi));
}
Exemple #16
0
static void
device_rotate(ModeInfo *mi)
{
  GLfloat rot = current_device_rotation();
  glRotatef(rot, 0, 0, 1);
  if ((rot >  45 && rot <  135) ||
      (rot < -45 && rot > -135))
    {
      GLfloat s = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
      glScalef (1/s, s, 1);
    }
}
static Bool 
draw_main(ModeInfo *mi, rubikblocks_conf *cp) 
{
  int i;
  double x, y, z;

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();
  get_position(cp->rot, &x, &y, &z, !cp->button_down);
  glTranslatef((x-0.5)*6, (y-0.5)*6, -20);

  /* Do it twice because we don't track the device's orientation. */
  glRotatef( current_device_rotation(), 0, 0, 1);
  gltrackball_rotate(cp->trackball);
  glRotatef(-current_device_rotation(), 0, 0, 1);

  get_rotation(cp->rot, &x, &y, &z, !cp->button_down);
  glRotatef(x*360, 1, 0, 0);
  glRotatef(y*360, 0, 1, 0);
  glRotatef(z*360, 0, 0, 1);
  glScalef(size, size, size);

  if(cp->wire) glColor3f(0.7, 0.7, 0.7);
  if(!cp->pause)
    for(i = 0; i < 27; i++)
      if(cp->pieces[i].act)
        mult_quat(cp->qfram, cp->pieces[i].qr);
  for(i = 0; i < 27; i++) 
  {
    glPushMatrix();
    if(fabs(cp->pieces[i].qr[0]) < 1)
      glRotatef(360/M_PI*acos(cp->pieces[i].qr[0]),
          cp->pieces[i].qr[1], cp->pieces[i].qr[2], cp->pieces[i].qr[3]);
    glCallList(cp->list_base + i);
    glPopMatrix();
  }
  if((cp->t += tspeed) > cp->tmax) finish(cp);
  return True;
}
ENTRYPOINT void
draw_cube (ModeInfo *mi)
{
  cube_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);
  int i;

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix ();
  glRotatef(current_device_rotation(), 0, 0, 1);
  gltrackball_rotate (bp->trackball);

  glScalef (2, 2, 2);

  mi->polygon_count = 0;

# if 0
  {
    floater F;
    F.x = F.y = F.z = 0;
    F.dx = F.dy = F.dz = 0;
    F.ddx = F.ddy = F.ddz = 0;
    F.rot = make_rotator (0, 0, 0, 1, 0, False);
    glRotatef (45, 0, 1, 0);
    draw_floater (mi, &F);
  }
# else
  for (i = 0; i < bp->nfloaters; i++)
    {
      floater *f = &bp->floaters[i];
      draw_floater (mi, f);
      tick_floater (mi, f);
    }
# endif

  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
ENTRYPOINT void draw_antinspect(ModeInfo * mi) 
{
  antinspectstruct *mp;
  
  Display    *display = MI_DISPLAY(mi);
  Window      window = MI_WINDOW(mi);
  
  if(!antinspect)
    return;
  mp = &antinspect[MI_SCREEN(mi)];
  
  MI_IS_DRAWN(mi) = True;
  
  if(!mp->glx_context)
	return;
  
  glXMakeCurrent(display, window, *(mp->glx_context));
  
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix();
  glRotatef(current_device_rotation(), 0, 0, 1);

  mi->polygon_count = 0;

  /* position camera --- this works well, we can peer inside 
     the antbubble */
  glTranslatef(0.0, 0.0, -10.0);
  gltrackball_rotate(mp->trackball);
  glRotatef((15.0/2.0 + 15.0*sin(mp->ant_step/100.0)), 1.0, 0.0, 0.0);
  glRotatef(30.0, 1.0, 0.0, 0.0);
  glRotatef(180.0, 0.0, 1.0, 0.0);
  
  if (!draw_antinspect_strip(mi)) {
	release_antinspect(mi);
	return;
  }
  
  glPopMatrix();
  
  if (MI_IS_FPS(mi)) do_fps (mi);
  glFlush();
  
  glXSwapBuffers(display, window);
  
  mp->step += 0.025;
}
static Bool 
draw_main(ModeInfo *mi, rubikblocks_conf *cp) 
{
  int i;
  double x, y, z;

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();

  get_position(cp->rot, &x, &y, &z, !cp->button_down);
  glTranslatef((x-0.5)*6, (y-0.5)*6, -20);

  gltrackball_rotate(cp->trackball);

  get_rotation(cp->rot, &x, &y, &z, !cp->button_down);
  glRotatef(x*360, 1, 0, 0);
  glRotatef(y*360, 0, 1, 0);
  glRotatef(z*360, 0, 0, 1);
  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

  if(cp->wire) glColor3f(0.7, 0.7, 0.7);
  if(!cp->pause)
    for(i = 0; i < 27; i++)
      if(cp->pieces[i].act)
        mult_quat(cp->qfram, cp->pieces[i].qr);
  for(i = 0; i < 27; i++) 
  {
    glPushMatrix();
    if(fabs(cp->pieces[i].qr[0]) < 1)
      glRotatef(360/M_PI*acos(cp->pieces[i].qr[0]),
          cp->pieces[i].qr[1], cp->pieces[i].qr[2], cp->pieces[i].qr[3]);
    glCallList(cp->list_base + i);
    glPopMatrix();
  }
  if((cp->t += tspeed) > cp->tmax) finish(cp);
  return True;
}
/*
 *-----------------------------------------------------------------------------
 *    Called by the mainline code periodically to update the display.
 *-----------------------------------------------------------------------------
 */
ENTRYPOINT void draw_fire(ModeInfo * mi)
{
    firestruct *fs = &fire[MI_SCREEN(mi)];

    Display *display = MI_DISPLAY(mi);
    Window window = MI_WINDOW(mi);

    MI_IS_DRAWN(mi) = True;

    if (!fs->glx_context)
	return;

    glXMakeCurrent(display, window, *(fs->glx_context));

    glShadeModel(GL_FLAT);
    glEnable(GL_DEPTH_TEST);

    /* makes particles blend with background */
    if (!MI_IS_WIREFRAME(mi)||(!fs->np))
    {
    	glEnable(GL_BLEND);
    	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    }

    /* fog stuff */
    glEnable(GL_FOG);
    glFogi(GL_FOG_MODE, GL_EXP);
    glFogfv(GL_FOG_COLOR, fogcolor);
    glFogf(GL_FOG_DENSITY, 0.03);
    glHint(GL_FOG_HINT, GL_NICEST);

    glPushMatrix();
    glRotatef(current_device_rotation(), 0, 0, 1);
    DrawFire(mi);
    glPopMatrix();
#ifndef STANDALONE
    Reshape(mi); /* xlock mode */
#else
    reshape_fire(mi,MI_WIDTH(mi),MI_HEIGHT(mi)); /* xscreensaver mode */
#endif

    glFinish();
    glXSwapBuffers(display, window);
}
Exemple #22
0
static int
DisplaySuperquadrics(ModeInfo *mi)
{
	superquadricsstruct *sp = &superquadrics[MI_SCREEN(mi)];
    int polys = 0;
	glDrawBuffer(GL_BACK);
	if (sp->wireframe)
		glClear(GL_COLOR_BUFFER_BIT);
	else
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	if (sp->viewcount < 1) {
		sp->viewcount = sp->viewwait;
/*		ReshapeSuperquadrics(-1, -1);*/
	}
	glPushMatrix();
	glTranslatef(0.0, 0.0, -((GLfloat) (sp->dist) / 16.0) - (sp->Mode * 3.0 - 1.0));	/* viewing transform  */
	glRotatef(sp->rotx, 1.0, 0.0, 0.0);	/* pitch */
	glRotatef(sp->rotz, 0.0, 0.0, 1.0);	/* bank */
	glRotatef(sp->roty, 0.0, 1.0, 0.0);	/* "spin", like heading but comes after P & B */

	SetCull(0, sp);

    glScalef(0.7, 0.7, 0.7);  /* jwz: scale it down a bit */

# 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

	polys = DoneScale(sp);

	glPopMatrix();

	/* Remember to flush & swap the buffers after calling this function! */
    return polys;
}
Exemple #23
0
/* Fill the background with a gradient -- thanks to 
   Phil Carrig <*****@*****.**> for figuring out
   how to do this more efficiently!
 */
static void
clear_tank (atlantisstruct * ap)
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  if (do_gradient && !ap->wire)
    {
      GLfloat top[4] = { 0.00, 0.40, 0.70, };
      GLfloat bot[4] = { 0.00, 0.05, 0.18, };

      glMatrixMode(GL_PROJECTION);
      glPushMatrix();
      {
        glLoadIdentity();
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        {
          glLoadIdentity();
          glRotatef(current_device_rotation(), 0, 0, 1);

# ifndef HAVE_JWZGLES
          glShadeModel (GL_SMOOTH);
# endif
          glDisable (GL_LIGHTING);
          glBegin (GL_QUADS);
          glColor3fv (bot);
          glVertex3f (-1, -1, 1); glVertex3f ( 1, -1, 1);
          glColor3fv (top);
          glVertex3f ( 1,  1, 1); glVertex3f (-1,  1, 1);
          glEnd();
          glEnable (GL_LIGHTING);
        }
        glPopMatrix();
      }
      glMatrixMode(GL_PROJECTION);
      glPopMatrix();

      glMatrixMode(GL_MODELVIEW);
    }
}
Exemple #24
0
ENTRYPOINT Bool
cube_handle_event (ModeInfo *mi, XEvent *event)
{
  cube_configuration *cc = &ccs[MI_SCREEN(mi)];

  /* Neutralize any vertical motion */
  GLfloat rot = current_device_rotation();
  Bool rotp = ((rot >  45 && rot <  135) ||
               (rot < -45 && rot > -135));
               
  if (event->xany.type == ButtonPress ||
      event->xany.type == ButtonRelease)
    {
      if (rotp)
        event->xbutton.x = MI_WIDTH(mi) / 2;
      else
        event->xbutton.y = MI_HEIGHT(mi) / 2;
    }
  else if (event->xany.type == MotionNotify)
    {
      if (rotp)
        event->xmotion.x = MI_WIDTH(mi) / 2;
      else
        event->xmotion.y = MI_HEIGHT(mi) / 2;
    }

  if (gltrackball_event_handler (event, cc->trackball,
                                 MI_WIDTH (mi), MI_HEIGHT (mi),
                                 &cc->button_down_p))
    return True;
  else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
    {
      reset_colors (mi);
      tweak_cubes (mi);
      gltrackball_reset (cc->trackball, 0, 0);
      return True;
    }

  return False;
}
Exemple #25
0
ENTRYPOINT void
draw_stonerview (ModeInfo *mi)
{
  stonerview_configuration *bp = &bps[MI_SCREEN(mi)];

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glPushMatrix ();
  glRotatef( current_device_rotation(), 0, 0, 1);
  gltrackball_rotate (bp->trackball);

  stonerview_win_draw(bp->st);
  if (! bp->button_down_p)
    stonerview_move_increment(bp->st);
  glPopMatrix ();

  mi->polygon_count = NUM_ELS;
  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(MI_DISPLAY (mi), MI_WINDOW(mi));
}
Exemple #26
0
static int
display(Flipflopcreen *c)
{
    GLfloat amb[] = { 0.8, 0.8, 0.8, 1.0 };
    int polys = 0;


    glClear(clearbits);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.2);
    glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.15/board_avg_size );
    glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.15/board_avg_size );
    glLightfv(GL_LIGHT0, GL_AMBIENT, amb);


    glRotatef(current_device_rotation(), 0, 0, 1);

    /** setup perspectif */
    glTranslatef(0.0, 0.0, -c->reldist*board_avg_size);
    glRotatef(22.5, 1.0, 0.0, 0.0);  
    gltrackball_rotate (c->trackball);
    glRotatef(c->theta*100, 0.0, 1.0, 0.0);
    glTranslatef(-0.5*board_x_size, 0.0, -0.5*board_y_size); /* Center the board */

    /* set texture */
    if(textured)
      glBindTexture(GL_TEXTURE_2D, c->texid);

    polys = drawBoard(c);

    if (!c->button_down_p) {
        c->theta += .01 * spin;
    }

    return polys;
}
Exemple #27
0
/* Window management, etc
 */
ENTRYPOINT void
reshape_voronoi (ModeInfo *mi, int width, int height)
{
/*  voronoi_configuration *vp = &vps[MI_SCREEN(mi)];*/

  glViewport (0, 0, (GLint) width, (GLint) height);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho (0, 1, 1, 0, -1, 1);

# ifdef HAVE_MOBILE	/* So much WTF */
  {
    int rot = current_device_rotation();

    glTranslatef (0.5, 0.5, 0);
    //  glScalef(0.19, 0.19, 0.19);

    if (rot == 180 || rot == -180) {
      glTranslatef (1, 1, 0);
    } else if (rot == 90 || rot == -270) {
      glRotatef (180, 0, 0, 1);
      glTranslatef (0, 1, 0);
    } else if (rot == -90 || rot == 270) {
      glRotatef (180, 0, 0, 1);
      glTranslatef (1, 0, 0);
    }

    glTranslatef(-0.5, -0.5, 0);
  }
# endif

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  glClear(GL_COLOR_BUFFER_BIT);
}
Exemple #28
0
static Bool draw_main(ModeInfo *mi)
{
  cubicgrid_conf *cp = &cubicgrid[MI_SCREEN(mi)];
  double x, y, z;

  glClear(GL_COLOR_BUFFER_BIT);
  glLoadIdentity();

  glRotatef (180, 1, 0, 0);  /* Make trackball track the right way */
  glRotatef (180, 0, 1, 0);

  glTranslatef(0, 0, zpos);

  glScalef(size/ticks, size/ticks, size/ticks);


# 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);
  }
# endif

  gltrackball_rotate (cp->trackball);

  get_rotation (cp->rot, &x, &y, &z, !cp->button_down_p);
  glRotatef (-x * 360, 1.0, 0.0, 0.0);
  glRotatef (-y * 360, 0.0, 1.0, 0.0);
  glRotatef (-z * 360, 0.0, 0.0, 1.0);

  glTranslatef(-ticks/2.0, -ticks/2.0, -ticks/2.0);
  glCallList(cp->list);
  return True;
}
Exemple #29
0
ENTRYPOINT void
draw_planet (ModeInfo * mi)
{
  planetstruct *gp = &planets[MI_SCREEN(mi)];
  Display    *display = MI_DISPLAY(mi);
  Window      window = MI_WINDOW(mi);
  double x, y, z;

  if (!gp->glx_context)
	return;

  glDrawBuffer(GL_BACK);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glXMakeCurrent (display, window, *(gp->glx_context));

  mi->polygon_count = 0;

  if (do_stars)
    {
      draw_stars (mi);
      mi->polygon_count += NUM_STARS;
    }

  if (do_light)   glEnable(GL_LIGHTING);
  if (do_texture) glEnable(GL_TEXTURE_2D);

  glEnable (GL_LINE_SMOOTH);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_CULL_FACE);
  glCullFace(GL_BACK); 

  glPushMatrix();

  get_position (gp->rot, &x, &y, &z, !gp->button_down_p);
  glTranslatef((x - 0.5) * 15,
               (y - 0.5) * 15,
               (z - 0.5) * 8);

  /* Do it twice because we don't track the device's orientation. */
  glRotatef( current_device_rotation(), 0, 0, 1);
  gltrackball_rotate (gp->trackball);
  glRotatef(-current_device_rotation(), 0, 0, 1);

  glRotatef (90,1,0,0);

  if (do_roll)
    {
      get_rotation (gp->rot, &x, &y, 0, !gp->button_down_p);
      glRotatef (x * 360, 1.0, 0.0, 0.0);
      glRotatef (y * 360, 0.0, 1.0, 0.0);
    }

  glLightfv (GL_LIGHT0, GL_POSITION, gp->sunpos);

  glRotatef (gp->z * 360, 0.0, 0.0, 1.0);
  if (do_rotate && !gp->button_down_p)
    {
      gp->z -= 0.005;     /* the sun sets in the west */
      if (gp->z < 0) gp->z += 1;
    }

  glCallList (gp->platelist);
  mi->polygon_count += resolution*resolution;

  if (gp->button_down_p)
    {
      glCallList (gp->latlonglist);
      mi->polygon_count += 24*24;
    }
  glPopMatrix();

  if (mi->fps_p) do_fps (mi);
  glFinish();
  glXSwapBuffers(display, window);

  gp->star_theta += star_spin;
}
Exemple #30
0
ENTRYPOINT void
draw_pipes (ModeInfo * mi)
{
	pipesstruct *pp = &pipes[MI_SCREEN(mi)];
	Display *display = MI_DISPLAY(mi);
	Window    window = MI_WINDOW(mi);
    Bool        wire = MI_IS_WIREFRAME(mi);
    int i = 0;

	if (!pp->glx_context)
		return;

	glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(pp->glx_context));
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glColor3f(1.0, 1.0, 1.0);

	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0);
	glLightfv(GL_LIGHT0, GL_POSITION, position0);
	glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1);
	glLightfv(GL_LIGHT1, GL_POSITION, position1);
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
	glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);

    if (wire)
      glDisable(GL_LIGHTING);
    else
      {
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
        /* This looks crappy. */
        /* glEnable(GL_LIGHT1); */
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_NORMALIZE);
        glEnable(GL_CULL_FACE);
      }

	glShadeModel(GL_SMOOTH);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular);

    glPushMatrix();

    pp->initial_rotation += 0.02;

	glTranslatef(0.0, 0.0, fisheye ? -3.8 : -4.8);

    /* Do it twice because we don't track the device's orientation. */
    glRotatef( current_device_rotation(), 0, 0, 1);
    gltrackball_rotate (pp->trackball);
    glRotatef(-current_device_rotation(), 0, 0, 1);

	if (rotatepipes)
      glRotatef(pp->initial_rotation, 0.0, 1.0, 0.0);

    glScalef(Scale4Window, Scale4Window, Scale4Window);

    mi->polygon_count = 0;

    if (pp->fadeout)
      {
        GLfloat s = (pp->fadeout * pp->fadeout) / 10000.0;
        glScalef (s, s, s);
        glRotatef (90 * (1 - (pp->fadeout/100.0)), 1, 0, 0.1);
        pp->fadeout -= 4;
        if (pp->fadeout <= 0)
          {
            pp->fadeout = 0;
            generate_system (mi);
          }
      }
    else if (pp->system_index < pp->system_size)
      pp->system_index++;
    else
      pp->fadeout = 100;

    for (i = 0; i < pp->system_index; i++)
      {
        glCallList (pp->dlists[i]);
        mi->polygon_count += pp->poly_counts[i];
      }

    glPopMatrix();

    if (mi->fps_p) do_fps (mi);
    glFinish();

    glXSwapBuffers(display, window);
}