亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? worms.c

?? jhjuc jggyiiyi gjgu gjjgtu hhgg
?? C
字號:
#if 0From jallen@cs.hmc.edu  Fri Feb 17 00:49:59 1995Received: from giraffe.asd.sgi.com by hoot.asd.sgi.com via SMTP (940816.SGI.8.6.9/940406.SGI.AUTO)	for <mjk@hoot.asd.sgi.com> id AAA13591; Fri, 17 Feb 1995 00:49:33 -0800Received: from sgi.sgi.com by giraffe.asd.sgi.com via SMTP (920330.SGI/920502.SGI)	for mjk@hoot.asd.sgi.com id AA09774; Fri, 17 Feb 95 00:52:30 -0800Received: from cs.hmc.edu by sgi.sgi.com via SMTP (950215.405.SGI.8.6.10/910110.SGI)	for <mjk@sgi.com> id AAA06439; Fri, 17 Feb 1995 00:52:28 -0800Received: by cs.hmc.edu (5.0/SMI-SVR4)	id AA13309; Fri, 17 Feb 1995 00:52:10 -0800Date: Fri, 17 Feb 1995 00:52:10 -0800From: jallen@cs.hmc.edu (Jeff R. Allen)Message-Id: <9502170852.AA13309@cs.hmc.edu>To: nate@cs.hmc.edu (Nathan Tuck), mjk@sgi.sgi.com, hadas@cs.hmc.eduSubject: Re: GLUT demosIn-Reply-To: <9502100805.AA08487@cs.hmc.edu>References: <9502100805.AA08487@cs.hmc.edu>Reply-To: Jeff Allen <jeff@hmc.edu>Content-Length: 12851Status: ROBelow is a program I wrote for the Graphics class at Harvey Mudd. Asthe comments explain, I am currently working on a version in 3D withlighting, and a pre-programmed camera flight-path. I also added achecker-board-type-thing for the worms to crawl around on, so thatthere is some reference for the viewer.For now, here is the program.-- Jeff R. Allen  |     Senior CS major    |    Support your local(fnord)        |    South 351d, x4940   |        unicyclist!-------------------------  begin worms.c   -------------------------#endif/* worms.c -- demos OpenGL in 2D using the GLUT interface to the              underlying window system.   Compile with: [g]cc -O3 -o worms worms.c -lm -lGLU -lglut -lXmu -lX11 -lGL   This is a fun little demo that actually makes very little use of   OpenGL and GLUT. It generates a bunch of worms and animates them as   they crawl around your screen. When you click in the screen with   the left mouse button, the worms converge on the spot for a while,   then go back to their business. The animation is incredibly simple:   we erase the tail, then draw a new head, repeatedly. It is so   simple, actually, we don't even need double-buffering!   The behavior of the worms can be controlled via the compile-time   constants below. Enterprising indiviuals wil want to add GLUT menus   to control these constants at run time. This is left as an exercise   to the reader. The only thing that can currently be controlled is   wether or not the worms are filled. Use the right button to get a popup   menu.   A future version of this program will make more use of OpenGL by   rendering 3d worms crawling in 3-space (or possibly just around on   a plane) and it will allow the user to manipulate the viewpoint   using the mouse. This will require double-buffering and less   optimal updates.   This program is Copyright 1995 by Jeff R. Allen <jeff@hmc.edu>.   Permission is hereby granted to use and modify this code freely,   provided it is not sold or redistibuted in any way for profit. This   is copyrighted material, and is NOT in the Public Domain.   $Id: //sw/apps/OpenGL/glut/progs/contrib/worms.c#6$ */#include <math.h>#include <stdlib.h>#include <sys/types.h>#include <time.h>#include <string.h>#include <GL/glut.h>#ifdef _WIN32#define drand48() (((float) rand())/((float) RAND_MAX))#define srand48(x) (srand((x)))#endif/* Some <math.h> files do not define M_PI... */#ifndef M_PI#define M_PI 3.14159265358979323846#endif/* operational constants */#define RADIAN .0174532#define CIRCLE_POINTS 25#define SIDETOLERANCE .01#define INITH 500#define INITW 500/* worm options */#define SEGMENTS 20#define SEG_RADIUS 0.01#define STEPSIZE 0.01#define MAXTURN (20 * RADIAN)        /* in radians */#define MAXWORMS 400#define INITWORMS 40#define MARKTICKS 100typedef struct worm_s {  float dir;                   /* direction in radians */  float segx[SEGMENTS];        /* location of segments. */  float segy[SEGMENTS];  GLfloat *color;              /* pointer to the RGB color of the worm */  int head;                    /* which elt of seg[xy] is currently head */                               /* the tail is always (head+1 % SEGMENTS) */} worm_t;/* colors available for worms... this is a huge mess because I   originally brought these colors in from rgb.txt as integers,   but they have to be normalized into floats. And C is stupid   and truncates them unless I add the annoying .0's */const GLfloat colors[][3] = {  { 255.0/255.0,   0.0/255.0,   0.0/255.0},  { 238.0/255.0,   0.0/255.0,   0.0/255.0},  { 205.0/255.0,   0.0/255.0,   0.0/255.0},  {   0.0/255.0, 255.0/255.0,   0.0/255.0},  {   0.0/255.0, 238.0/255.0,   0.0/255.0},  {   0.0/255.0, 205.0/255.0,   0.0/255.0},  {   0.0/255.0,   0.0/255.0, 255.0/255.0},  {   0.0/255.0,   0.0/255.0, 238.0/255.0},  {   0.0/255.0,   0.0/255.0, 205.0/255.0},  { 255.0/255.0, 255.0/255.0,   0.0/255.0},  { 238.0/255.0, 238.0/255.0,   0.0/255.0},  { 205.0/255.0, 205.0/255.0,   0.0/255.0},  {   0.0/255.0, 255.0/255.0, 255.0/255.0},  {   0.0/255.0, 238.0/255.0, 238.0/255.0},  {   0.0/255.0, 205.0/255.0, 205.0/255.0},  { 255.0/255.0,   0.0/255.0, 255.0/255.0},  { 238.0/255.0,   0.0/255.0, 238.0/255.0},  { 205.0/255.0,   0.0/255.0, 205.0/255.0},};#define COLORS 18/* define's for the menu item numbers */#define MENU_NULL          0#define MENU_FILLED        1#define MENU_UNFILLED      2#define MENU_QUIT          3/* flag to determine how to draw worms; set by popup menu -- starts out   filled in */int filled = 1;/* the global worm array */worm_t worms[MAXWORMS];int curworms = 0;/* global window extent variables */GLfloat gleft = -1.0, gright = 1.0, gtop = 1.0, gbottom = -1.0;GLint wsize, hsize;/* globals for marking */float markx, marky;int marktime;/* prototypes */void mydisplay(void);void drawCircle(float x0, float y0, float radius){  int i;  float angle;  /* a table of offsets for a circle (used in drawCircle) */  static float circlex[CIRCLE_POINTS];  static float circley[CIRCLE_POINTS];  static int   inited = 0;  if (! inited) {    for (i = 0; i < CIRCLE_POINTS; i++) {      angle = 2.0 * M_PI * i / CIRCLE_POINTS;      circlex[i] = cos(angle);      circley[i] = sin(angle);    }    inited++;  };  if (filled)    glBegin(GL_POLYGON);  else    glBegin(GL_LINE_LOOP);  for(i = 0; i < CIRCLE_POINTS; i++)    glVertex2f((radius * circlex[i]) + x0, (radius * circley[i]) + y0);  glEnd();  return;}void drawWorm(worm_t *theworm){  int i;  glColor3fv(theworm->color);  for (i = 0; i < SEGMENTS; i++)    drawCircle(theworm->segx[i], theworm->segy[i], SEG_RADIUS);  return;}void myinit(void){  int i, j, thecolor;  float thedir;  srand48(time(NULL));  curworms = INITWORMS;    for (j = 0; j < curworms; j++) {    /* divide the circle up into a number of pieces, and send one worm       each direction.     */    worms[j].dir = ((2.0 * M_PI) / curworms) * j;    thedir = worms[j].dir;    worms[j].segx[0] = 0.0;    worms[j].segy[0] = 0.0;    for (i = 1; i < SEGMENTS; i++) {      worms[j].segx[i] = worms[j].segx[i-1] + (STEPSIZE * cos(thedir));      worms[j].segy[i] = worms[j].segx[i-1] + (STEPSIZE * sin(thedir));    };    worms[j].head = (SEGMENTS - 1);    /* make this worm one of the predefined colors */    thecolor = (int) COLORS * drand48();    worms[j].color = (GLfloat *) colors[thecolor];  };  /* now that they are all set, draw them as though they have just been     uncovered   */  mydisplay();}/* this routine is called after the coordinates are changed to make sure   worms outside the window come back into view right away. (This behavior   is arbitrary, but they are my worms, and they'll do what I please!) */void warpWorms(void){  register int j, head;  for (j = 0; j < curworms; j++) {    head = worms[j].head;    if (worms[j].segx[head] < gleft)      worms[j].segx[head] = gleft;    if (worms[j].segx[head] > gright)      worms[j].segx[head] = gright;    if (worms[j].segx[head] > gtop)      worms[j].segx[head] = gtop;    if (worms[j].segx[head] < gbottom)      worms[j].segx[head] = gbottom;        }}/* a bunch of extra hoopla goes on here to change the Global coordinate   space at teh same rate that the window itself changes. This give the   worms more space to play in when the window gets bigger, and vice versa.   The alternative would be to end up with big worms when the window gets   big, and that looks silly. */void myreshape (GLsizei w, GLsizei h){  float ratiow = (float) w/INITW;  float ratioh = (float) h/INITH;  glViewport(0,0,w,h);  glMatrixMode(GL_PROJECTION);  glLoadIdentity();  gleft = -1 * ratiow;  gright = 1 * ratiow;  gbottom = -1 * ratioh;  gtop = 1 * ratioh;  gluOrtho2D(gleft, gright, gbottom, gtop);  warpWorms();  glMatrixMode(GL_MODELVIEW);  glLoadIdentity();  wsize = w; hsize = h;  return;}/* given a pointer to a worm, this routine will decide on the next   place to put a head and will advance the head pointer */void updateWorm(worm_t *theworm){  int newhead;  float prevx, prevy;  float newh = -1, newv = -1;  float num, denom;  /* make an easy to reference local copy of head, and update it in     the worm structure. The new head replaces the old tail.   */  newhead = (theworm->head + 1) % SEGMENTS;  prevx = theworm->segx[theworm->head];  prevy = theworm->segy[theworm->head];  /* if there is a mark, home in on it. After this, we still allow     the random adjustment so that the worms play around a bit on the     way to the mark.   */  if (marktime) {    num = marky - prevy;    denom = markx - prevx;    theworm->dir = atan2(num,denom);  };  /* make a bit of a turn: between -MAXTURN and MAXTURN degrees change     to dir (actualy theworm->dir is in radians for later use with     cosf().   */  theworm->dir += (MAXTURN - (2 * MAXTURN * (float) drand48()));  theworm->segx[newhead] = prevx + (STEPSIZE * cos(theworm->dir));  theworm->segy[newhead] = prevy + (STEPSIZE * sin(theworm->dir));  /* if we are at an edge, change direction so that we are heading away     from the edge in question. There might be a problem here handling     corner cases, but I have never seen a worm get stuck, so what the     heck...   */  if (theworm->segx[newhead] <= gleft)    theworm->dir = 0;  if (theworm->segx[newhead] >= gright)    theworm->dir = (180 * RADIAN);  if (theworm->segy[newhead] >= gtop)    theworm->dir = (270 * RADIAN);  if (theworm->segy[newhead] <= gbottom)    theworm->dir = (90 * RADIAN);  if ((newv >= 0) || (newh >= 0)) {    newh = (newh<0) ? 0 : newh;    newv = (newv<0) ? 0 : newv;  };  /* update the permanent copy of the new head index */  theworm->head = newhead;}  /* updates the worms -- drawing takes place here, which may actually   be a bad idea. It will probably be better to update the internal   state only here, then post a redisplay using GLUT.*/void myidle (void){  register int i, tail;  if (marktime)    marktime--;  for (i = 0; i < curworms; i++) {    /* first find tail */    tail = (worms[i].head + 1) % SEGMENTS;      /* erase tail */    glColor3f(0.0, 0.0, 0.0);    drawCircle(worms[i].segx[tail], worms[i].segy[tail], SEG_RADIUS);    /* update head segment position and head pointer */    updateWorm(&worms[i]);    /* draw head */    glColor3fv(worms[i].color);    drawCircle(worms[i].segx[worms[i].head], worms[i].segy[worms[i].head],	       SEG_RADIUS);  };  glFlush();  return;}/* redraws the worms from scratch -- called after a window gets obscured */void mydisplay(void){  int i;#ifndef WORMS_EAT_BACKGROUND  glClearColor(0.0, 0.0, 0.0, 0.0);  glClear(GL_COLOR_BUFFER_BIT);#endif  for (i = 0; i < curworms; i++)    drawWorm(&worms[i]);  glFlush();  return;}/* this routine gets called when the mouse is clicked. The incoming   coordinates are in screen coordinates relative to the upper-left corner   of the window, and oriented according to X, not to GL. So, here we   convert the given coordinates into worm-world coordinates, and set the   mark. */void markSpot(int x, int y){  /* map into the corridinate space I am using */  markx = (float)((x - wsize/2)*(gright - gleft)/wsize);  marky = -(float)((y - hsize/2)*(gtop - gbottom)/hsize);  marktime = MARKTICKS;}void handleMouse(int btn, int state, int x, int y){  switch (btn) {  case (GLUT_LEFT_BUTTON):    if (state == GLUT_UP)      markSpot(x,y);    break;  default:    /* do nothing */    break;  }  return;}void menuSelect(int value){  switch (value) {    case MENU_FILLED:      filled = 1;      break;    case MENU_UNFILLED:      filled = 0;      break;    case MENU_QUIT:      exit(0);      break;    case MENU_NULL:      return;    default:      break;    };  glutPostRedisplay();  return;}void visibility(int status){  if (status == GLUT_VISIBLE)    glutIdleFunc(myidle);  else    glutIdleFunc(NULL);}/* this is where GLUT is initialized, and the whole thing starts up.   All animation and redisplay happens via the callbacks registered below. */int main(int argc, char **argv){  int fillmenu = 0;  glutInit(&argc, argv);  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);  glutInitWindowSize(INITW, INITH);  glutCreateWindow("Worms");  myinit();  glutDisplayFunc(mydisplay);  glutVisibilityFunc(visibility);  glutReshapeFunc(myreshape);  glutMouseFunc(handleMouse);  /* popup menu, courtsey of GLUT */  fillmenu = glutCreateMenu(menuSelect);  glutAddMenuEntry("Filled", MENU_FILLED);  glutAddMenuEntry("Unfilled", MENU_UNFILLED);  glutCreateMenu(menuSelect);  glutAddMenuEntry("     WORMS", MENU_NULL);  glutAddSubMenu("Drawing Mode", fillmenu);  glutAddMenuEntry("Quit", MENU_QUIT);  glutAttachMenu(GLUT_RIGHT_BUTTON);  glutMainLoop();  return 0;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩黄色免费电影| 欧美日韩免费观看一区二区三区| aa级大片欧美| 日韩一区二区在线看| 综合欧美一区二区三区| 青青草原综合久久大伊人精品优势| 国产成人高清视频| 日韩视频免费观看高清完整版 | 伊人婷婷欧美激情| 久久99日本精品| 欧美日本精品一区二区三区| 国产精品卡一卡二| 国产原创一区二区三区| 欧美精品一卡二卡| 亚洲美女淫视频| 成人深夜在线观看| 久久久久久久综合狠狠综合| 五月天久久比比资源色| 色婷婷亚洲综合| 亚洲视频在线一区观看| 成人性生交大片免费看中文| 欧美精品一区二区久久婷婷| 免费人成在线不卡| 3atv一区二区三区| 午夜久久久久久久久久一区二区| 色狠狠色狠狠综合| 亚洲精品欧美二区三区中文字幕| 99久久er热在这里只有精品66| 欧美韩国日本一区| 国产一区二区不卡在线| 精品国产sm最大网站| 韩国v欧美v亚洲v日本v| 2020国产精品自拍| 国产精品888| 国产日韩精品一区二区三区| 国产成人在线观看免费网站| 国产色婷婷亚洲99精品小说| 国产一区二区女| 国产欧美一区二区精品性色超碰| 国产美女一区二区| 中文字幕免费不卡在线| av激情综合网| 亚洲综合在线五月| 欧美日韩国产首页| 蜜臀av性久久久久蜜臀aⅴ四虎| 日韩欧美一二三四区| 国产一二精品视频| 国产精品另类一区| 欧美在线啊v一区| 亚洲v日本v欧美v久久精品| 91精品在线观看入口| 国产麻豆视频精品| 亚洲欧美综合另类在线卡通| 色婷婷综合久久久中文字幕| 视频一区在线播放| 国产欧美一区视频| 一本高清dvd不卡在线观看| 亚洲不卡一区二区三区| 日韩精品一区二区三区在线| 波多野结衣在线一区| 亚洲一区二区黄色| 精品国内片67194| 99r精品视频| 天堂va蜜桃一区二区三区漫画版| 精品日韩欧美一区二区| 色综合天天性综合| 久久精品国产亚洲a| 亚洲日本免费电影| 欧美一卡二卡三卡| 99re成人在线| 久久av老司机精品网站导航| 亚洲人快播电影网| 精品久久久久av影院| 色婷婷综合久色| 精品一区二区三区免费观看| 亚洲精品欧美在线| 国产亚洲短视频| 91精品国产综合久久精品性色| 成人激情动漫在线观看| 天天综合天天综合色| 国产精品国产自产拍高清av| 91精品国产一区二区三区蜜臀 | 国产精品久久久久久久久免费相片| 91极品美女在线| 风间由美性色一区二区三区| 三级在线观看一区二区| 自拍偷拍国产亚洲| 久久网站热最新地址| 欧美三级日本三级少妇99| 成人免费不卡视频| 国产一区二区三区高清播放| 日日欢夜夜爽一区| 亚洲一二三级电影| 中文字幕一区二区三| 久久亚洲影视婷婷| 欧美一级爆毛片| 91精品国产欧美一区二区成人| 色婷婷综合视频在线观看| 国产91综合一区在线观看| 精品综合免费视频观看| 日韩av高清在线观看| 亚洲国产精品一区二区久久| 亚洲欧美日韩一区| 国产精品久久久99| 国产精品毛片a∨一区二区三区| 精品三级在线看| 精品国免费一区二区三区| 91精品一区二区三区久久久久久| 欧美三级电影在线观看| 色屁屁一区二区| 一本色道亚洲精品aⅴ| 99免费精品视频| 成人av免费在线观看| 粉嫩av一区二区三区在线播放 | 一本色道久久综合亚洲aⅴ蜜桃| 国产iv一区二区三区| 国产成人av自拍| 国产成人福利片| 成人ar影院免费观看视频| 成人av网站大全| 日本福利一区二区| 欧美日韩精品欧美日韩精品| 欧美群妇大交群中文字幕| 这里是久久伊人| 欧美不卡123| 国产欧美日本一区二区三区| 中文欧美字幕免费| 亚洲美女电影在线| 午夜伦欧美伦电影理论片| 久久精品国产精品亚洲精品| 精品一区二区三区免费观看| 国产精品亚洲专一区二区三区 | 国产精品综合网| 成人污视频在线观看| av在线这里只有精品| 欧美性大战xxxxx久久久| 日韩一区二区三免费高清| 337p粉嫩大胆色噜噜噜噜亚洲 | 成人一级黄色片| 91丨九色丨尤物| 在线不卡一区二区| 欧美精品一区二区高清在线观看| 国产免费久久精品| 亚洲综合免费观看高清完整版在线 | 日韩美女在线视频| 国产人成一区二区三区影院| 一区二区三区鲁丝不卡| 轻轻草成人在线| 99久久99久久精品免费看蜜桃| 欧美视频三区在线播放| 精品国产一区久久| 一级精品视频在线观看宜春院 | 精品免费国产一区二区三区四区| 久久久国产精华| 亚洲电影欧美电影有声小说| 国产乱对白刺激视频不卡| 91久久香蕉国产日韩欧美9色| 日韩亚洲欧美一区| 亚洲免费av观看| 国产精品一区二区久激情瑜伽 | 久久综合久久综合久久| 亚洲人成伊人成综合网小说| 精品一区二区三区在线观看| 色婷婷av一区二区三区gif | 日韩视频免费观看高清完整版| 欧美国产禁国产网站cc| 日韩中文字幕麻豆| 91性感美女视频| 久久久久久久久久久电影| 日韩国产一区二| 91一区二区在线观看| 久久综合给合久久狠狠狠97色69| 亚洲无线码一区二区三区| eeuss鲁片一区二区三区| 精品入口麻豆88视频| 日韩和的一区二区| 一本大道久久a久久综合婷婷| 久久久国产精品麻豆| 麻豆国产精品视频| 在线不卡中文字幕播放| 亚洲一区在线观看免费 | 亚洲日本青草视频在线怡红院| 国产精品资源网| 精品欧美黑人一区二区三区| 天天综合网天天综合色| 欧美三区免费完整视频在线观看| 国产精品超碰97尤物18| 国产成人一级电影| 久久精品欧美日韩精品| 精久久久久久久久久久| 日韩欧美激情四射| 蜜桃视频在线观看一区二区| 欧美日韩一区二区在线观看视频 | 中文字幕亚洲不卡| 不卡av电影在线播放| 亚洲欧洲日韩一区二区三区| 国产一区亚洲一区| 国产情人综合久久777777| 国产成人超碰人人澡人人澡| 日本一区二区动态图|