/* *----------------------------------------------------------------------------- * Called by the mainline code periodically to update the display. *----------------------------------------------------------------------------- */ ENTRYPOINT void draw_hypertorus(ModeInfo *mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); hypertorusstruct *hp; if (hyper == NULL) return; hp = &hyper[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if (!hp->glx_context) return; glXMakeCurrent(display,window,*(hp->glx_context)); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); display_hypertorus(mi); if (MI_IS_FPS(mi)) do_fps (mi); glFlush(); glXSwapBuffers(display,window); }
void draw_gasket(ModeInfo * mi) { gasketstruct *gp = &gasket[MI_SCREEN(mi)]; Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); int angle_incr = 1; if (!gp->glx_context) return; glDrawBuffer(GL_BACK); if (max_depth > 10) max_depth = 10; MI_IS_DRAWN(mi) = True; glXMakeCurrent(display, window, *(gp->glx_context)); draw(mi); /* rotate */ gp->angle = (int) (gp->angle + angle_incr) % 360; rotate(&gp->rotx, &gp->dx, &gp->ddx, gp->d_max, MI_IS_VERBOSE(mi)); rotate(&gp->roty, &gp->dy, &gp->ddy, gp->d_max, MI_IS_VERBOSE(mi)); rotate(&gp->rotz, &gp->dz, &gp->ddz, gp->d_max, MI_IS_VERBOSE(mi)); /* if (mi->fps_p) do_fps (mi); */ if (MI_IS_FPS(mi)) do_fps (mi); glFinish(); glXSwapBuffers(display, window); }
/* *----------------------------------------------------------------------------- * Called by the mainline code periodically to update the display. *----------------------------------------------------------------------------- */ ENTRYPOINT void draw_projectiveplane(ModeInfo *mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); projectiveplanestruct *pp; if (projectiveplane == NULL) return; pp = &projectiveplane[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if (!pp->glx_context) return; glXMakeCurrent(display,window,*(pp->glx_context)); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); display_projectiveplane(mi); if (MI_IS_FPS(mi)) do_fps (mi); glFlush(); glXSwapBuffers(display,window); }
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; }
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; }
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)); }
ENTRYPOINT void draw_antspotlight(ModeInfo * mi) { antspotlightstruct *mp; Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if(!antspotlight) return; mp = &antspotlight[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if(!mp->glx_context) return; /* Just keep running before the texture has come in. */ /* if (mp->waiting_for_image_p) return; */ glXMakeCurrent(display, window, *(mp->glx_context)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); /* position camera */ /* follow focused ant */ glTranslatef(0.0, 0.0, -6.0 - mp->mag); glRotatef(35.0, 1.0, 0.0, 0.0); gltrackball_rotate(mp->trackball); glTranslatef(-mp->ant->position[0], mp->ant->position[1], -mp->ant->position[2]); /* stable position */ /* glTranslatef(0.0, 0.0, -10.0 - mag); */ /* gltrackball_rotate(mp->trackball); */ /* glRotatef(40.0, 1.0, 0.0, 0.0); */ /* glRotatef(20.0, 0.0, 1.0, 0.0); */ draw_antspotlight_strip(mi); ++mp->ticks; glPopMatrix(); if (MI_IS_FPS(mi)) do_fps (mi); glFlush(); glXSwapBuffers(display, window); }
ENTRYPOINT void draw_providence(ModeInfo * mi) { providencestruct *mp; Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if(!providence) return; mp = &providence[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(); /* modify camera */ if(fabs(mp->camera_velocity) > EPSILON) { mp->camera_z = max(min(mp->camera_z + 0.1*mp->camera_velocity, -4.0), -12.0); mp->camera_velocity = 0.95*mp->camera_velocity; } /* rotate providence */ glTranslatef(0.0, 0.0, mp->camera_z + sin(mp->theta/4.0)); glRotatef(10.0+20.0*sin(mp->theta/2.0), 1.0, 0.0, 0.0); gltrackball_rotate(mp->trackball); glRotatef(mp->theta * 180.0 / Pi, 0.0, -1.0, 0.0); /* draw providence */ draw_providence_strip(mi); glPopMatrix(); if(MI_IS_FPS(mi)) do_fps (mi); glFlush(); glXSwapBuffers(display, window); /* update */ mp->currenttime += 1.0 / FPS; mp->theta = mp->currenttime / 2.0 * mp->theta_scale; update_particles(mp); }
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)); }
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; }
ENTRYPOINT void draw_cage (ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); cagestruct *cp; if (cage == NULL) return; cp = &cage[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if (!cp->glx_context) return; glXMakeCurrent(display, window, *(cp->glx_context)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(0.0, 0.0, -10.0); if (!MI_IS_ICONIC(mi)) { glScalef(Scale4Window * cp->WindH / cp->WindW, Scale4Window, Scale4Window); } else { glScalef(Scale4Iconic * cp->WindH / cp->WindW, Scale4Iconic, Scale4Iconic); } /* cage */ glRotatef(cp->step * 100, 0, 0, 1); glRotatef(25 + cos(cp->step * 5) * 6, 1, 0, 0); glRotatef(204.5 - sin(cp->step * 5) * 8, 0, 1, 0); if (!draw_impossiblecage(cp, MI_IS_WIREFRAME(mi))) { release_cage(mi); return; } glPopMatrix(); if (MI_IS_FPS(mi)) do_fps (mi); glFlush(); glXSwapBuffers(display, window); cp->step += 0.025; }
ENTRYPOINT void draw_commander(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); commander_conf *cp = &commander[MI_SCREEN(mi)]; if (!cp->glx_context) return; /*MI_IS_DRAWN(mi) = True;*/ glXMakeCurrent(display, window, *(cp->glx_context)); if (!draw_main(cp)) { release_commander(mi); return; } mi->polygon_count = cp->npoints; if (MI_IS_FPS(mi)) do_fps (mi); glFinish(); glXSwapBuffers(display, window); }
ENTRYPOINT void draw_cubicgrid(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); cubicgrid_conf *cp; if (!cubicgrid) return; cp = &cubicgrid[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if (!cp->glx_context) return; glXMakeCurrent(display, window, *(cp->glx_context)); if (!draw_main(cp)) { release_cubicgrid(mi); return; } if (MI_IS_FPS(mi)) do_fps (mi); glFlush(); glXSwapBuffers(display, window); }
ENTRYPOINT void draw_bang (ModeInfo *mi) { Display *dpy = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); GLfloat camx, camz; float r = 10.0; int LightPos[4] = {-10,0,0,1}; int MatSpec [4] = {1,1,1,1}; glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bang->glx_context)); glMaterialiv(GL_FRONT_AND_BACK,GL_SPECULAR,MatSpec); glMateriali(GL_FRONT_AND_BACK,GL_SHININESS,100); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /* set camera position */ camx = r*sin(bang->alpha) + 0.5; camz = r*cos(bang->alpha) + 0.5; bang->alpha += 0.01; if (bang->alpha == 360) { bang->alpha = 0; } gluLookAt(camx, 0.0, camz, 0.0, 0.0, 0.0, 0, 1, 0); glLightiv(GL_LIGHT0, GL_POSITION, LightPos); /* gluLookAt(10, 0.0, 10, 0, 0, 0, 0, 1, 0);*/ glPushMatrix (); drawsphere(0.1, 0.0, 0.0, 0.0); drawsphere(0.5, 3.0, 0.0, 0.0); drawsphere(1.0, 6.0, 0.0, 0.0); glPopMatrix (); if (MI_IS_FPS(mi)) do_fps (mi); glXSwapBuffers(dpy, window); }
ENTRYPOINT void draw_cube21(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); cube21_conf *cp; if (!cube21) return; cp = &cube21[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if (!cp->glx_context) return; mi->polygon_count = 0; glXMakeCurrent(display, window, *cp->glx_context); if (!draw_main(mi, cp)) { MI_ABORT(mi); return; } if (MI_IS_FPS(mi)) do_fps (mi); glFlush(); glXSwapBuffers(display, window); }
ENTRYPOINT void draw_rubikblocks(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); rubikblocks_conf *cp; if (!rubikblocks) return; cp = &rubikblocks[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if (!cp->glx_context) return; mi->polygon_count = 0; glXMakeCurrent(display, window, *(cp->glx_context)); if (!draw_main(mi, cp)) { release_rubikblocks(mi); return; } if (MI_IS_FPS(mi)) do_fps (mi); glFlush(); glXSwapBuffers(display, window); }
/* draw the screensaver once */ ENTRYPOINT void draw_atunnel(ModeInfo * mi) { atunnelstruct *sa = &Atunnel[MI_SCREEN(mi)]; Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if (!sa->glx_context) return; glXMakeCurrent(display, window, *(sa->glx_context)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); DrawTunnel(sa->ts, do_texture, do_light, sa->texture); SplashScreen(sa->ts, do_wire, do_texture, do_light); glFlush(); /* manage framerate display */ if (MI_IS_FPS(mi)) do_fps (mi); glXSwapBuffers(display, window); }
ENTRYPOINT void draw_morph3d(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); morph3dstruct *mp; if (morph3d == NULL) return; mp = &morph3d[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if (!mp->glx_context) return; mi->polygon_count = 0; glXMakeCurrent(display, window, *(mp->glx_context)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(0.0, 0.0, -10.0); if (!MI_IS_ICONIC(mi)) { glScalef(Scale4Window * mp->WindH / mp->WindW, Scale4Window, Scale4Window); glTranslatef(2.5 * mp->WindW / mp->WindH * sin(mp->step * 1.11), 2.5 * cos(mp->step * 1.25 * 1.11), 0); } else { glScalef(Scale4Iconic * mp->WindH / mp->WindW, Scale4Iconic, Scale4Iconic); } # 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, h, 1); } # endif glRotatef(mp->step * 100, 1, 0, 0); glRotatef(mp->step * 95, 0, 1, 0); glRotatef(mp->step * 90, 0, 0, 1); mp->seno = (sin(mp->step) + 1.0 / 3.0) * (4.0 / 5.0) * mp->Magnitude; if (mp->VisibleSpikes) { #ifdef DEBUG_CULL_FACE int loop; for (loop = 0; loop < 20; loop++) mp->MaterialColor[loop] = MaterialGray; #endif glDisable(GL_CULL_FACE); } else { #ifdef DEBUG_CULL_FACE int loop; for (loop = 0; loop < 20; loop++) mp->MaterialColor[loop] = MaterialWhite; #endif glEnable(GL_CULL_FACE); } mp->draw_object(mi); glPopMatrix(); if (MI_IS_FPS(mi)) do_fps (mi); glXSwapBuffers(display, window); mp->step += 0.05; }
void draw_molecule (ModeInfo *mi) { /* static time_t last = 0; */ time_t now = time ((time_t *) 0); molecule_configuration *mc; Display *dpy = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if (mcs == NULL) return; mc = &mcs[MI_SCREEN(mi)]; if (!mc->glx_context) return; MI_IS_DRAWN(mi) = True; if (last + timeout <= now) /* randomize molecules every -timeout seconds */ { if (mc->nmolecules == 1) { if (last != 0) goto SKIP; mc->which = 0; } else if (last == 0) { mc->which = NRAND(mc->nmolecules); } else { int n = mc->which; while (n == mc->which) n = NRAND(mc->nmolecules); mc->which = n; } last = now; glNewList (mc->molecule_dlist, GL_COMPILE); ensure_bounding_box_visible (mi); if (MI_IS_ICONIC(mi)) {do_labels = False; do_bonds = True; do_titles = False; } else { do_labels = orig_do_labels; do_bonds = orig_do_bonds; do_titles = orig_do_titles; } cur_wire = orig_wire; if (mc->molecule_size > mc->no_label_threshold) do_labels = 0; if (mc->molecule_size > mc->wireframe_threshold) cur_wire = 1; if (cur_wire) do_bonds = 1; build_molecule (mi); glEndList(); } SKIP: glPushMatrix (); glScalef(1.1, 1.1, 1.1); { GLfloat x, y, z; if (do_wander) { static int frame = 0; # define SINOID(SCALE,SIZE) \ ((((1 + sin((frame * (SCALE)) / 2 * M_PI)) / 2.0) * (SIZE)) - (SIZE)/2) x = SINOID(0.031, 9.0); y = SINOID(0.023, 9.0); z = SINOID(0.017, 9.0); frame++; glTranslatef(x, y, z); } if (mc->spin_x || mc->spin_y || mc->spin_z) { x = mc->rotx; y = mc->roty; z = mc->rotz; if (x < 0) x = 1 - (x + 1); if (y < 0) y = 1 - (y + 1); if (z < 0) z = 1 - (z + 1); if (mc->spin_x) glRotatef(x * 360, 1.0, 0.0, 0.0); if (mc->spin_y) glRotatef(y * 360, 0.0, 1.0, 0.0); if (mc->spin_z) glRotatef(z * 360, 0.0, 0.0, 1.0); rotate(&mc->rotx, &mc->dx, &mc->ddx, mc->d_max, MI_IS_VERBOSE(mi)); rotate(&mc->roty, &mc->dy, &mc->ddy, mc->d_max, MI_IS_VERBOSE(mi)); rotate(&mc->rotz, &mc->dz, &mc->ddz, mc->d_max, MI_IS_VERBOSE(mi)); } } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glCallList (mc->molecule_dlist); glPopMatrix (); if (MI_IS_FPS(mi)) do_fps (mi); glFinish(); glXSwapBuffers(dpy, window); }
static void Draw(ModeInfo * mi) { sballsstruct *sb = &sballs[MI_SCREEN(mi)]; int sphere; mi->polygon_count = 0; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glEnable(GL_DEPTH_TEST); /* move eyes */ glTranslatef (-sb->eye[0], -sb->eye[1], -sb->eye[2]); /* draw background */ if (do_texture) { glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glColor3f(1, 1, 1); #ifdef HAVE_GLBINDTEXTURE glBindTexture(GL_TEXTURE_2D, sb->backid); #endif /* HAVE_GLBINDTEXTURE */ } else { glColor3f(0, 0, 0); } glBegin(GL_QUAD_STRIP); #ifndef HAVE_MOBILE /* Letterbox the background image */ glNormal3f(0, 0, 1); glTexCoord2f(0,0); glVertex3f(8, 4.1, -4); glNormal3f(0, 0, 1); glTexCoord2f(0,1); glVertex3f(8, -4.1, -4); glNormal3f(0, 0, 1); glTexCoord2f(1,0); glVertex3f(-8, 4.1, -4); glNormal3f(0, 0, 1); glTexCoord2f(1,1); glVertex3f(-8, -4.1, -4); #else /* Fill the iPhone screen. Letterboxing looks dumb there. */ glNormal3f(0, 0, 1); glTexCoord2f(0,0); glVertex3f(4, 5.2, -4); glNormal3f(0, 0, 1); glTexCoord2f(0,1); glVertex3f(4, -5.2, -4); glNormal3f(0, 0, 1); glTexCoord2f(1,0); glVertex3f(-4, 5.2, -4); glNormal3f(0, 0, 1); glTexCoord2f(1,1); glVertex3f(-4, -5.2, -4); #endif glEnd(); mi->polygon_count++; gltrackball_rotate (sb->trackball); /* rotate the balls */ glRotatef(sb->rotm[0], 1.0f, 0.0f, 0.0f); glRotatef(sb->rotm[1], 0.0f, 1.0f, 0.0f); glRotatef(sb->rotm[2], 0.0f, 0.0f, 1.0f); if (! sb->button_down_p) { sb->rotm[0] += sb->speed; sb->rotm[1] += -(sb->speed); sb->rotm[2] += 0; } /* draw the balls */ if (do_texture) #ifdef HAVE_GLBINDTEXTURE glBindTexture(GL_TEXTURE_2D, sb->faceid); else #endif /* HAVE_GLBINDTEXTURE */ glEnable(GL_LIGHTING); for (sphere=0;sphere<spheres;sphere++) { drawSphere(mi,sphere); } glDisable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); /* manage framerate display */ if (MI_IS_FPS(mi)) do_fps (mi); glPopMatrix(); }
void draw_morph3d(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); morph3dstruct *mp; if (morph3d == NULL) return; mp = &morph3d[MI_SCREEN(mi)]; if (!mp->glx_context) return; MI_IS_DRAWN(mi) = True; #ifdef WIN32 wglMakeCurrent(hdc, mp->glx_context); #else glXMakeCurrent(display, window, *(mp->glx_context)); #endif glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(0.0, 0.0, -10.0); if (!MI_IS_ICONIC(mi)) { glScalef(Scale4Window * mp->WindH / mp->WindW, Scale4Window, Scale4Window); glTranslatef(2.5 * mp->WindW / mp->WindH * sin(mp->step * 1.11), 2.5 * cos(mp->step * 1.25 * 1.11), 0); } else { glScalef(Scale4Iconic * mp->WindH / mp->WindW, Scale4Iconic, Scale4Iconic); } glRotatef(mp->step * 100, 1, 0, 0); glRotatef(mp->step * 95, 0, 1, 0); glRotatef(mp->step * 90, 0, 0, 1); mp->seno = (sin(mp->step) + 1.0 / 3.0) * (4.0 / 5.0) * mp->Magnitude; if (mp->VisibleSpikes) { #ifdef DEBUG_CULL_FACE int loop; for (loop = 0; loop < 20; loop++) mp->MaterialColor[loop] = MaterialGray; #endif glDisable(GL_CULL_FACE); } else { #ifdef DEBUG_CULL_FACE int loop; for (loop = 0; loop < 20; loop++) mp->MaterialColor[loop] = MaterialWhite; #endif glEnable(GL_CULL_FACE); } mp->draw_object(mi); glPopMatrix(); glFlush(); if (MI_IS_FPS(mi)) do_fps (mi); glXSwapBuffers(display, window); mp->step += 0.05; }
ENTRYPOINT void draw_antmaze(ModeInfo * mi) { double h = (GLfloat) MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi); antmazestruct *mp; Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if(!antmaze) return; mp = &antmaze[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if(!mp->glx_context) return; mi->polygon_count = 0; glXMakeCurrent(display, window, *(mp->glx_context)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* first panel */ glPushMatrix(); /* h = ((GLfloat) MI_HEIGHT(mi)/2) / (3*(GLfloat)MI_WIDTH(mi)/4); */ glViewport(MI_WIDTH(mi)/32, MI_HEIGHT(mi)/8, (9*MI_WIDTH(mi))/16, 3*MI_HEIGHT(mi)/4); glMatrixMode(GL_PROJECTION); glLoadIdentity(); /* h = (3*MI_HEIGHT(mi)/4) / (3*MI_WIDTH(mi)/4); */ gluPerspective(45, 1/h, 1, 25.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); device_rotate(mi); glPushMatrix(); /* follow focused ant */ glTranslatef(0.0, 0.0, -mp->mag - 5.0); glRotatef(20.0+5.0*sin(mp->ant_step/40.0), 1.0, 0.0, 0.0); /* glTranslatef(0.0, */ /* started ? -mag : -8.0 + 4.0*fabs(sin(ant_step/10.0)), */ /* started ? -mag : -8.0 + 4.0*fabs(sin(ant_step/10.0))); */ gltrackball_rotate(mp->trackball); glRotatef(mp->ant_step*0.6, 0.0, 1.0, 0.0); /* glRotatef(90.0, 0.0, 0.0, 1.0); */ /* glTranslatef(-antposition[0][0]-0.5, 0.0, -antposition[focus][1]); */ /*-elevator*/ /* sync */ if(!draw_antmaze_strip(mi)) { release_antmaze(mi); return; } glPopMatrix(); glPopMatrix(); h = (GLfloat) (3*MI_HEIGHT(mi)/8) / (GLfloat) (MI_WIDTH(mi)/2); /* draw overhead */ glPushMatrix(); glViewport((17*MI_WIDTH(mi))/32, MI_HEIGHT(mi)/2, MI_WIDTH(mi)/2, 3*MI_HEIGHT(mi)/8); glMatrixMode(GL_PROJECTION); glLoadIdentity(); device_rotate(mi); gluPerspective(45, 1/h, 1, 25.0); glMatrixMode(GL_MODELVIEW); /* twist scene */ glTranslatef(0.0, 0.0, -16.0); glRotatef(60.0, 1.0, 0.0, 0.0); glRotatef(-15.0 + mp->ant_step/10.0, 0.0, 1.0, 0.0); gltrackball_rotate(mp->trackball); /* sync */ if(!draw_antmaze_strip(mi)) { release_antmaze(mi); return; } glPopMatrix(); /* draw ant display */ glPushMatrix(); glViewport((5*MI_WIDTH(mi))/8, MI_HEIGHT(mi)/8, (11*MI_WIDTH(mi))/32, 3*MI_HEIGHT(mi)/8); glMatrixMode(GL_PROJECTION); glLoadIdentity(); device_rotate(mi); gluPerspective(45, 1/h, 1, 25.0); glMatrixMode(GL_MODELVIEW); /* twist scene */ glTranslatef(0.0, 0.0, -1.6); glRotatef(30.0, 1.0, 0.0, 0.0); glRotatef(mp->ant_step, 0.0, 1.0, 0.0); glRotatef(90.0, 0.0, 0.0, 1.0); /* /\* draw ant shadow *\/ */ /* glPushMatrix(); */ /* glScalef(1.0, 0.01, 1.0); */ /* glRotatef(90.0, 0.0, 0.0, 1.0); */ /* glRotatef(90.0, 0.0, 1.0, 0.0); */ /* glDisable(GL_LIGHTING); */ /* glColor4fv(MaterialGray6); */ /* /\* slow down first ant *\/ */ /* draw_ant(MaterialGrayB, 0, 1, first_ant_step, mySphere, myCone); */ /* glPopMatrix(); */ /* draw ant body */ glEnable(GL_TEXTURE_2D); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse); glBindTexture(GL_TEXTURE_2D, mp->brushedtexture); draw_ant(mi, mp, MaterialGray35, 0, 1, mp->ant_step/2.0, mySphereTex, myCone2); glDisable(GL_TEXTURE_2D); glPopMatrix(); /* /\* draw overlay *\/ */ /* glPushMatrix(); */ /* /\* go to ortho mode *\/ */ /* glViewport(MI_WIDTH(mi)/2, MI_HEIGHT(mi)/8, MI_WIDTH(mi)/2, 3*MI_HEIGHT(mi)/8); */ /* glMatrixMode(GL_PROJECTION); */ /* glLoadIdentity(); */ /* glPushMatrix (); */ /* glOrtho(-4.0, 4.0, -3.0, 3.0, -100.0, 100.0); */ /* glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGrayB); */ /* glColor4fv(MaterialGrayB); */ /* glDisable(GL_LIGHTING); */ /* glEnable(GL_BLEND); */ /* glBegin(GL_QUADS); */ /* glNormal3f(0.0, 0.0, 1.0); */ /* glVertex3f(4.0, 3.0, 0.0); */ /* glVertex3f(2.0, 3.0, 0.0); */ /* glVertex3f(2.0, -3.0, 0.0); */ /* glVertex3f(4.0, -3.0, 0.0); */ /* mi->polygon_count++; */ /* glEnd(); */ /* glEnable(GL_LIGHTING); */ /* glDisable(GL_BLEND); */ /* glPopMatrix(); */ /* glPopMatrix(); */ if (MI_IS_FPS(mi)) { glViewport(0, 0, MI_WIDTH(mi), MI_HEIGHT(mi)); do_fps (mi); } glFlush(); glXSwapBuffers(display, window); update_ants(mp); mp->step += 0.025; }
static void DrawFire(ModeInfo * mi) { int j; firestruct *fs = &fire[MI_SCREEN(mi)]; Bool wire = MI_IS_WIREFRAME(mi); if (do_trackmouse && !MI_IS_ICONIC(mi)) trackmouse(mi); if (do_wander) { GLfloat x, y, z; # define SINOID(SCALE,SIZE) \ ((((1 + sin((frame * (SCALE)) / 2 * M_PI)) / 2.0) * (SIZE)) - (SIZE)/2) x = SINOID(0.031, 0.85); y = SINOID(0.017, 0.25); z = SINOID(0.023, 0.85); frame++; fs->obs[0] = x + DEF_OBS[0]; fs->obs[1] = y + DEF_OBS[1]; fs->obs[2] = z + DEF_OBS[2]; fs->dir[1] = y; fs->dir[2] = z; } glEnable(GL_DEPTH_TEST); if (fs->fog) glEnable(GL_FOG); else glDisable(GL_FOG); glDepthMask(GL_TRUE); glClearColor(0.5, 0.5, 0.8, 1.0); /* sky in the distance */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); calcposobs(fs); gluLookAt(fs->obs[0], fs->obs[1], fs->obs[2], fs->obs[0] + fs->dir[0], fs->obs[1] + fs->dir[1], fs->obs[2] + fs->dir[2], 0.0, 1.0, 0.0); glEnable(GL_TEXTURE_2D); /* draw ground using the computed texture */ #ifdef HAVE_GLBINDTEXTURE if (do_texture) { glColor4f(1.0,1.0,1.0,1.0); /* white to get texture in it's true color */ glBindTexture(GL_TEXTURE_2D, fs->groundid); } else #endif /* HAVE_GLBINDTEXTURE */ glColor4f(0.54, 0.27, 0.07, 1.0); /* untextured ground color */ glBegin(GL_QUADS); glTexCoord2fv(qt[0]); glVertex3fv(q[0]); glTexCoord2fv(qt[1]); glVertex3fv(q[1]); glTexCoord2fv(qt[2]); glVertex3fv(q[2]); glTexCoord2fv(qt[3]); glVertex3fv(q[3]); glEnd(); glAlphaFunc(GL_GEQUAL, 0.9); #ifdef HAVE_GLBINDTEXTURE if (fs->num_trees) { /* here do_texture IS True - and color used is white */ glEnable(GL_ALPHA_TEST); glBindTexture(GL_TEXTURE_2D,fs->treeid); for(j=0;j<fs->num_trees;j++) drawtree(fs->treepos[j].x ,fs->treepos[j].y ,fs->treepos[j].z ); glDisable(GL_ALPHA_TEST); } #endif /* HAVE_GLBINDTEXTURE */ glDisable(GL_TEXTURE_2D); glDepthMask(GL_FALSE); if (fs->shadows) { /* draw shadows with black color */ glBegin(wire ? GL_LINE_STRIP : GL_TRIANGLES); for (j = 0; j < fs->np; j++) { glColor4f(black[0], black[1], black[2], fs->p[j].c[0][3]); glVertex3f(fs->p[j].p[0][0], 0.1, fs->p[j].p[0][2]); glColor4f(black[0], black[1], black[2], fs->p[j].c[1][3]); glVertex3f(fs->p[j].p[1][0], 0.1, fs->p[j].p[1][2]); glColor4f(black[0], black[1], black[2], fs->p[j].c[2][3]); glVertex3f(fs->p[j].p[2][0], 0.1, fs->p[j].p[2][2]); } glEnd(); } glBegin(wire ? GL_LINE_STRIP : GL_TRIANGLES); for (j = 0; j < fs->np; j++) { /* draw particles: colors are computed in setpart */ glColor4fv(fs->p[j].c[0]); glVertex3fv(fs->p[j].p[0]); glColor4fv(fs->p[j].c[1]); glVertex3fv(fs->p[j].p[1]); glColor4fv(fs->p[j].c[2]); glVertex3fv(fs->p[j].p[2]); setpart(fs, &fs->p[j]); } glEnd(); /* draw rain particles if no fire particles */ if (!fs->np) { float timeused = gettimerain(); glDisable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glBegin(GL_LINES); for (j = 0; j < NUMPART; j++) { glColor4f(0.7f,0.95f,1.0f,0.0f); glVertex3fv(fs->r[j].oldpos); glColor4f(0.3f,0.7f,1.0f,1.0f); glVertex3fv(fs->r[j].pos); setpartrain(fs, &fs->r[j],timeused); } glEnd(); glShadeModel(GL_FLAT); } glDisable(GL_TEXTURE_2D); glDisable(GL_ALPHA_TEST); glDisable(GL_DEPTH_TEST); glDisable(GL_FOG); /* manage framerate display */ if (MI_IS_FPS(mi)) do_fps (mi); glPopMatrix(); }
ENTRYPOINT void draw_providence(ModeInfo * mi) { providencestruct *mp; Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if(!providence) return; mp = &providence[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if(!mp->glx_context) return; glXMakeCurrent(display, window, *(mp->glx_context)); /* setup twoside lighting */ glLightfv(GL_LIGHT0, GL_AMBIENT, ambient2); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_POSITION, mp->position0); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_NORMALIZE); glFrontFace(GL_CCW); /* glDisable(GL_CULL_FACE); */ glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(current_device_rotation(), 0, 0, 1); /* modify camera */ if(fabs(mp->camera_velocity) > EPSILON) { mp->camera_z = max(min(mp->camera_z + 0.1*mp->camera_velocity, -4.0), -12.0); mp->camera_velocity = 0.95*mp->camera_velocity; } /* rotate providence */ glTranslatef(0.0, 0.0, mp->camera_z + sin(mp->theta/4.0)); glRotatef(10.0+20.0*sin(mp->theta/2.0), 1.0, 0.0, 0.0); gltrackball_rotate(mp->trackball); glRotatef(mp->theta * 180.0 / Pi, 0.0, -1.0, 0.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); } # endif /* draw providence */ draw_providence_strip(mi); glPopMatrix(); if(MI_IS_FPS(mi)) do_fps (mi); glFlush(); glXSwapBuffers(display, window); /* update */ mp->currenttime += 1.0 / FPS; mp->theta = mp->currenttime / 2.0 * mp->theta_scale; update_particles(mp); }