void displayFcn(void) { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(x0, yO, z0, 0, 0, 0, 0, 1, 0); glColor3f(color[0], color[1], color[2]); if (toggle) glRotatef(rotTheta += 3, 0.0, 1.0, 0.0); glScalef(scale, scale, scale); if (solid) { switch (poly) { case 1: glutSolidCube(1.0); break; case 2: glutSolidDodecahedron(); break; case 3: glutSolidTetrahedron(); break; case 4: glutSolidOctahedron(); break; case 5: glutSolidIcosahedron(); break; case 6: glutSolidIcosahedron(); break; } } else { switch (poly) { case 1: glutWireCube(1.0); break; case 2: glutWireDodecahedron(); break; case 3: glutWireTetrahedron(); break; case 4: glutWireOctahedron(); break; case 5: glutWireIcosahedron(); break; case 6: glutWireIcosahedron(); break; } } glPopMatrix(); glutSwapBuffers(); glFlush(); }
void displayWirePolyhedra (void) { glClear (GL_COLOR_BUFFER_BIT); glColor3f (0.0, 0.0, 1.0); gluLookAt (5.0, 5.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); //draw cube glScalef (1.5, 2.0, 1.0); glutWireCube (1.0); //draw d12 glScalef (0.8, 0.5, 0.8); glTranslatef (-6.0, -5.0, 0.0); glutWireDodecahedron (); //draw d4 glTranslatef (8.6, 8.6, 2.0); glutWireTetrahedron (); //draw d8 glTranslatef (-3.0, -1.0, 0.0); glutWireOctahedron (); //draw d20 glScalef (0.8, 0.8, 1.0); glTranslatef (4.3, -2.0, 0.5); glutWireIcosahedron (); glFlush (); }
/* display() draws an icosahedron. */ void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); glutWireIcosahedron(); glFlush(); }
// 3Dオブジェクトを描画(引数によって変化) void mySelectWire(int i){ switch(i){ case 0: glutWireSphere( 30.0, 10, 10); break; case 1: glutWireCube( 40.0 ); break; case 2: glScalef( 1.5, 1.5, 1.5 ); glutWireTorus( 10.0, 20.0, 20, 6); break; case 3: glScalef( 40.0, 40.0, 40.0 ); glutWireTetrahedron(); break; case 4: glTranslatef( 0.0, 0.0, 10.0 ); glRotatef( 90.0, 1.0, 0.0, 0.0 ); glutWireTeapot( 40.0 ); break; default: glutWireIcosahedron(); printf("EROOR: Wire_count\n"); break; } }
void display(void) { glClear (GL_COLOR_BUFFER_BIT); glLoadIdentity (); gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glTranslatef(tx*5.0, ty*5.0, 0.0); glRotatef(r, 1, 0, 0); glRotatef(r, 0, 1, 0); glRotatef(r, 0, 0, 1); switch (object) { case 0: glColor3f (0.0, 1.0, 0.0); glutWireCube(2.0); break; case 1: glColor3f (0.0, 1.0, 1.0); glutWireDodecahedron(); break; case 2: glColor3f (1.0, 0.0, 0.0); glutWireIcosahedron(); break; case 3: glColor3f (1.0, 1.0, 0.0); glutWireTeapot(1.5); break; } glutSwapBuffers(); }
void drawHead() { glColor3f (1.0, 1.0, 0.0); glScalef (HeadR, HeadR, HeadR); glutSolidIcosahedron(); glColor3f (0.0, 0.0, 0.0); glScalef (1.01, 1.01, 1.01); glutWireIcosahedron(); }
//------------------------------------------------------------------------- // Draws our object. //------------------------------------------------------------------------- void drawObject () { // Show when are displaying an object printf ("Displaying object...\n"); // Draw Icosahedron glutWireIcosahedron (); }
//------------------------------------------------------------------------------ void npGlutPrimitive (int primitive) { switch (primitive) { case kNPgeoCubeWire : glScalef (0.6f, 0.6f, 0.6f); glutWireCube(2.0f); glScalef (1.666667f, 1.666667f, 1.666667f); break; case kNPgeoCube : glScalef (0.6f, 0.6f, 0.6f); glutSolidCube(2.0f); glScalef (1.666667f, 1.666667f, 1.666667f); break; case kNPgeoSphereWire : glutWireSphere( 1.0f, 24, 12); break;//15, 15 ); break; case kNPgeoSphere : glutSolidSphere( 1.0f, 24, 12 ); break; case kNPgeoConeWire : glutWireCone( 1.0f, 2.0f, 24, 1 ); break; case kNPgeoCone : glutSolidCone( 1.0f, 2.0f, 24, 1 ); break; case kNPgeoTorusWire : glutWireTorus(kNPtorusRadius * 0.1f, kNPtorusRadius, 7, 16); break; case kNPgeoTorus : glutSolidTorus(kNPtorusRadius * 0.1f, kNPtorusRadius, 7, 16); break; case kNPgeoDodecahedronWire : glScalef (0.6f, 0.6f, 0.6f); glutWireDodecahedron(); glScalef (1.666667f, 1.666667f, 1.666667f); break; case kNPgeoDodecahedron : glScalef (0.6f, 0.6f, 0.6f); glutSolidDodecahedron(); glScalef (1.666667f, 1.666667f, 1.666667f); break; case kNPgeoOctahedronWire : glutWireOctahedron(); break; case kNPgeoOctahedron : glutSolidOctahedron(); break; case kNPgeoTetrahedronWire : glutWireTetrahedron(); break; case kNPgeoTetrahedron : glutSolidTetrahedron(); break; case kNPgeoIcosahedronWire : glutWireIcosahedron(); break; case kNPgeoIcosahedron : glutSolidIcosahedron(); break; // case kNPglutWireTeapot : glutWireTeapot( 2.0f ); break; // case kNPglutSolidTeapot : glutSolidTeapot( 2.0f ); break; default : glutWireTetrahedron(); break; } }
/* display() draws an icosahedron. */ void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (!twopass) { glEnable(GL_FOG); } else { glDisable(GL_FOG); } glColor3f (1.0, 1.0, 1.0); glutWireIcosahedron(); if (twopass) { afDoFinalFogPass(0, 0, width, height); } glutSwapBuffers(); }
void menu (int valor) { switch (valor) { case 1: { glutWireTorus(0.5, 1.0, 20, 20); break; } case 2: { glutWireTeapot(1); break; } case 3: { glutWireIcosahedron(); break; } case 4: { glutWireCone(1.0, 1.0, 10, 10); break; } case 5: { glutWireOctahedron(); break; } case 6: { glutWireTetrahedron(); break; } case 7: exit(0); } }
static void hugsprim_glutWireIcosahedron_4(HugsStackPtr hugs_root) { glutWireIcosahedron(); hugs->returnIO(hugs_root,0); }
static void drawWireIcosahedron(void) { glutWireIcosahedron (); }
/** WireIcosahedron () -> None */ static int glut_wire_icosahedron(lua_State *L) { glutWireIcosahedron(); }
void displayFunc(void) { static int shape = 1; fprintf(stderr, " %d", shape); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); switch (shape) { case 1: glutWireSphere(1.0, 20, 20); break; case 2: glutSolidSphere(1.0, 20, 20); break; case 3: glutWireCone(1.0, 1.0, 20, 20); break; case 4: glutSolidCone(1.0, 1.0, 20, 20); break; case 5: glutWireCube(1.0); break; case 6: glutSolidCube(1.0); break; case 7: glutWireTorus(0.5, 1.0, 15, 15); break; case 8: glutSolidTorus(0.5, 1.0, 15, 15); break; case 9: glutWireDodecahedron(); break; case 10: glutSolidDodecahedron(); break; case 11: glutWireTeapot(1.0); break; case 12: glutSolidTeapot(1.0); break; case 13: glutWireOctahedron(); break; case 14: glutSolidOctahedron(); break; case 15: glutWireTetrahedron(); break; case 16: glutSolidTetrahedron(); break; case 17: glutWireIcosahedron(); break; case 18: glutSolidIcosahedron(); break; default: printf("\nPASS: test16\n"); exit(0); } glutSwapBuffers(); shape += 1; sleep(1); glutPostRedisplay(); }
void display_2(void) { char *p; glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear the screen glMatrixMode (GL_PROJECTION); // Tell opengl that we are doing project matrix work glLoadIdentity(); // Clear the matrix glOrtho(-8.0, 8.0, -8.0, 8.0, 0.0, 30.0); // Setup an Ortho view glMatrixMode(GL_MODELVIEW); // Tell opengl that we are doing model matrix work. (drawing) glLoadIdentity(); // Clear the model matrix glColor3f(1.0, 1.0, 1.0); if (shape == 0) Sprint(-3, -7 ,"Wire Cube"); if (shape == 1) Sprint(-3, -7 ,"Wire Cone"); if (shape == 2) Sprint(-3, -7 ,"Wire Sphere"); if (shape == 3) Sprint(-3, -7 ,"Wire Torus"); if (shape == 4) Sprint(-3, -7 ,"Wire Dodecahedron"); if (shape == 5) Sprint(-3, -7 ,"Wire Octahedron"); if (shape == 6) Sprint(-3, -7 ,"Wire Tetrahedron"); if (shape == 7) Sprint(-3, -7 ,"Wire Icosahedron"); if (shape == 8) Sprint(-3, -7 ,"Wire Teapot"); // Setup view, and print view state on screen if (view_state == 1) { glColor3f( 1.0, 1.0, 1.0); Sprint(-2, 4, "Perspective view"); glMatrixMode (GL_PROJECTION); glLoadIdentity(); gluPerspective(60, 1, 1, 30); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }else { glColor3f( 1.0, 1.0, 1.0); Sprint(-2, 4, "Ortho view"); } glColor3f( 0.0, 0.0, 1.0); // Cube color // Lighting on/off if (light_state == 1) { glDisable(GL_LIGHTING); // Turn off lighting glDisable(GL_COLOR_MATERIAL); // Turn off material, which needs lighting to work }else { glEnable(GL_LIGHTING); // Turn on lighting glEnable(GL_COLOR_MATERIAL); // Turn on material settings glColorMaterial(GL_FRONT, GL_AMBIENT); glColor4f(0.65, 0.65, 0.65, 0.4); glColorMaterial(GL_FRONT, GL_EMISSION); glColor4f(0.10, 0.10, 0.10, 0.0); glColorMaterial(GL_FRONT, GL_SPECULAR); glColor4f(0.5, 0.5, 0.5, 0.4); glColorMaterial(GL_FRONT, GL_DIFFUSE); glColor4f(0.85, 0.85, 0.85, 0.4); } gluLookAt( 0, 0, 20, 0, 0, 0, 0, 1, 0); //glRotatef( 45, 1.0, 1.0, 0.0); // rotate cube glRotatef( spin++, 1.0, 1.0, 1.0); // spin cube if (shape == 0) glutWireCube(10); // Draw a cube if (shape == 1) glutWireCone(5,10, 16,16); // Draw a Cone if (shape == 2) glutWireSphere(5, 16,16 ); // Draw a Sphere if (shape == 3) glutWireTorus( 2.5, 5, 16, 16); if (shape == 4) { glScalef( 3.5, 3.5, 3.5); glutSolidDodecahedron(); } if (shape == 5) { glScalef( 5.0, 5.0, 5.0); glutWireOctahedron(); } if (shape == 6) { glScalef( 5.0, 5.0, 5.0); glutWireTetrahedron(); } if (shape == 7) { glScalef( 5.0, 5.0, 5.0); glutWireIcosahedron(); } if (shape == 8) glutWireTeapot( 5 ); glutSwapBuffers(); }
//------------------------------------------------------------------------- // Draws our object. //------------------------------------------------------------------------- void drawObject () { // Draw the object only if the Draw check box is selected if (draw) { // Push the current matrix into the model view stack glPushMatrix (); // Apply the translation glTranslatef (translate_xy[0], translate_xy[1], -translate_z); // Apply the rotation matrix glMultMatrixf (rotation_matrix); // Apply the scaling glScalef (scale, scale, scale); // Get the id of the selected object int selected_object = (radiogroup_item_id * 2) + 1 - wireframe; switch (selected_object) { // draw glut wire cube case GLUT_WIRE_CUBE: glutWireCube (0.5); break; // draw glut solid cube case GLUT_SOLID_CUBE: glutSolidCube (0.5); break; // draw glut wire sphere case GLUT_WIRE_SPHERE: glutWireSphere (0.5, 50, 50); break; // draw glut solid sphere case GLUT_SOLID_SPHERE: glutSolidSphere (0.5, 50, 50); break; // draw glut wire Cone case GLUT_WIRE_CONE: glutWireCone (0.5, 0.5, 50, 50); break; // draw glut solid cone case GLUT_SOLID_CONE: glutSolidCone (0.5, 0.5, 50, 50); break; // draw glut wire Torus case GLUT_WIRE_TORUS: glutWireTorus (0.15, 0.25, 20, 20); break; /// draw glut solid Torus case GLUT_SOLID_TORUS: glutSolidTorus (0.15, 0.25, 20, 20); break; // draw a wire dodecahedron.. The reason why I'm dividing // by 2 * radical (3) when I'm scaling it because I want to fit // the dodecahedron which is centered at the modeling // coordinates origin with a radius of radical (3). case GLUT_WIRE_DODECAHEDRON: glScalef (1 / sqrt (12), 1 / sqrt (12), 1 / sqrt (12)); glutWireDodecahedron (); break; // draw a solid dodecahedron case GLUT_SOLID_DODECAHEDRON: glScalef (1 / sqrt (12), 1 / sqrt (12), 1 / sqrt (12)); glutSolidDodecahedron (); break; // draw a wire octahedron.. The reason why I'm dividing // by 2 when I'm scaling is because I want to fit // the octahedron which is centered at the modeling // coordinates origin with a radius of 1. case GLUT_WIRE_OCTAHEDRON: glScalef (0.5, 0.5, 0.5); glutWireOctahedron (); break; // draw a solid tetrahedron case GLUT_SOLID_OCTAHEDRON: glScalef (0.5, 0.5, 0.5); glutSolidOctahedron (); break; // draw a wire tetrahedron.. case GLUT_WIRE_TETRAHEDRON: glScalef (1 / sqrt(6), 1 / sqrt(6), 1 / sqrt(6)); glutWireTetrahedron (); break; // draw a solid tetrahedron case GLUT_SOLID_TETRAHEDRON: glScalef (1 / sqrt(6), 1 / sqrt(6), 1 / sqrt(6)); glutSolidTetrahedron (); break; // draw a wire icosahedron.. The reason why I'm dividing // by 2 when I'm scaling is because I want to fit // the icosahedron which is centered at the modeling // coordinates origin with a radius of 1. case GLUT_WIRE_ICOSAHEDRON: glScalef (0.5, 0.5, 0.5); glutWireIcosahedron (); break; // draw a solid icosahedron case GLUT_SOLID_ICOSAHEDRON: glScalef (0.5, 0.5, 0.5); glutSolidIcosahedron (); break; // draw Wire Teapot case GLUT_WIRE_TEAPOT: glutWireTeapot (0.5); break; // draw a solid Teapot case GLUT_SOLID_TEAPOT: glutSolidTeapot (0.5); break; // Do Nothing default: break; } // Pop our matrix from the model view stack after we finish drawing glPopMatrix (); } }
// Called to draw scene void RenderScene(void) { // Clear the window glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Save matrix state and do the rotation glPushMatrix(); glRotatef(xRot, 1.0f, 0.0f, 0.0f); glRotatef(yRot, 0.0f, 1.0f, 0.0f); switch(iShape) { case 1: glutWireSphere(1.0f, 25, 25); break; case 2: glutWireCube(1.0f); break; case 3: glutWireCone(0.30f, 1.1f, 20, 20); break; case 4: glutWireTorus(0.3f, 1.0f, 10, 25); break; case 5: glutWireDodecahedron(); break; case 6: glutWireOctahedron(); break; case 7: glutWireTetrahedron(); break; case 8: glutWireIcosahedron(); break; case 9: glutWireTeapot(1.0f); break; case 11: glutSolidSphere(1.0f, 25, 25); break; case 12: glutSolidCube(1.0f); break; case 13: glutSolidCone(0.30, 1.1f, 20, 20); break; case 14: glutSolidTorus(0.3f, 1.0f, 10, 25); break; case 15: glutSolidDodecahedron(); break; case 16: glutSolidOctahedron(); break; case 17: glutSolidTetrahedron(); break; case 18: glutSolidIcosahedron(); break; default: glutSolidTeapot(1.0f); break; } // Restore transformations glPopMatrix(); // Flush drawing commands glutSwapBuffers(); }
//显示回调函数 void renderScreen(void){ //将窗口颜色清理为黑色 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //将模板缓冲区值全部清理为1 glClearStencil(1); //使能模板缓冲区 glEnable(GL_STENCIL_TEST); //把整个窗口清理为当前清理颜色:黑色。清除深度缓冲区、模板缓冲区 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); //将当前Matrix状态入栈 glPushMatrix(); //坐标系绕x轴旋转xRotAngle glRotatef(xRotAngle, 1.0f, 0.0f, 0.0f); //坐标系绕y轴旋转yRotAngle glRotatef(yRotAngle, 0.0f, 1.0f, 0.0f); //进行平滑处理 glEnable(GL_POINT_SMOOTH); glHint(GL_POINT_SMOOTH, GL_NICEST); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH, GL_NICEST); glEnable(GL_POLYGON_SMOOTH); glHint(GL_POLYGON_SMOOTH, GL_NICEST); //白色绘制坐标系 glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_LINES); glVertex3f(-9.0f, 0.0f, 0.0f); glVertex3f(9.0f, 0.0f, 0.0f); glVertex3f(0.0f, -9.0f, 0.0f); glVertex3f(0.0f, 9.0f, 0.0f); glVertex3f(0.0f, 0.0f, -9.0f); glVertex3f(0.0f, 0.0f, 9.0f); glEnd(); glPushMatrix(); glTranslatef(9.0f, 0.0f, 0.0f); glRotatef(90.0f, 0.0f, 1.0f, 0.0f); glutSolidCone(0.3, 0.6, 10, 10); glPopMatrix(); glPushMatrix(); glTranslatef(0.0f, 9.0f, 0.0f); glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); glutSolidCone(0.3, 0.6, 10, 10); glPopMatrix(); glPushMatrix(); glTranslatef(0.0f, 0.0f, 9.0f); glRotatef(90.0f, 0.0f, 0.0f, 1.0f); glutSolidCone(0.3, 0.6, 10, 10); glPopMatrix(); //设置绘画颜色为金色 glColor3f(0.0f, 1.0f, 0.0f); switch (iModel){ //球 case SPHERE: if (bWire){ glutWireSphere(8.0f, 20, 20); } else{ glutSolidSphere(8.0f, 20, 20); } break; //锥体 case CONE: if (bWire){ glutWireCone(4.0f, 8.0f, 20, 20); } else{ glutSolidCone(4.0f, 8.0f, 20, 20); } break; //立体 case CUBE: if (bWire){ glutWireCube(8.0f); } else{ glutSolidCube(8.0f); } break; //甜圈 case TORUS: if (bWire){ glutWireTorus(3.0f, 6.0f, 20, 20); } else{ glutSolidTorus(3.0f, 6.0f, 20, 20); } break; //十六面体,默认半径1.0 case DODECAHEDRON: glScalef(6.0f, 6.0f, 6.0f);//x,y,z轴均放大6倍 if (bWire){ glutWireDodecahedron(); } else{ glutSolidDodecahedron(); } break; //茶壶 case TEAPOT: if (bWire){ glutWireTeapot(8.0f); } else{ glutSolidTeapot(8.0f); } break; //八面体,默认半径1.0 case OCTAHEDRON: glScalef(6.0f, 6.0f, 6.0f);//x,y,z轴均放大6倍 if (bWire){ glutWireOctahedron(); } else{ glutSolidOctahedron(); } break; //四面体,默认半径1.0 case TETRAHEDRON: glScalef(6.0f, 6.0f, 6.0f);//x,y,z轴均放大6倍 if (bWire){ glutWireTetrahedron(); } else{ glutSolidTetrahedron(); } break; //二十面体,默认半径1.0 case ICOSAHEDRON: glScalef(6.0f, 6.0f, 6.0f);//x,y,z轴均放大6倍 if (bWire){ glutWireIcosahedron(); } else{ glutSolidIcosahedron(); } break; default: break; } //恢复压入栈的Matrix glPopMatrix(); //交换两个缓冲区的指针 glutSwapBuffers(); }
/* * Class: gruenewa_opengl_GLUT__ * Method: glutWireIcosahedron * Signature: ()V */ JNIEXPORT void JNICALL Java_gruenewa_opengl_GLUT_00024_glutWireIcosahedron (JNIEnv * jenv, jobject jobj) { glutWireIcosahedron(); }