void display(void){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* 画面クリア */ glLoadIdentity(); /* スタックのクリア */ polarview(); /* ビューイング変換 */ glPushMatrix(); //支柱 glRotated(90, 1.0, 0.0, 0.0); glTranslated(0.0,-1.9,0.0); T_Cylinder(0.02, 2.0, 100, 1); glPopMatrix(); for(int i = 0; i < NUM; i++){ double L,CLR; glPushMatrix(); //振り子 glTranslated(0.0, 0.0, pendulum[i].draw(3)); glRotated(pendulum[i].draw(1), 0.0, 0.0, 1.0); L = pendulum[i].draw(2); glTranslated(0.0, -L, 0.0); T_Cylinder(0.005, L, 100, 1); CLR = pendulum[i].draw(4); if(CLR > 0) T_Sphere(0.0, -L, 0.0, 0.1, 0.1, 0.1, 2); else T_Sphere(0.0, -L, 0.0, 0.1, 0.1, 0.1, 1); glPopMatrix(); } glutSwapBuffers(); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // „Ƕ„Ç£„É≥„Éâ„Ƕ„ÅÆËÉåÊôØ„Çí°ó„Çä„ŧ„Å∂„Å? & Èö†Èù¢Âá¶ÁêÅEÇíÂèØËÉΩ„Å´„Åô„Çã glEnable(GL_DEPTH_TEST); // Èö†Èù¢Âá¶ÁêÅEñãÂß? glEnable(GL_NORMALIZE); glEnable(GL_LIGHTING); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glPushMatrix(); glTranslatef(0.0, 1.0, 0.0); polarview(); // „Éù„ÅE„É©„ɺ„Éì„É•„ɺ„Å∏„ÅÆ„Éì„É•„ɺ„ǧ„É≥„Ç∞§âÊèõ glPushMatrix(); glLightfv(GL_LIGHT0, GL_POSITION, light0); glPopMatrix(); shading(5); drawGround2D(); shading(6); glDisable(GL_LIGHTING); drawGrass(); glEnable(GL_LIGHTING); shading(5); drawPlant(); if (rainFlag == GL_TRUE) drawRain(); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); drawCloud(); if (thunderFlag == GL_TRUE && rainFlag == GL_TRUE) { if (lightningnum == 0 || lightningnum == 4) lightning(); lightningnum++; if (lightningnum == 5) { lightningnum = 0; thunderFlag = GL_FALSE; } if (rand() % 10 == 4) fallFlag = GL_TRUE; } else thunderFlag = GL_FALSE; glPopMatrix(); glutSwapBuffers(); }
void display( void ) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glEnable (GL_LIGHTING); glPushMatrix(); polarview(); float light0[] = { -5., 5., 5., 1. }; float light1[] = { 5., -5., -5., 0. }; glLightfv( GL_LIGHT1, GL_POSITION, light1 ); glLightfv( GL_LIGHT0, GL_POSITION, light0 ); // DISPLAY BUGDROID bug.display(); glPopMatrix(); glDisable(GL_DEPTH_TEST | GL_LIGHT0); glutSwapBuffers(); }
/* * Shows various combinations of viewing and * projection transformations. */ main() { char device[20]; fprintf(stderr,"Enter device name: "); gets(device); vinit(device); color(BLACK); clear(); /* * we want to draw just within the boundaries of the screen */ viewport(-0.9, 0.9, -0.9, 0.9); ortho2(-5.0, 5.0, -5.0, 5.0); /* set the world size */ color(RED); rect(-5.0, -5.0, 5.0, 5.0); /* draw a boundary frame */ /* * set up a perspective projection with a field of view of * 40.0 degrees, aspect ratio of 1.0, near clipping plane 0.1, * and the far clipping plane at 1000.0. */ perspective(40.0, 1.0, 0.1, 1000.0); /* * we want the drawing to be done with our eye point at (5.0, 8.0, 5.0) * looking towards (0.0, 0.0, 0.0). The last parameter gives a twist * in degrees around the line of sight, in this case zero. */ lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0.0); drawtetra(); move2(-4.5, -4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("perspective/lookat"); getkey(); /* * window can also be used to give a perspective projection. Its * arguments are 6 clipping planes, left, right, bottom, top, near, * and far. */ window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0); /* * as window replaces the current transformation matrix we must * specify our viewpoint again. */ lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0.0); color(BLACK); clear(); color(GREEN); rect(-5.0, -5.0, 5.0, 5.0); drawtetra(); move2(-4.5,-4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("window/lookat"); getkey(); /* * set up our original perspective projection again. */ perspective(40.0, 1.0, 0.1, 1000.0); /* * polarview also specifies our viewpoint, but, unlike lookat, in polar * coordinates. Its arguments are the distance from the world origin, an * azimuthal angle in the x-y plane measured from the y axis, an * incidence angle in the y-z plane measured from the z axis, and a * twist around the line of sight. */ polarview(15.0, 30.0, 30.0, 30.0); color(BLACK); clear(); color(MAGENTA); rect(-5.0, -5.0, 5.0, 5.0); drawtetra(); move2(-4.5,-4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("perspective/polarview"); getkey(); /* * once more with window for comparison */ window(-4.0, 4.0, -4.0, 4.0, -4.0, 4.0); polarview(6.0, 20.0, -30.0, 70.0); color(BLACK); clear(); color(YELLOW); rect(-5.0, -5.0, 5.0, 5.0); drawtetra(); move2(-4.5,-4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("window/polarview"); getkey(); vexit(); }