/* world.c texture globe needs */ #include #include #include #include #include #include #define ANIMATE 10 #define ZOOMIN 20 #define ZOOMOUT 21 #define SLOWER 30 #define FASTER 31 #define QUIT 100 static double pi = 3.14159265358979323846; static GLuint Globe; static GLboolean Animate = GL_TRUE; static GLfloat Xrot = -66.55; static GLfloat Yrot = -23.45; static GLfloat Zrot = 0.0; static GLfloat DZrot = 0.1; /* JSS added GLfloat, 1.0 -> 0.1 */ static GLfloat zoom = 1.0; static int winWidth = 1000; static int winHeight = 600; static int nth = 18; static int nphi = 18; static int icselect = 0; static int istart = 0; static int iselect = 0; static int ncountry = 194; static int nvselect = 33; struct loc {char * cou; char * cap; char * lat;}; static struct loc locs[200] = { {"Afghanistan","Kabul","34n31 62e12"}, {"Albania","Tirane","41n20 19e50"}, {"Algeria","Algiers","36n47 03e03"}, {"Andorra","Andorra la Vella","42n30 01e31"}, {"Angola","Luanda","08s48 13e14"}, {"Antigua and Barbuda","Saint John's",""}, {"Argentina","Buenos Aires","34s36 58w27"}, {"Armenia","Yerevan","40n11 44e30"}, {"Australia","Canberra","35s17 149e08"}, {"Austria","Vienna","48n13 16e20"}, {"Azerbaijan","Baku","40n23 49e51"}, {"The Bahamas","Nassau","25n05 77w21"}, {"Bahrain","Manama","26n13 50e35"}, {"Bangladesh","Dhaka","23n43 90e25"}, {"Barbados","Bridgetown","13n06 59w37"}, {"Belarus","Minsk","53n54 27e34"}, {"Belgium","Brussels","50n50 04e20"}, {"Belize","Belmopan","17n15 88w46"}, {"Benin","Porto-Novo","06n29 02e37"}, {"Bhutan","Thimphu","27n28 89e39"}, {"Bolivia","La Paz","16s30 68w09"}, {"Bosnia and Herzegovina","Sarajevo","43n52 18e25"}, {"Botswana","Gaborone","24s45 25e55"}, {"Brazil","Brasilia","15s46 47w55"}, {"Brunei","Bandar Seri Begawan","04n56 114e55"}, {"Bulgaria","Sofia","42n41 23e19"}, {"Burkina Faso","Ouagadougou","12n22 01w31"}, {"Burundi","Bujumbura","03s23 29e22"}, {"Cambodia","Phnom Penh","11n33 104e55"}, {"Cameroon","Yaounde","03n52 11e31"}, {"Canada","Ottawa","45n25 75w42"}, {"Cape Verde","Praia",""}, {"Central African Republic","Bangui",""}, {"Chad","N'Djamena",""}, {"Chile","Santiago",""}, {"China","Beijing",""}, {"Colombia","Bogota",""}, {"Comoros","Moroni",""}, {"Congo, Republic of the","Brazzaville",""}, {"Congo, Democratic Republic of the","Kinshasa",""}, {"Costa Rica","San Jose",""}, {"Cote d'Ivoire","Yamoussoukro",""}, {"Croatia","Zagreb",""}, {"Cuba","Havana",""}, {"Cyprus","Nicosia",""}, {"Czech Republic","Prague",""}, {"Denmark","Copenhagen",""}, {"Djibouti","Djibouti",""}, {"Dominica","Roseau",""}, {"Dominican Republic","Santo Domingo",""}, {"East Timor","Dili",""}, {"Ecuador","Quito",""}, {"Egypt","Cairo",""}, {"El Salvador","San Salvador",""}, {"Equatorial Guinea","Malabo",""}, {"Eritrea","Asmara",""}, {"Estonia","Tallinn",""}, {"Ethiopia","Addis Ababa",""}, {"Fiji","Suva",""}, {"Finland","Helsinki",""}, {"France","Paris",""}, {"Gabon","Libreville",""}, {"The Gambia","Banjul",""}, {"Georgia","Tbilisi",""}, {"Germany","Berlin",""}, {"Ghana","Accra",""}, {"Greece","Athens",""}, {"Grenada","Saint George's",""}, {"Guatemala","Guatemala City",""}, {"Guinea","Conakry",""}, {"Guinea-Bissau","Bissau",""}, {"Guyana","Georgetown",""}, {"Haiti","Port-au-Prince",""}, {"Honduras","Tegucigalpa",""}, {"Hungary","Budapest",""}, {"Iceland","Reykjavik",""}, {"India","New Delhi",""}, {"Indonesia","Jakarta",""}, {"Iran","Tehran",""}, {"Iraq","Baghdad",""}, {"Ireland","Dublin",""}, {"Israel","Jerusalem",""}, {"Italy","Rome",""}, {"Jamaica","Kingston",""}, {"Japan","Tokyo",""}, {"Jordan","Amman",""}, {"Kazakhstan","Astana",""}, {"Kenya","Nairobi",""}, {"Kiribati","Tarawa",""}, {"Korea, North","Pyongyang",""}, {"Korea, South","Seoul",""}, {"Kuwait","Kuwait City",""}, {"Kyrgyzstan","Bishtek",""}, {"Laos","Vientiane",""}, {"Latvia","Riga",""}, {"Lebanon","Beirut",""}, {"Lesotho","Maseru",""}, {"Liberia","Monrovia",""}, {"Libya","Tripoli",""}, {"Liechtenstein","Vaduz",""}, {"Lithuania","Vilnius",""}, {"Luxembourg","Luxembourg",""}, {"Macedonia","Skopje",""}, {"Madagascar","Antananarivo",""}, {"Malawi","Lilongwe",""}, {"Malaysia","Kuala Lumpur",""}, {"Maldives","Male",""}, {"Mali","Bamako",""}, {"Malta","Valletta",""}, {"Marshall Islands","Majuro",""}, {"Mauritania","Nouakchott",""}, {"Mauritius","Port Louis",""}, {"Mexico","Mexico City",""}, {"Federated States of Micronesia","Palikir",""}, {"Moldova","Chisinau",""}, {"Monaco","Monaco",""}, {"Mongolia","Ulaanbaatar",""}, {"Morocco","Rabat",""}, {"Mozambique","Maputo",""}, {"Myanmar (Burma)","Rangoon",""}, {"Namibia","Windhoek",""}, {"Nauru","Yaren District",""}, {"Nepal","Kathmandu",""}, {"Netherlands","Amsterdam",""}, {"New Zealand","Wellington",""}, {"Nicaragua","Managua",""}, {"Niger","Niamey",""}, {"Nigeria","Abuja",""}, {"Norway","Oslo",""}, {"Oman","Muscat",""}, {"Pakistan","Islamabad",""}, {"Palau","Koror",""}, {"Panama","Panama City",""}, {"Papua New Guinea","Port Moresby",""}, {"Paraguay","Asuncion",""}, {"Peru","Lima",""}, {"Philippines","Manila",""}, {"Poland","Warsaw",""}, {"Portugal","Lisbon",""}, {"Qatar","Doha",""}, {"Romania","Bucharest",""}, {"Russia","Moscow",""}, {"Rwanda","Kigali",""}, {"Saint Kitts and Nevis","Basseterre",""}, {"Saint Lucia","Castries",""}, {"Saint Vincent and the Grenadines","Kingstown",""}, {"Samoa","Apia",""}, {"San Marino","San Marino",""}, {"Sao Tome and Principe","Sao Tome",""}, {"Saudi Arabia","Riyadh",""}, {"Senegal","Dakar",""}, {"Serbia and Montenegro (Yugoslavia)","Belgrade",""}, {"Seychelles","Victoria",""}, {"Sierra Leone","Freetown",""}, {"Singapore","Singapore",""}, {"Slovakia","Bratislava",""}, {"Slovenia","Ljubljana",""}, {"Solomon Islands","Honiara",""}, {"Somalia","Mogadishu",""}, {"South Africa","Pretoria",""}, {"Spain","Madrid",""}, {"Sri Lanka","Colombo",""}, {"Sudan","Khartoum",""}, {"Suriname","Paramaribo",""}, {"Swaziland","Mbabana",""}, {"Sweden","Stockholm",""}, {"Switzerland","Bern",""}, {"Syria","Damascus",""}, {"Taiwan","Taipei",""}, {"Tajikistan","Dushanbe",""}, {"Tanzania","Dar es Salaam",""}, {"Thailand","Bangkok",""}, {"Togo","Lome",""}, {"Tonga","Nuku'alofa",""}, {"Trinidad and Tobago","Port of Spain",""}, {"Tunisia","Tunis",""}, {"Turkey","Ankara",""}, {"Turkmenistan","Ashgabat",""}, {"Tuvalu","Funafuti",""}, {"Uganda","Kampala",""}, {"Ukraine","Kiev",""}, {"United Arab Emirates","Abu Dhabi",""}, {"United Kingdom","London","51n30 00w10"}, {"United States","Washington D.C.","38n54 77w02"}, {"Uruguay","Montevideo","34s53 56w11"}, {"Uzbekistan","Tashkent","41n20 69e18"}, {"Vanuatu","Port Vila","17s44 168e19"}, {"Vatican City","Vatican City","41n54 12e27"}, {"Venezuela","Caracas","10n30 66w56"}, {"Vietnam","Hanoi","21n02 105e51"}, {"Western Sahara","none","25n00 15e00"}, {"Yemen","Sanaw","17n50 51e00"}, {"Zambia","Lusaka","15s25 28e17"}, {"Zimbabwe","Harare","17s50 31e03"} }; static void drawText(GLfloat x, GLfloat y, char * msg) /* non movable */ { int i, len; glPushMatrix(); glLoadIdentity(); glRasterPos2f(x, y); len = strlen(msg); for (i=0; i 360.0) { Zrot -= 360.0; } glutPostRedisplay(); } } /* end idle */ static void draw() { int i, j, ntha; double r, th, dth, phi, dphi; double sphi, cphi, sth, cth; GLfloat xs, ys, zs; nphi = nth; ntha = nth; glEnable(GL_LINE_SMOOTH); dphi = pi/(double)nphi; r = 1.0; glColor3f(1.0, 1.0, 1.0); glutSolidSphere(r-0.05, 36, 36); glColor3f(0.5, 0.5, 0.5); if(ntha<36)ntha = 36; dth = 2.0*pi/(double)ntha; phi = -pi/2.0; for(i=1; i icselect) istart = icselect; if(icselect >= istart+nvselect) istart = icselect-nvselect+1; if(istart > ncountry-nvselect) istart = ncountry-nvselect; if(istart < 0 ) istart = 0; iend = istart+nvselect; if(iend>ncountry) iend = ncountry; if(iend=ncountry) icselect=ncountry-1; break; case GLUT_KEY_UP: icselect -= 1; if(icselect<0) icselect = 0; break; case GLUT_KEY_LEFT: /* left arrow */ iselect = 0; break; case GLUT_KEY_RIGHT: iselect = 1; break; default: return; } glutPostRedisplay(); } /* end special key */ static void Reshape( int w, int h ) { double xr = 6.66666666666-2.0; winWidth = w; winHeight = h; glViewport( 0, 0, w, h ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho(-2.0, xr, -2.0, 2.0, -10.0, 10.0); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); } /* end reshape */ static void Init( void ) { /* set clear color to white */ glClearColor (1.0, 1.0, 1.0, 1.0); } /* end init */ int main(int argc, char *argv[]) { glutInit( &argc, argv ); glutInitWindowSize( winWidth, winHeight ); glutInitWindowPosition(10,50); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow(argv[0]); Init(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc(special); glutDisplayFunc( Display ); glutIdleFunc( Idle ); glutCreateMenu(ModeMenu); glutAddMenuEntry("Toggle Animation", ANIMATE); glutAddMenuEntry("zoom in", ZOOMIN); glutAddMenuEntry("zoom out", ZOOMOUT); glutAddMenuEntry("Rotate slower", SLOWER); glutAddMenuEntry("Rotate faster", FASTER); glutAddMenuEntry("Quit", QUIT); glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); return 0; } /* end main of world.c */