Wednesday 27 April 2022

Tingkat keanekaragaman hayati tingkat gen


Tingkat keanekaragaman hayati tingkat gen

Tingkat keanekaragaman hayati tingkat gen -- Keanekaragaman hayati adalah sebuah istilah untuk menggambarkan keanekaragaman mahluk hidup di seluruh dunia. keanekaragaman hayati menunjukan keseluruhan variasi yang terjadi pada tingkat gen, spesies dan ekosistem disuatu daerah diseluruh dunia. 

Keanekaragaman hayati melukiskan keadaan bermacam-macam terhadap suatu benda yang terjadi karena akibat perbedaan dalam hal ukuran, perbedaan dalam hal bentuk, perbedaan tekstur maupun jumlahnya.

Menurut Zulkifli (1997), keanekaragaman hayati merupakan istilah yang digunakan untuk istilah yang berkaitan dengan berbagai kehidupan di muka bumi.

menurut dahuri (2003), keankearagaman hayati adalah keaneka ragaman yang mencangkup keanekaragaman ekosistem , jenis dan  genetik.

menurut bernes (1997) keanekaragaman hayati merupakan berbagai jenis pola penyebaran, berbagai macam jenis serta jumlah dari suatu organisme.

Keanekaragaman hayati baik secara langsung ataupun tidak langsung memiliki peran dalam kehidupan manusia meliputi kebutuhan sandang, pangan, papan dan obat-obatan. selain itu peran lain dari keanekaragaman hayati yang tidak kalah pentingnya adalah dapat mengatur proses ekologis sistem penyangga kehidupan termasuk mencegah pencemaran udara serta air, menghasilkan oksigen,  mencegah adanya banjir serta erosi dan longsor, selain itu menunjang keseimbangan hubungan pemangsa dan yang dimangsa dalam bentuk pengendalian hama secara alami.

Didalam keanekaragaman hayati terdapat beberapa tingkatan keanekaragaman hayati diantaranya yaitu :

  1. keanakearagaman hayati tingkat gen
  2. keanekaragaman hayati tingkat spesies
  3. keankearagaman hayati tingkat ekosistem
namun pada artikel kali ini kita akan membahas secara mendetail mengenai tingkat keanekaragaman hayati tingkat gen.

Apa itu keanekaragaman hayati tingkat gen?

Keaneka ragaman hayati tingkat gen menurut (Indrawan dkk,2007) adalah segala perbedaan pada mahluk hidup dalam satu spesies. artinya adalah keanakaragaman hayati tingkat gen merupakan perbedaan suatu individu dalam satu jenis mahluk hidup. 

Keanekaragaman hayati tingkat gen diakibatkan karena adanya keanekaragaman tingkat gen pada suatu jenis mahluk hidup. keankearagaman hayati tingkat gen ini diakibatkan karena terjadinya variasi genetik.

variasi genetik pada suatu spesies diakibatkan karena adanya persilangan jenis dalam satu individu. bisa juga variasi genetik disebabkan oleh manusia dengan menggunakan teknologi untuk merubah keadaan genetik suatu jenis spesies. adapun contoh dari keanekaragaman hayati tingkat gen dapat anda lihat pada penjelasan dibawah ini. 

Apa saja contoh keanekaragaman hayati tingkat gen?

Contoh dari keanekaragaman hayati tingkat gen adalah sebagai berikut.

  1. Perbedaan warna pada bunga mawar. walaupun jenis dari mawar sama akan tetapi karena adanya perubahan genetik pada mawar maka warna mawar berbeda-beda ada mawar warna merah, mawar warna kuning, mawar warna putih.
  2. Buah mangga. walaupun jenisnya sama-sama mangga akan tetapi terdapat variasi yang berbeda dijenisnya diantaranya adalah adanya mangga harum manis, mangga manalagi , mangga gedong.
  3. Perbedaan pada kucing yaitu jenisnya bisa berbeda-beda adanya kucing anggora, kucing persia,  kucing rumah dan kucing siam.
  4. Pisang terdiri dari pisang ambon, pisang raja , pisang kepok, pisang sunrise dan masih banyak jenis pisang lainnya.
  5. Ayam pada keturunannya memiliki perbedaan kepada keturunanannya mengenai warnanya, ada warna kelawu, ada warna hitam, ada warna putih  dan masih banyak warna yang lainnya.
  6. Ikan cupang, walaupun ikan cupang memiliki perbedaan warna serta jenisnya. untuk jenisnya ada cupang halfmoon, cupang plakat, cupang serit dan cupang double tails.
  7. Ikan Guppy, memiliki banyak jenisnya diantaranya adalah ada guppy koi, guppy halfmoon, guppy sword tail dan masih banyak yang lainnya.

Demikian pembahasan mengenai tingkat keanekaragaman tingkat gen. semoga bermanfaat dan dapat dimanfaatkan.

Saturday 23 April 2022

Biologi sebagai ilmu materi kelas X beserta soal ujiannya (download pdf, ppt dan doc)

 
Biologi sebagai ilmu
Ilustration from pixabay

Mengenal Biologi sebagai ilmu

Biologi sebagai ilmu - Biologi berasal dari bahasa yunani. kata Biologi secara bahasa terdiri dari 2 kata yaitu "bios" dan "logos". bios memiliki arti "hidup" dan logos memiliki arti "ilmu". dari kedua istilah tersebut dapat kita simpulkan bahwa biologi adalah ilmu yang memperlajari makhluk hidup dan kehidupan didalamnya. 

Ilmu biologi mengkaji dari berbagai aspek kehidupan diantaranya yaitu struktur, fungsi , evolusi, pertumbuhan persebaran serta taksonomi. 

untuk soft file materi ini dapat anda download disini

Download PPT Download PDF Download Doc

Untuk Soal Ujiannya silahkan kunjungi link dibawah ini.


16 Cabang Ilmu Biologi


Didunia ini cabang ilmu biologi jumlahnya diperkirakan lebih dari 200 buah. mencangkup bidang kesehatan, hewan, tumbuhan, evolusi, bakteri , ruang angkasa, reproduksi dan masih banyak yang lainnya. pada artikel ini akan kita bahas 15 cabang ilmu biologi yang harus diketahui diantaranya yaitu :

# Cabang Penjelasan
1 Anatomi Anatomi adalah Cabang ilmu biologi yang mempelajari struktur bagian dalam tubuh mahluk hidup. Anatomi berasal dari bahasa yunani yang memiliki arti pembedahan atau pemotongan.
2 Morfologi Morfologi adalah cabang ilmu biologi yang mempelajari struktur bagian luar dari mahluk hidup. contohnya adalah penelitian mengapa paruh burung berbeda-beda bentuknya. nah struktur perbedaan dari luar ini maka akan masuk ke cabang ilmu biologi mengenai morfologi.
3 Fisiologi Fisiologi adalah cabang ilmu biologi yang mempelajari mengenai fungsi dari alat tubuh. fisiologi akan mempelajari fungsi tubuh baik secara anatomi ( maupun morfologi.
4 Bakteriologi Bakteriologi adalah cabang ilmu biologi yang mempelajari mengenai bakteri beserta pengaruhnya terhadap sebuah penyakit dan obat-obatan.
5 Taksonomi Taksonomi adalah cabang ilmu biologi yang mempelajari pengelompokan mahluk hidup (klasifikasi mahluk hidup).
6 Botani Botani adalah cabang ilmu biologi yang mempelajari tumbuh-tumbuhan
7 Ekologi Ekologi adalah cabang ilmu biologi yang mempelajari interaksi antar mahluk hidung dengan lingkungannya
8 MikroBiologi Mikrobiologi adalah cabang ilmu biologi yang mempelajari tentang segala aspek kehidupan mikro organisme yang berukuran mikroskopis atau berukutan kecil yang tidak dapat dilihat oleh mata telanjang.
9 Evolusi Evolusi adalah cabang ilmu biologi yang mempelajari perubahan-perubahan dari jenis mahluk hidup sepanjang masa.
10 Sitologi Sitologi adalah cabang ilmu biologi yang mempelajari susunan dan fungsi sel pada mahluk hidup.
11 Genetika Genetika adalah cabang ilmu biologi yang mempelajari tentang cara menurunnya sifat pada keturunan yang dihasilkan.
12 Patologi patologi adalah cabang ilmu biologi yang mempelajari tentang seluk beluk penyakit baik pada tanaman, hewan ataupun manusia.
13 Histologi Histologi adalah cabang ilmu biologi yang mempelajari jaringan tubuh pada mahluk hidup
14 Imunologi Imunologi adalah cabang ilmu biologi yang mempelajari tentang sistem kekebalan tubuh
15 Virologi Virologi adalah cabang ilmu biologi yang mempelajari tentang virus. contoh virus diantaranya yaitu virus flu burung, virus antrak, virus influenza dan virus covid.
16 Mikologi Mikologi adalah cabang ilmu biologi yang mempelajari tentang jamur


Objek kajian biologi

Objek kajian Biologi memiliki ruang lingkup seluruh kehidupan yang ada dimuka bumi. mulai dari tingkat organisme mikroskopis sampai tingkat organisme yang besar, dari mulai tingkat organisasi sederhana sampai tingkat organisasi yang sangat kompleks.
Sejalan dengan berkembangnya ilmu pengetahuan, Objek kajian biologi juga selalu mengalami perkembangan. pada mulanya perkembangan mahluk hidup itu hanya dibagi menjadi 2 kingdom yaitu kingdom animalia(hewan) dan kingdom plantae (tanaman). namun semakin berkembangnya zaman maka tingkat klasifikasi dibagi menjadi 6 tingkat diantaranya yaitu
  • Archaebacterial
  • Eubacteria
  • Protista
  • Fungi
  • Plantae
  • Animalia

11 Tingkat organisasi mahluk hidup

Didala biologi sebagai ilmu terutama pada objek kajian. Semua objek dapat dikaji mulai dari tingkat molekul, sel, jaringan, organ, system organ, individu (organisme), Populasi, komunitas, ekosistem, bioma, serta biosfer. Urutan tingkat makhluk hidup tersebut dinamakan dengan hierarki kehidupan atau organisasi kehidupan
tingkatan organisasi mahluk hidup didalam biologi sebagai ilmu dapat dibagi menjadi 11 diantaranya yaitu :

# Tingkat Penjelasan
1 Molekul Molekul adalah Partikel penyususn organisme dari atom-atom. Organisasi maluk hidup pada tingkat molekul mempelajari makromolekul seperti karbohidrat, Asam nukleat (RNA dan DNA) dan masih banyak yang lainnya.
2 Sel Sel adalah unit struktural dan fungsional terkecil dari mahluk hidup. sel merupakan dasar dari kehidupan, semua fungsi kehidupan diatur  dan berlangsung didalam sel.
3 Jaringan Jaringan adalah kumpulan sel yang memiliki bentuk dan fungsi yang sama.
4 Organ Organ adalah kumpulan berbagai jaringan yang melakukan fungsi tertentu. setiap tubuh dari mahluk hidup akan tersusun dari berbagai macam organ diantaranya yaitu jantung, paru-paru dan otak.
5 Sistem Organ Sistem organ adalah Berbagai macam organ bersatu dan menjalankan fungsi tertentu membentuk suatu sistem. sebagai contoh lambung, hati, pankreas dan lain-lain akan membentuk sistem pencernaan manusia (menjalankan fungsi pencernaan). 
6 Organisme /Individu Organisme adalah kumpulan berbagai macam sistem organ saling bekerjasama menyusun tubuh organisme. organisme merupakan mahluk hidup tunggal 
7 Populasi Populasi adalah kumpulan dari individu dari satu spesies yang berinteraksi dan hidup di wilayah tertentu
8 Komunitas Komunitas adalah kumpulan populasi dari berbagai spesies yang saling berinteraksi dan hidup di area tertentu dalam kurun waktu yang sama.
9 Ekosistem Ekosistem adalah seluruh komunitas beserta lingkungan fisik atau abiotik yang saling berinteraksi.
10 Bioma Bioma adalah suatu tipe ekosistem regional yang memiliki komunitas yang serupa. Bioma yang terdapat di dunia antara lain:Hutan hujan tropis,Taiga,Tundra,Padag rumput,Gurun,Hutan gugur.
11 Biosfer Biosfer adalah keseluruhan bioma atau seluruh organisme di bumi beserta tempat hidup yang meliputi atmosfer, hidrosfer dan litosfer disebut biosfer.

.






Monday 17 January 2022

Project OpenGL Rumah pintar dengan CodeBlock C++ dan C

 

Rumah pintar full sourcecode openGL c++

PENGUMUMAN

  " Projek ini Dibuat dengan Benar sudah berjalan secara semestinya. apabila ada ERROR di code silahkan pelajari dimana letak errornya. jangan hanya mau disuapi saja. mengcopi ini = harus mempelajari  sourcodenaya sendiri. 

Jangan Lupa Ucapkan Terimakasih di kolom komentar Jika Projeknya berhasil Dijalankan. 

dan untuk Glut download sementara saya tutup, jika ingin mendownload silahkan komentar dibawah tujuan kalian belajar OPENGL beserta email kalian. nanti saya bagikan lewat email kalian yang ada dikolom komentar. (komentar tidak akan muncul jika belum disetujui dan belum dikirim openGLnya ke email kalian)"

pada projek kali ini kita akan membuat projek rumah pintar. sekenarionya adalah membuat sebuah projek opengl tentang pedesaan yang sudah maju teknologinya. disana terdapat perbukitan serta terdapat pembangkit listrik tenaga angin. 

Projek ini tidak ada efek animasi hanya gambar saja membentuk pola pedesaan. jika anda penasaran cara membuatnya silahkan pelajari langkah-langkah dibawah ini.


Persiapan Projek OpenGL C++ dengan Codeblock

Untuk memulai membuat projek open GL ini anda harus menseting beberapa komponen kedalam codeblock dan ketika sudah selesai menseting semuanya saatnya membuat projeknya. untul langkah-langkah persiapannya dapat melakukan beberapa langkah-langkah dibawah ini.

  1. Open GL download disini :View openGL
  2. CodeBlock setting dengan openGL caranya lihat disini: view
  3. buka codeblock dan buat projek baru caranya dapat dilihat disini : view
  4. copy semua sourcode yang tersedia di blog ini.
silahkan copy contoh program dibawah ini ke projek yang anda buat. adapun sourcode yang akan anda coba adalah sebagai berikut.


  
#include<windows.h> #include<GL\glut.h> #include <GL/glu.h> #include<math.h> #include <stdlib.h> #include<stdio.h> #define PI 3.1416 GLint i, j, k; GLfloat sun_spin=0, sun_x=0, sun_y=0; GLfloat ax=0,bx=0,cx=0,dx=0,str=500.0,mn=500.0; GLfloat sr=0.0,sg=0.749,sb=1.0; GLfloat spin = 0.0; void init(void) { glClearColor(.40, .110, 1.0, 0.0); glMatrixMode(GL_PROJECTION); gluOrtho2D(0.0, 1000.0, 0.0, 500.0); } ///============================================================================================================/// ///=================/// ///*** All_Model ***/// ///=================/// ///*** Circle_Model***/// void circle(GLdouble rad) { GLint points = 50; GLdouble delTheta = (2.0 * PI) / (GLdouble)points; GLdouble theta = 0.0; glBegin(GL_POLYGON); { for( i = 0; i <=50; i++, theta += delTheta ) { glVertex2f(rad * cos(theta),rad * sin(theta)); } } glEnd(); } /// *** Sun_Model **/// void Sun_Model(){ glPushMatrix(); glTranslatef(500,0,0); circle(30); glPopMatrix(); } void Moving_Sun_Model(){ glPushMatrix(); glRotatef(-sun_spin, 0,0,-.009); Sun_Model(); glPopMatrix(); } ///*** Cloud_Model***/// void cloud_model_one(){ glColor3f(1.25, 0.924, 0.930); ///Top_Left glPushMatrix(); glTranslatef(320,210,0); circle(15); glPopMatrix(); ///Top glPushMatrix(); glTranslatef(340, 225, 0); circle(16); glPopMatrix(); ///Right glPushMatrix(); glTranslatef(360,210,0); circle(16); glPopMatrix(); ///middle_Fill glPushMatrix(); glTranslatef(355,210,0); circle(16); glPopMatrix(); glPushMatrix(); glTranslatef(350,210,0); circle(16); glPopMatrix(); glPushMatrix(); glTranslatef(345,204,0); circle(10); glPopMatrix(); glPushMatrix(); glTranslatef(340,204,0); circle(10); glPopMatrix(); glPushMatrix(); glTranslatef(335,204,0); circle(10); glPopMatrix(); glPushMatrix(); glTranslatef(330,204,0); circle(10); glPopMatrix(); glPushMatrix(); glTranslatef(325,204,0); circle(10); glPopMatrix(); glPushMatrix(); glTranslatef(320,204,0); circle(10); glPopMatrix(); glPushMatrix(); glTranslatef(315,204,0); circle(10); glPopMatrix(); glPushMatrix(); glTranslatef(310,204,0); circle(10); glPopMatrix(); glPushMatrix(); glTranslatef(305,204,0); circle(10); glPopMatrix(); ///****Fill End**** } void cloud_model_Two(){ glColor3f(1.25, 0.924, 0.930); ///Left_Part glPushMatrix(); glTranslatef(305,205,0); circle(10); glPopMatrix(); ///Top glPushMatrix(); glTranslatef(320,210,0); circle(15); glPopMatrix(); ///Right_Part glPushMatrix(); glTranslatef(334,207,0); circle(10); glPopMatrix(); ///Bottom_Part glPushMatrix(); glTranslatef(320,207,0); circle(10); glPopMatrix(); } void cloud_model_Three(){ glColor3f(1.25, 0.924, 0.930); ///Left_Part glPushMatrix(); glTranslatef(300,200,0); circle(15); glPopMatrix(); ///Top_Left glPushMatrix(); glTranslatef(320,210,0); circle(15); glPopMatrix(); ///Top glPushMatrix(); glTranslatef(340,220,0); circle(16); glPopMatrix(); ///Top_Right glPushMatrix(); glTranslatef(360,210,0); circle(15); glPopMatrix(); ///Right_Part glPushMatrix(); glTranslatef(380,200,0); circle(15); glPopMatrix(); ///Bottom_Right glPushMatrix(); glTranslatef(360,190,0); circle(20); glPopMatrix(); ///Bottom_Left glPushMatrix(); glTranslatef(320,190,0); circle(20); glPopMatrix(); ///Bottom glPushMatrix(); glTranslatef(340,190,0); circle(20); glPopMatrix(); ///****Fill End**** } ///*** Hill_Model***/// void hill_big(){ ///Hill glBegin(GL_POLYGON); glColor3f(0.38, 0.41, 0.36); glVertex2i(70, 70); glVertex2i(200, 225); glVertex2i(330, 70); glEnd(); ///Hill_Snow glBegin(GL_POLYGON); glColor3f(1.25, 0.924, 0.930); glVertex2i(200, 225); glVertex2i(230, 190); glVertex2i(220, 180); glVertex2i(200, 190); glVertex2i(190, 180); glVertex2i(170, 190); glEnd(); } void hill_small(){ ///Hill_Small glBegin(GL_POLYGON); glColor3f(0.11, 0.23, 0.36); glVertex2i(250, 100); glVertex2i(310, 175); glVertex2i(370, 100); glEnd(); ///Hill_Small_Snow glBegin(GL_POLYGON); glColor3f(1.25, 0.924, 0.930); glVertex2i(290, 150); glVertex2i(310, 175); glVertex2i(330, 150); glVertex2i(325, 140); glVertex2i(310, 150); glVertex2i(300, 140); glEnd(); } ///*** Tilla_Model ***/// void Tilla_One_Model(){ ///Tilla glBegin(GL_POLYGON); glColor3f(0.1, 1.293, 0.0); glVertex2i(125, 70); glVertex2i(150, 80); glVertex2i(160, 90); glVertex2i(170, 90); glVertex2i(180, 100); glVertex2i(190, 105); glVertex2i(200, 108); glVertex2i(300, 110); glVertex2i(300, 70); glEnd(); } void Tilla_Two_Model(){ glColor3f(0.1, 1.293, 0.0); /// Left_Part glPushMatrix(); glTranslatef(430,90,0); circle(30); glPopMatrix(); glPushMatrix(); glTranslatef(420,87,0); circle(30); glPopMatrix(); glPushMatrix(); glTranslatef(410,80,0); circle(30); glPopMatrix(); glPushMatrix(); glTranslatef(400,80,0); circle(30); glPopMatrix(); glPushMatrix(); glTranslatef(390,70,0); circle(30); glPopMatrix(); ///Right_Part glPushMatrix(); glTranslatef(445,80,0); circle(30); glPopMatrix(); glPushMatrix(); glTranslatef(455,75,0); circle(30); glPopMatrix(); glPushMatrix(); glTranslatef(465,70,0); circle(30); glPopMatrix(); glPushMatrix(); glTranslatef(470,65,0); circle(30); glPopMatrix(); glPushMatrix(); glTranslatef(480,60,0); circle(30); glPopMatrix(); glPushMatrix(); glTranslatef(485,55,0); circle(20); glPopMatrix(); } ///*** House_Model ***/// void house(){ ///House_Roof glBegin(GL_POLYGON); glColor3f(.990, 0.0, 0.0); glVertex2i(285, 105); glVertex2i(285, 130); glVertex2i(380, 115); glVertex2i(380, 105); glEnd(); ///House_Roof_Shadow glBegin(GL_POLYGON); glColor3f(.890, 0.0, 0.0); glVertex2i(285, 105); glVertex2i(285, 120); glVertex2i(380, 105); glVertex2i(380, 105); glEnd(); ///House_Fence glBegin(GL_POLYGON); glColor3f(.555, 1.0, 1.0); glVertex2i(290, 70); glVertex2i(290, 104); glVertex2i(375, 104); glVertex2i(375, 70); glEnd(); ///House_Fence_Shadow glBegin(GL_POLYGON); glColor3f(.555, 0.924, 0.930); glVertex2i(310, 70); glVertex2i(350, 104); glVertex2i(375, 104); glVertex2i(375, 70); glEnd(); ///House_Door glBegin(GL_POLYGON); glColor3f(0.38, 0.41, 0.36); glVertex2i(330, 70); glVertex2i(330, 100); glVertex2i(350, 100); glVertex2i(350, 70); glEnd(); ///House_Window1 glBegin(GL_POLYGON); glColor3f(0.38, 0.21, 0.26); glVertex2i(295, 75); glVertex2i(295, 90); glVertex2i(310, 90); glVertex2i(310, 75); glEnd(); ///House_Window2 glBegin(GL_POLYGON); glColor3f(0.38, 0.21, 0.26); glVertex2i(312, 75); glVertex2i(312, 90); glVertex2i(327, 90); glVertex2i(327, 75); glEnd(); ///House_Window3 glBegin(GL_POLYGON); glColor3f(0.38, 0.21, 0.26); glVertex2i(355, 75); glVertex2i(355, 90); glVertex2i(370, 90); glVertex2i(370, 75); glEnd(); ///House_Small_Roof glBegin(GL_POLYGON); glColor3f(1.0, 0.0, 0.0); glVertex2i(250, 90); glVertex2i(257, 104); glVertex2i(290, 104); glVertex2i(290, 90); glEnd(); ///House_Small_Fence glBegin(GL_POLYGON); glColor3f(.555, .724, .930); glVertex2i(255, 70); glVertex2i(255, 90); glVertex2i(290, 90); glVertex2i(290, 70); glEnd(); ///House_Small_Door glBegin(GL_POLYGON); glColor3f(0.11, 0.23, 0.36); glVertex2i(260, 70); glVertex2i(260, 80); glVertex2i(285, 80); glVertex2i(285, 70); glEnd(); } ///*** Field_Model ***/// void field(){ ///Field glBegin(GL_POLYGON); glColor3f(0.533, 1.293, 0.0); glVertex2i(0, 50); glVertex2i(0, 70); glVertex2i(1000, 70); glVertex2i(1000, 50); glEnd(); ///Field_Shadow glBegin(GL_POLYGON); glColor3f(0.1, 1.293, 0.0); glVertex2i(0, 0); glVertex2i(0, 50); glVertex2i(1000, 50); glVertex2i(1000, 0); glEnd(); } ///*** Tree_Model ***/// void Tree_Model_One(){ glPushMatrix(); glTranslatef(110,110,0); circle(15); glPopMatrix(); glPushMatrix(); glTranslatef(110,100,0); circle(15); glPopMatrix(); glBegin(GL_POLYGON); glColor3f(0.38, 0.21, 0.26); glVertex2f(109, 70); glVertex2f(109, 90); glVertex2f(111, 90); glVertex2f(111, 70); glEnd(); } void Tree_Model_Two(){ glPushMatrix(); glTranslatef(130,130,0); circle(5); glPopMatrix(); glPushMatrix(); glTranslatef(125,126,0); circle(5); glPopMatrix(); glPushMatrix(); glTranslatef(135,126,0); circle(5); glPopMatrix(); glPushMatrix(); glTranslatef(130,125,0); circle(5); glPopMatrix(); glBegin(GL_POLYGON); glColor3f(0.38, 0.21, 0.26); glVertex2f(129, 110); glVertex2f(129, 124); glVertex2f(131, 124); glVertex2f(131, 110); glEnd(); } void Tree_Model_Three(){ glBegin(GL_POLYGON); glVertex2f(125, 123); glVertex2f(133, 145); glVertex2f(141, 123); glEnd(); glBegin(GL_POLYGON); glColor3f(0.38, 0.21, 0.26); glVertex2f(132, 110); glVertex2f(132, 124); glVertex2f(134, 124); glVertex2f(134, 110); glEnd(); } /// *** Windmill_Stand_Model ***/// void Windmill_Stand_Model(){ glColor3f(0.38, 0.41, 0.36); glBegin(GL_POLYGON); glVertex2i(375, 100); glVertex2i(380, 240); glVertex2i(384, 240); glVertex2i(390, 100); glEnd(); } ///*** Windmill_Blades_Model ***/// void Windmill_Blade(){ ///Blade_One glPushMatrix(); glRotatef(spin,0,0,90); glBegin(GL_POLYGON); glVertex2i(-5, 0); glVertex2i(-85, -36); glVertex2i(-83, -37); glVertex2i(-3, -8); glEnd(); glPopMatrix(); ///Blade_Two glPushMatrix(); glRotatef(spin,0,0,90); glBegin(GL_POLYGON); glVertex2i(0, 5); glVertex2i(45, 70); glVertex2i(50, 73); glVertex2i(5, 0); glEnd(); glPopMatrix(); ///Blade_Three glPushMatrix(); glRotatef(spin,0,0,90); glBegin(GL_POLYGON); glVertex2i(68, -78); glVertex2i(0,0); glVertex2i(5, 5); glVertex2i(70, -77); glEnd(); glPopMatrix(); } ///*** Windmill_Final_Model ***/// void Windmill(){ ///Windmill_Stand glColor3f(0.38, 0.41, 0.36); glPushMatrix(); Windmill_Stand_Model(); glPopMatrix(); ///Windmill_Motor glColor3f(0.11, 0.23, 0.36); glPushMatrix(); glTranslatef(380,250,0); circle(10); glPopMatrix(); ///Windmill_Rotary_Blades glColor3f(0.11, 0.23, 0.36); glPushMatrix(); glTranslatef(380,251,0); Windmill_Blade(); glPopMatrix(); } ///Model_End ///=======================================================================================================/// ///=================/// ///*** Object ***/// ///=================/// ///*** Sun ***/// void Sun(){ glColor3f(1, 1, 0); glPushMatrix(); Moving_Sun_Model(); glPopMatrix(); } ///*** Cloud_One_Model_One ***/// void cloud_one(){ glPushMatrix(); glTranslatef(cx,-40,0); cloud_model_one(); glPopMatrix(); } ///*** Cloud_Two_Model_one ***/// void cloud_two(){ glPushMatrix(); glTranslatef(bx+100,150,0); cloud_model_one(); glPopMatrix(); } ///*** Cloud_Three_Model_Two ***/// void cloud_three(){ glPushMatrix(); glTranslatef(ax-80,80,0); cloud_model_Two(); glPopMatrix(); } ///*** Cloud_Four_Model_Two ***/// void cloud_four(){ glPushMatrix(); glTranslatef(dx+300,125,0); cloud_model_Two(); glPopMatrix(); } ///*** Cloud_Five_Model_Three ***/// void cloud_five(){ glPushMatrix(); glTranslatef(ax+-300,170,0); cloud_model_Three(); glPopMatrix(); } ///*** Cloud_Six_Model_Three ***/// void cloud_six(){ glPushMatrix(); glTranslatef(cx+-500,20,0); cloud_model_Three(); glPopMatrix(); } ///*** House_One ***/// void house_one(){ glPushMatrix(); glTranslatef(0,0,0); house(); glPopMatrix(); } ///*** House_Two ***/// void house_two(){ glPushMatrix(); glTranslatef(450,0,0); house(); glPopMatrix(); } ///*** House_Two ***/// void house_three(){ glPushMatrix(); glTranslatef(320, 37,0); house(); glPopMatrix(); } ///*** Hill_big_One ***/// void Hill_Big_One(){ glPushMatrix(); glTranslatef(0,0,0); hill_big(); glPopMatrix(); } ///*** Hill_big_Two ***/// void Hill_Big_Two(){ glPushMatrix(); glTranslatef(550,-20,0); hill_big(); glPopMatrix(); } ///*** Hill_Small_One ***/// void Hill_Small_One(){ glPushMatrix(); glTranslatef(0,0,0); hill_small(); glPopMatrix(); } /// *** Tilla_One_Model_One ***/// void Tilla_One(){ glPushMatrix(); glTranslatef(0,0,0); Tilla_One_Model(); glPopMatrix(); } /// *** Tilla_Two_Model_Two ***/// void Tilla_Two(){ glPushMatrix(); glTranslatef(0,0,0); Tilla_Two_Model(); glPopMatrix(); } /// *** Tilla_Three_Model_Two ***/// void Tilla_Three(){ glPushMatrix(); glTranslatef(400,0,0); Tilla_Two_Model(); glPopMatrix(); } /// *** Tilla_Four_Model_One ***/// void Tilla_Four(){ glColor3f(0.833, 1., 0.0); glPushMatrix(); glTranslatef(380,0,0); Tilla_One_Model(); glPopMatrix(); } ///*** Tree_1 ***/// void Tree_One(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(0,0,0); Tree_Model_One(); glPopMatrix(); } ///*** Tree_2 ***/// void Tree_Two(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(540,0,0); Tree_Model_One(); glPopMatrix(); } ///*** Tree_3 ***/// void Tree_Three(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(750,0,0); Tree_Model_One(); glPopMatrix(); } ///*** Tree_4 ***/// void Tree_Four(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(292,40,0); Tree_Model_One(); glPopMatrix(); } ///*** Tree_5 ***/// void Tree_Five(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(30,-20,0); Tree_Model_Two(); glPopMatrix(); } ///*** Tree_6 ***/// void Tree_Six(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(50,-10,0); Tree_Model_Two(); glPopMatrix(); } ///*** Tree_7 ***/// void Tree_Seven(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(322,0,0); Tree_Model_Two(); glPopMatrix(); } ///*** Tree_8 ***/// void Tree_Eight(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(350,-15,0); Tree_Model_Two(); glPopMatrix(); } ///*** Tree_9 ***/// void Tree_Nine(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(760,-25,0); Tree_Model_Two(); glPopMatrix(); } ///*** Tree_10 ***/// void Tree_Ten(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(90,-2,0); Tree_Model_Three(); glPopMatrix(); } ///*** Tree_11 ***/// void Tree_Eleven(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(125,0,0); Tree_Model_Three(); glPopMatrix(); } ///*** Tree_12 ***/// void Tree_Twelve(){ glColor3f(0.533, 1.293, 0.0); glPushMatrix(); glTranslatef(408,-22,0); Tree_Model_Three(); glPopMatrix(); } /// *** Windmill ***/// void Windmill_One(){ glColor3f(0.11, 0.23, 0.36); glPushMatrix(); glTranslatef(0,-10,0); Windmill(); glPopMatrix(); } void Windmill_Two(){ glColor3f(0.11, 0.23, 0.36); glPushMatrix(); glTranslatef(508,-70,0); Windmill(); glPopMatrix(); } void Windmill_Three(){ glColor3f(0.11, 0.23, 0.36); glPushMatrix(); glTranslatef(108,-90,0); Windmill(); glPopMatrix(); } ///Object_End ///=========================================================================================================/// ///========================/// ///*** Display Function ***/// ///========================/// void display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0, 0.0, 1.0); ///*** Object_Layer ***/// Sun(); Windmill_Three(); Hill_Big_One(); Tilla_Four(); house_three(); Hill_Big_Two(); Hill_Small_One(); cloud_three(); cloud_four(); Windmill_One(); Windmill_Two(); Tilla_One(); Tilla_Two(); Tilla_Three(); house_one(); cloud_one(); house_two(); Tree_One(); Tree_Two(); Tree_Three(); Tree_Four(); Tree_Five(); Tree_Six(); Tree_Seven(); Tree_Eight(); Tree_Nine(); Tree_Ten(); Tree_Eleven(); Tree_Twelve(); cloud_two(); cloud_five(); cloud_six(); field(); glFlush(); } ///========================/// ///*** Speed & Movement ***/// ///========================/// ///*** Sun_Move ***/// void sun_move(){ sun_spin = sun_spin + 0.0008; } void move_right(){ sun_move(); spin = spin +.1; ax = ax + .05; bx = bx + .08; cx = cx + .10; dx = dx + .15; if(cx>1000){ cx = -300; } if(bx>1000){ bx= -400; } if(cx>1000){ cx= -400; } if(dx>1000){ dx= -500; } glutPostRedisplay(); } void mouse(int key, int state, int x, int y){ switch (key) { case GLUT_LEFT_BUTTON: if (state == GLUT_DOWN) { glutIdleFunc(move_right); } break; case GLUT_MIDDLE_BUTTON: case GLUT_RIGHT_BUTTON: if (state == GLUT_DOWN) { glutIdleFunc(NULL); } break; default: break; } } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowPosition(50, 50); glutInitWindowSize(800, 450); glutCreateWindow("Rumah Pintar"); init(); glutDisplayFunc(display); glutMouseFunc(mouse); glutMainLoop(); }




Saturday 15 January 2022

Projek OpenGL C++ Full sourcecode (Roket di Ruang angkasa).

 

Projek OpenGL C++ full sourcode

PENGUMUMAN

  " Projek ini Dibuat dengan Benar sudah berjalan secara semestinya. apabila ada ERROR di code silahkan pelajari dimana letak errornya. jangan hanya mau disuapi saja. mengcopi ini = harus mempelajari  sourcodenaya sendiri. 

Jangan Lupa Ucapkan Terimakasih di kolom komentar Jika Projeknya berhasil Dijalankan. 

dan untuk Glut download sementara saya tutup, jika ingin mendownload silahkan komentar dibawah tujuan kalian belajar OPENGL beserta email kalian. nanti saya bagikan lewat email kalian yang ada dikolom komentar. (komentar tidak akan muncul jika belum disetujui dan belum dikirim openGLnya ke email kalian)"

Pada projek kali ini kita akan membuat projek sederhana dengan OpenGL C++ dan C yaitu membuat roket di ruang angkasa. Sekenario projek ini adalah membuat sebuah roket yang meluncur diruang angkasa melewati bintang-bintang yang berkelap kelip. projek ini tidak ada kombinasi menggunakan keyboard. projek ini hanya sekedar animasi yang harus berjalan sesuai sekenario.

Jika anda penasara cara membuatnya silahkan ikuti langkah-langkah dibawah ini. jangan sampai ada yang terlewat.

Persiapan membuat Projek OpenGL C++ dengan Codeblock

Untuk memulai membuat projek open GL ini anda harus menseting beberapa komponen kedalam codeblock dan ketika sudah selesai menseting semuanya saatnya membuat projeknya. untul langkah-langkah persiapannya dapat melakukan beberapa langkah-langkah dibawah ini.

  1. Open GL download disini :View openGL
  2. CodeBlock setting dengan openGL caranya lihat disini: view
  3. buka codeblock dan buat projek baru caranya dapat dilihat disini : view
  4. copy semua sourcode yang tersedia di blog ini.
silahkan copy contoh program dibawah ini ke projek yang anda buat. adapun sourcode yang akan anda coba adalah sebagai berikut.


  
#include <GL/gl.h> #include <Gl/glu.h> #include <GL/glut.h> #include <stdlib.h> #include <math.h> #include <iostream> #include <string.h> void stars(); int p; void rocket_to_cam_pos(); float i,j,count=0,count1=0,count3=0,flag=0,flag1=0,t=0,f=0,flag3=0; void control() { count1++; rocket_to_cam_pos(); } void stars() { glColor3f(0.965, 0.788, 0.055); glPointSize(1.37); glBegin(GL_POINTS); glVertex2i(10,20); glVertex2i(20,100); glVertex2i(30,10); glVertex2i(15,150); glVertex2i(17,80); glVertex2i(200,200); glVertex2i(55,33); glVertex2i(400,300); glVertex2i(330,110); glVertex2i(125,63); glVertex2i(63,125); glVertex2i(20,10); glVertex2i(110,330); glVertex2i(440,430); glVertex2i(32,65); glVertex2i(110,440); glVertex2i(210,230); glVertex2i(390,490); glVertex2i(12,90); glVertex2i(400,322); glVertex2i(420,366); glVertex2i(455,400); glVertex2i(20,20); glVertex2i(111,120); glVertex2i(401,200); glVertex2i(230,30); glVertex2i(220,20); glVertex2i(122,378); glVertex2i(133,340); glVertex2i(345,420); glVertex2i(130,360); glVertex2i(333,120); glVertex2i(250,22); glVertex2i(242,11); glVertex2i(280,332); glVertex2i(233,40); glVertex2i(210,418); glVertex2i(256,12); glVertex2i(288,232); glVertex2i(247,36); glVertex2i(229,342); glVertex2i(257,47); glVertex2i(290,63); glVertex2i(232,72); glVertex2i(243,143); glVertex2i(100,200); glVertex2i(90,250); glVertex2i(80,225); glVertex2i(50,333); glVertex2i(60,350); glVertex2i(243,143); glVertex2i(243,143); glEnd(); } void rocket_to_cam_pos() { count++; count3++; for(i=0;i<=500;i++) { glClearColor(0.169, 0.169, 0.157, 1.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); stars(); glColor3f(0.231, 0.035, 0.267); glBegin(GL_POLYGON); glVertex2f(237.5,20.0+i); glVertex2f(262.5,20.0+i); glVertex2f(262.5,120.0+i); glVertex2f(237.5,120.0+i); glEnd(); glColor3f(0.631, 0.145, 0.349); glBegin(GL_POLYGON); glVertex2f(237.5,120.0+i); glVertex2f(262.5,120.0+i); glVertex2f(250,170.0+i); glEnd(); glColor3f(0.373, 0.094, 0.329); glBegin(GL_POLYGON); glVertex2f(237.5,120.0+i); glVertex2f(217.5,95.0+i); glVertex2f(237.5,95.0+i); glEnd(); glBegin(GL_POLYGON); glVertex2f(237.5,20.0+i); glVertex2f(217.5,20.0+i); glVertex2f(237.5,70.0+i); glEnd(); glBegin(GL_POLYGON); glVertex2f(262.5,20.0+i); glVertex2f(282.5,20.0+i); glVertex2f(262.5,70.0+i); glEnd(); glBegin(GL_POLYGON); glVertex2f(262.5,120.0+i); glVertex2f(262.5,95.0+i); glVertex2f(282.5,95.0+i); glEnd(); glColor3f(0.945, 0.733, 0.835); glBegin(GL_POLYGON); glVertex2f(237.5,20.0+i); glVertex2f(244.5,20.0+i); glVertex2f(241,0.0+i); glEnd(); glBegin(GL_POLYGON); glVertex2f(246.5,20.0+i); glVertex2f(253.5,20.0+i); glVertex2f(249.5,0.0+i); glEnd(); glBegin(GL_POLYGON); glVertex2f(262.5,20.0+i); glVertex2f(255.5,20.0+i); glVertex2f(258.5,0.0+i); glEnd(); p=p+1; for(j=0;j<=1000000;j++); glutSwapBuffers(); glutPostRedisplay(); glFlush(); } } void display() { control(); glFlush(); } void myinit() { glClearColor(0.196078 ,0.6 ,0.8,1.0); glPointSize(1.0); gluOrtho2D(0.0,499.0,0.0,499.0); } int main(int argc,char*argv[]) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB); glutInitWindowSize(900,500); glutCreateWindow("rocket"); myinit(); glutDisplayFunc(display); glutIdleFunc(display); glutMainLoop(); return 0; }



Wednesday 12 January 2022

Projek OpenGL C++ "War in the morning" dengan codeBlock fullsourcode (langsung pake)


project openGL c++ codeblock full sourcode


PENGUMUMAN

  " Projek ini Dibuat dengan Benar sudah berjalan secara semestinya. apabila ada ERROR di code silahkan pelajari dimana letak errornya. jangan hanya mau disuapi saja. mengcopi ini = harus mempelajari  sourcodenaya sendiri. 

Jangan Lupa Ucapkan Terimakasih di kolom komentar Jika Projeknya berhasil Dijalankan. 

dan untuk Glut download sementara saya tutup, jika ingin mendownload silahkan komentar dibawah tujuan kalian belajar OPENGL beserta email kalian. nanti saya bagikan lewat email kalian yang ada dikolom komentar. (komentar tidak akan muncul jika belum disetujui dan belum dikirim openGLnya ke email kalian)"

Pada Projek OpenGL C++ dan C ini kita akan membuat sebuah kapal perang yang akan berperang dimalam hari ataupun disiang hari. Didalam projek ini Disekenariokan bahwa tejadi peperangan dilautan luas antara pesawat dan kapal laut. kapal laut berusaha menembakan misik ke pesawat terbang supaya terjatuh. akan tetapi pesawat selalu tidak pernah terkena senjata dari kapal laut.

pada projek ini nantinya kapal laut akan bisa menembakan misil ke pesawat dengan batuan tombol dari keyboard. kemudia kapal laut juga bisa bergerak berpindah-pindah posisi untuk menentukan letak menembaknya. sedangkan pesawat terbang hanya bolak balik di langit lepas. adapun tombol yang digunakan dalam projek ini adalah sebagai berikut. 

  1. tombol keyboard z = menembakan roket ke langit.
  2. tombol keyboard y = Pertempuran Fajar.
  3. tombol keyboard m = Pertempuran pagi hari.
  4. tombol keyboard a = Pertempuran siang hari.
  5. tombol keyboard e = Pertempuran sore hari.
  6. tombol keyboard n = Pertempuran malam.
  7. tombol keyboard d = Pertempuran tengah malam.
  8. tombol keyboard nomor 6 = Kapal laut berjalan maju.
  9. tombol keyboard nomor 4 = Kapal laut berjalan mundur.
  10. tombol keyboard Esc = Keluar dari game( Exit ).
  11. tombol keyboard Enter = Masuk ke game.
Jika anda penasaran bagaimana cara membuatnya silahkan pelajari langkah-langkah dibawah ini dengan baik dan benar.

  
#include<GL/glut.h> #include<windows.h> #include <stdlib.h> #include <stdio.h> #include <math.h> float pos=0,x=0,col=0,i,p,c,cf=0,pr,pl=0; int screen=0; //Introduction Page char name[35]="The Curse of Black Pearl"; char college[100]=""; char dept[100]=""; char heading[100]=""; char row1[100]=""; char row2[100]=""; char emsg[100]="Press ENTER to start"; char title[50]="WAR IN THE MORNING"; char dash[100]=""; void frontscreen(void) { glPushMatrix(); glTranslatef(50,100,0); glClearColor(0.8,0.8,1.0,1.0); int s; glClear(GL_COLOR_BUFFER_BIT); glRasterPos2i(184,480); //displays college name for(s=0;college[s]!='\0';s++) { glColor3f(0.0,0.0,1.0); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,college[s]); } glRasterPos2i(180,450); //displays dept. for(s=0;dept[s]!='\0';s++) { glColor3f(1.0,0.0,0.0); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,dept[s]); } glRasterPos2i(210,380); //displays project name for(s=0;title[s]!='\0';s++) { glColor3f(0.0,0.0,0.0); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,title[s]); } glRasterPos2i(155,370); //displays dashes for(s=0;dash[s]!='\0';s++) { glColor3f(0.0,0.0,0.0); glutBitmapCharacter(GLUT_BITMAP_9_BY_15,dash[s]); } glRasterPos2i(170,340); //displays heading of table for(s=0;heading[s]!='\0';s++) { glColor3f(0.0,0.0,0.0); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,heading[s]); } glRasterPos2i(155,330); //displays dashes for(s=0;dash[s]!='\0';s++) { glColor3f(0.0,0.0,0.0); glutBitmapCharacter(GLUT_BITMAP_9_BY_15,dash[s]); } glRasterPos2i(170,310); //displays 1st row in table for(s=0;row1[s]!='\0';s++) { glColor3f(0.0,0.0,0.0); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,row1[s]); } glRasterPos2i(170,290); //displays 2nd row in table for(s=0;row2[s]!='\0';s++) { glColor3f(0.0,0.0,0.0); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,row2[s]); } glRasterPos2i(155,270); //displays dashes for(s=0;dash[s]!='\0';s++) { glColor3f(0.0,0.0,0.0); glutBitmapCharacter(GLUT_BITMAP_9_BY_15,dash[s]); } glRasterPos2i(200,100); //displays "enter msg" for(s=0;emsg[s]!='\0';s++) { glColor3f(1.0,0.0,0.5); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,emsg[s]); } glPopMatrix(); glFlush(); } //sun/moon void Drawarc(float sa,float ea,float cx,float cy,float rd) { float PI = 3.14; float step=1.0; float angle,x=0,y=0,centerX=cx,centerY=cy,radius=rd; glBegin(GL_POLYGON); for(angle=sa;angle<ea; angle+=step) { float rad ; rad = PI*angle/180; x = centerX+radius*cos(rad); y = centerY+radius*sin(rad); glVertex2f(x,y); } glEnd(); glFlush(); } //smoke void cloud(int m, int n) { for(c=p=0;c<31;c+=10,p-=1) { glColor3f(0.5,0.5,0.5); Drawarc(0,360,m+c,n,10+p); } } void ship(float x) { glPushMatrix(); glTranslatef(x,0,0); //base glColor3f(0.2+col,0.2+col,0.2+col); glBegin(GL_POLYGON); glVertex2f(10,119); glVertex2f(10,110); glVertex2f(41,70); glColor3f(0.3+col,0.3+col,0.8+col); glVertex2f(219,42); glVertex2f(292,98); glVertex2f(300,110); glEnd(); //p1 glColor3f(1.0+col,1.0+col,1.0+col); glBegin(GL_POLYGON); glVertex2f(35,118); glVertex2f(35,128); glColor3f(0.5+col,0.5+col,0.5+col); glVertex2f(239,131); glVertex2f(239,111); glVertex2f(35,119); glEnd(); //side glBegin(GL_POLYGON); glColor3f(0.8+col,0.8+col,0.8+col); glVertex2f(239,131); glVertex2f(239,111); glVertex2f(257,110); glVertex2f(257,127); glEnd(); //p2 glColor3f(0.0+col,0.0+col,0.5+col); glBegin(GL_POLYGON); glVertex2f(45,129); glVertex2f(45,140); glVertex2f(233,149); glVertex2f(233,131); glEnd(); //side glBegin(GL_POLYGON); glColor3f(0.1+col,0.1+col,0.8+col); glVertex2f(233,149); glVertex2f(233,131); glVertex2f(254,128); glVertex2f(254,145); glEnd(); //p3 glColor3f(0.2+col,0.5+col,0.2+col); glBegin(GL_POLYGON); glVertex2f(51,151); glVertex2f(51,140); glVertex2f(221,149); glColor3f(0.9+col,0.6+col,0.3+col); glVertex2f(221,165); glVertex2f(51,151); glEnd(); //side glBegin(GL_POLYGON); glColor3f(0.1+col,0.4+col,0.1+col); glVertex2f(221,164); glVertex2f(221,149); glVertex2f(247,147); glVertex2f(247,162); glEnd(); //p4 //pipe1 glColor3f(0.48+col,0.27+col,0.44+col); glBegin(GL_POLYGON); glVertex2f(79,152); glVertex2f(79,194); glVertex2f(94,194); glColor3f(0.0+col,0.0+col,0.0+col); glVertex2f(94,155); glEnd(); cloud(59,194); //pipe2 glColor3f(0.44+col,0.48+col,0.27+col); glBegin(GL_POLYGON); glVertex2f(112,156); glVertex2f(112,198); glVertex2f(127,198); glColor3f(0.0+col,0.0+col,0.0+col); glVertex2f(127,158); glEnd(); cloud(92,198); //pipe3 glColor3f(0.27+col,0.48+col,0.44+col); glBegin(GL_POLYGON); glVertex2f(159,161); glVertex2f(159,203); glVertex2f(179,203); glColor3f(0.0+col,0.0+col,0.0+col); glVertex2f(179,160); glEnd(); cloud(144,203); glPopMatrix(); } void water() { glBegin(GL_POLYGON); glColor3f(0.2+col,0.2+col,0.6+col); glVertex2f(00,00); glVertex2f(00,300); glVertex2f(1024,300); glVertex2f(1024,00); glEnd(); } void mountain2() { float a,b; glColor3f(0.6+col,0.4+col,0.2+col); for(a=0,b=300;a<1025;a=a+80) { glBegin(GL_POLYGON); glVertex2f(-40+a,b); glVertex2f(10+a,b+140); glVertex2f(60+a,b); glEnd(); } } void mountain() { float a,b; glColor3f(0.8+col,0.6+col,0.4+col); for(a=0,b=300;a<1025;a=a+80) { glBegin(GL_POLYGON); glVertex2f(0+a,b); glVertex2f(50+a,b+100); glVertex2f(100+a,b); glEnd(); } } void mountain3() { float a,b; glColor3f(0.4+col,0.2+col,0.0+col); for(a=0,b=350;a<1025;a=a+80) { glBegin(GL_POLYGON); glVertex2f(0+a,b); glVertex2f(50+a,b+180); glVertex2f(100+a,b); glEnd(); } } void flag(float x) { int s; glPushMatrix(); glTranslatef(x,0,0); glColor3f(0.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(245,160); glVertex2f(245,250); glVertex2f(242,250); glVertex2f(242,160); glEnd(); glColor3f(0.8,0.1,0.1); glBegin(GL_POLYGON); glVertex2f(245,250); glVertex2f(275,215); glVertex2f(245,180); glEnd(); glRasterPos2i(50,80); //displays college name for(s=0;college[s]!='\0';s++) { glColor3f(1.0,1.0,1.0); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,name[s]); } glPopMatrix(); } void crackers() { // if(cf==1) { glColor3f(1,0,0); glBegin(GL_POLYGON); glVertex2f(100+pos,100+pr); glVertex2f(100+pos,110+pr); glVertex2f(101+pos,110+pr); glVertex2f(101+pos,100+pr); glEnd(); glFlush(); } glutPostRedisplay(); } void init() { glClearColor(0.0,0.0,0.0,1.0); glLoadIdentity(); gluOrtho2D(0,1024,0,768); } void plane() { glPushMatrix(); glTranslatef(0+pl,700,0); glColor3f(0.0,0.0,0.0); glBegin(GL_POLYGON);//rectangular body glVertex2f(0.0,30.0/3); glVertex2f(0.0,55.0/3); glVertex2f(135.0/3,55.0/3); glColor3f(1.0,0.0,0.0); glVertex2f(135.0/3,30.0/3); glEnd(); glColor3f(0.0,0.0,0.0); glBegin(GL_POLYGON);//upper triangle construction plane glVertex2f(135.0/3,55.0/3); glVertex2f(150.0/3,50.0/3); glVertex2f(155.0/3,45.0/3); glVertex2f(160.0/3,40.0/3); glVertex2f(135.0/3,40.0/3); glEnd(); glColor3f(0.0,0.0,0.0); glBegin(GL_LINE_LOOP);//outline of upper triangle plane glVertex2f(135.0/3,55.0/3); glVertex2f(150.0/3,50.0/3); glVertex2f(155.0/3,45.0/3); glVertex2f(160.0/3,40.0/3); glVertex2f(135.0/3,40.0/3); glEnd(); glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON);//lower triangle glVertex2f(135.0/3,40.0/3); glVertex2f(160.0/3,40.0/3); glVertex2f(160.0/3,37.0/3); glVertex2f(145.0/3,30.0/3); glVertex2f(135.0/3,30.0/3); glEnd(); glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON);//back wing glVertex2f(0.0,55.0/3); glVertex2f(0.0,80.0/3); glVertex2f(10.0/3,80.0/3); glVertex2f(40.0/3,55.0/3); glEnd(); glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON);//left side wing glVertex2f(65.0/3,55.0/3); glVertex2f(50.0/3,70.0/3); glVertex2f(75.0/3,70.0/3); glVertex2f(90.0/3,55.0/3); glEnd(); glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON);//rightside wing glVertex2f(70.0/3,40.0/3); glVertex2f(100.0/3,40.0/3); glVertex2f(80.0/3,15.0/3); glVertex2f(50.0/3,15.0/3); glEnd(); glPopMatrix(); } void display() { glClear(GL_COLOR_BUFFER_BIT); if(screen==0) { frontscreen(); glFlush(); } else if(screen==1) { mountain3(); mountain2(); mountain(); water(); if(cf==1) { crackers(); pr+=2; } ship(pos); flag(pos); plane(); pl+=2; if(pl==1200) pl=0; if(i==1) { glColor3f(0.9,0.9,0.5); Drawarc(0,360,200,700,10); } if(i==2) { glColor3f(0.8,0.7,0.4); Drawarc(0,360,400,700,10); } if(i==3) { glColor3f(1.0,1.0,1.0); Drawarc(0,360,600,700,10); } if(i==4) { glColor3f(1.0,1.0,1.0); Drawarc(0,360,800,700,10); } glFlush(); } glutPostRedisplay(); glutSwapBuffers(); glFlush(); } void keyboard(unsigned char key, int x, int y) { switch (key) { case 13:if(screen==0) { screen=1; glutPostRedisplay(); } break; case 27:exit (0); break; case 'y':glClearColor(0.8,0.5,0.4,1.0); col=-0.1; i=0; glutPostRedisplay(); break; case 'm':glClearColor(0.5,0.5,1.0,1.0); i=1; col=0.2; glutPostRedisplay(); break; case 'a':glClearColor(0.9,0.9,0.3,1.0); i=2; col=0.3; glutPostRedisplay(); break; case 'e':glClearColor(0.8,0.5,0.4,1.0); col=-0.1; i=0; glutPostRedisplay(); break; case 'n':glClearColor(0.5,0.5,0.5,1.0); i=3; glutPostRedisplay(); col=-0.2; break; case 'd':glClearColor(0.0,0.0,0.0,0.0); i=4; col=-0.3; glutPostRedisplay(); break; case '6':pos+=2; break; case '4':pos-=2; break; case 'z':cf=1; pr=0; glutPostRedisplay(); break; } } int main() { glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB); glutInitWindowSize(800,500); glutInitWindowPosition(0,0); glutCreateWindow("War in the morning"); glutSwapBuffers(); glutKeyboardFunc(keyboard); glutDisplayFunc(display); init(); glutMainLoop(); }



Referensi : 

Monday 10 January 2022

Project openGL interior rumah (home) dengan C++ CodeBlock Full Sourcode

 

project opengl full sourcode

PENGUMUMAN

  " Projek ini Dibuat dengan Benar sudah berjalan secara semestinya. apabila ada ERROR di code silahkan pelajari dimana letak errornya. jangan hanya mau disuapi saja. mengcopi ini = harus mempelajari  sourcodenaya sendiri. 

Jangan Lupa Ucapkan Terimakasih di kolom komentar Jika Projeknya berhasil Dijalankan. 

dan untuk Glut download sementara saya tutup, jika ingin mendownload silahkan komentar dibawah tujuan kalian belajar OPENGL beserta email kalian. nanti saya bagikan lewat email kalian yang ada dikolom komentar. (komentar tidak akan muncul jika belum disetujui dan belum dikirim openGLnya ke email kalian)"

Pada projek openGl kali ini kita akan membuat sebuah ruangan kamar sendiri. projek ini disekenariokan membuat sebuah kamar lengkap dengan ranjang, kasur dan bantal serta lemari pakaian. selain itu dibuatkan pula pintu yang nantinya bisa dibuka dan di tutup, meja belajar dengan laptop yang bisa dibuka dan ditutup.

Kemudian pada projek ini kita akan membuat beberapa fungsi yang akan kita jalankan seperti membuka dan menutup pintu, membuka dan menutup pintu kamar membuka dan menutup laptop dimeja dengan menggunakan keyboard pada komputer anda. 

adapun beberapa fungsi yang akan tersedia pada projek kali ini adalah

  1. tombol keyboard  q = memutar searah jarum jam.
  2. tombol keyboard  e = memutar berlawanan arah jarum jam.
  3. tombol keyboard f = geser arah kebawah.
  4. tombol keyboard r = geser arah atas.
  5. tombol keyboard a = geser horizontal kiri.
  6. tombol keyboard d = geser horizontal kanan.
  7. tombol keyboard w = memperbesar gambar objek.
  8. tombol keyboard s = memperkecil gambar obejek.
  9. tombol keyboad p = membuka pintu (syarat geser dulu gambar objek ke depan).
  10. tombol keyboard o = menutup pintu (syarat geser dulu gambar ke objek depan).
  11. tombol keyboard l = menutup laptop.
  12. tombol keyboard k = membuka laptop.
  13. tombol keyboard . = membuka lemari.
  14. tombol keybard , = menutup lemari.
  15. tombol keyboard m = buka kursi.
  16. tombol keyboard n = menutup kursi.
Jika anda penasaran dengan cara membuatnya silahkan ikuti langkah-langkah dibawah ini.

Persiapan membuat projek OpenGL dengan CodeBlock

Untuk memulai membuat projek open GL ini anda harus menseting beberapa komponen kedalam codeblock dan ketika sudah selesai menseting semuanya saatnya membuat projeknya. untul langkah-langkah persiapannya dapat melakukan beberapa langkah-langkah dibawah ini.

  1. Open GL download disini :View openGL
  2. CodeBlock setting dengan openGL caranya lihat disini: view
  3. buka codeblock dan buat projek baru caranya dapat dilihat disini : view
  4. copy semua sourcode yang tersedia di blog ini.
silahkan copy contoh program dibawah ini ke projek yang anda buat. adapun sourcode yang akan anda coba adalah sebagai berikut.

  
    #include <cstdlib>
    #include <iostream>     #include <windows.h>     #include <stdio.h>     #include <GL/gl.h>     #include <GL/glu.h>     #include <GL/glut.h>     #include <math.h>     //memberikan fileheader yang dibutuhkan     GLuint texture[35];     GLint slices = 35;     GLint stacks = 35;     using namespace std;     static float ypos = 0, zpos = 0, xpos = 0,a = -9, b = -5,c =-30, laptop=0, laci=0, kursi=0, pintu=0;     int z=0;     struct Image {     unsigned long sizeX;     unsigned long sizeY;     char *data;     };     typedef struct Image Image; //struktur data untuk     //ukuran image #bisa di set sesuai kebutuhan     #define checkImageWidth 164     #define checkImageHeight 164     GLubyte checkImage[checkImageWidth][checkImageHeight][3];     //mengambil tekstur void init(void) { glClearColor(0.5, 0.5, 0.5, 0.0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); // Generate texture/ membuat texture background } //fungsi kotak kosong, belum diisi koordinat. diisi di display() void kotak(float x1,float y1,float z1,float x2,float y2,float z2) { //depan glTexCoord2f(0.0, 0.0); glVertex3f(x1,y1,z1); glTexCoord2f(0.0, 1.0); glVertex3f(x2,y1,z1); glTexCoord2f(1.0, 1.0); glVertex3f(x2,y2,z1); glTexCoord2f(1.0, 0.0); glVertex3f(x1,y2,z1); //atas glTexCoord2f(0.0, 0.0); glVertex3f(x1,y2,z1); glTexCoord2f(0.0, 1.0); glVertex3f(x2,y2,z1); glTexCoord2f(1.0, 1.0); glVertex3f(x2,y2,z2); glTexCoord2f(1.0, 0.0); glVertex3f(x1,y2,z2); //belakang glTexCoord2f(0.0, 0.0); glVertex3f(x1,y2,z2); glTexCoord2f(0.0, 1.0); glVertex3f(x2,y2,z2); glTexCoord2f(1.0, 1.0); glVertex3f(x2,y1,z2); glTexCoord2f(1.0, 0.0); glVertex3f(x1,y1,z2); //bawah glTexCoord2f(0.0, 0.0); glVertex3f(x1,y1,z2); glTexCoord2f(1.0, 0.0); glVertex3f(x2,y1,z2); glTexCoord2f(1.0, 1.0); glVertex3f(x2,y1,z1); glTexCoord2f(0.0, 1.0); glVertex3f(x1,y1,z1); //samping kiri glTexCoord2f(0.0, 0.0); glVertex3f(x1,y1,z1); glTexCoord2f(1.0, 0.0); glVertex3f(x1,y2,z1); glTexCoord2f(1.0, 1.0); glVertex3f(x1,y2,z2); glTexCoord2f(0.0, 1.0); glVertex3f(x1,y1,z2); //samping kanan glTexCoord2f(0.0, 0.0); glVertex3f(x2,y1,z1); glTexCoord2f(1.0, 0.0); glVertex3f(x2,y2,z1); glTexCoord2f(1.0, 1.0); glVertex3f(x2,y2,z2); glTexCoord2f(0.0, 1.0); glVertex3f(x2,y1,z2); } //Controler void keyboard(unsigned char key, int x, int y) { switch (key) { //putar arah jarum jam (menambah derajat putaran) case 'q': ypos=ypos+5; if (ypos>360) ypos=0; glutPostRedisplay(); break; //putar berlawanan arah jarum jam (mengurangi derajat putaran) case 'e': ypos=ypos-5; if (ypos>360) ypos=0; glutPostRedisplay(); break; //vertikal bawah (menambah koordinat y) case 'f': b = b + 1; glutPostRedisplay(); break; //vertikal atas (mengurangi koordinat y) case 'r': b = b - 1; glutPostRedisplay(); break; //horisontal kiri (mengurangi koordinat x) case 'a': a = a + 1; glutPostRedisplay(); break; //horisontal kanan (menambah koordinat x) case 'd': a = a - 1; glutPostRedisplay(); break; //memperbesar objek (menambah koordinat z) case 'w': c = c + 1; glutPostRedisplay(); break; //memperkecil abjek(mengurangi koordinat z) case 's': c = c - 1; glutPostRedisplay(); break; //buka pintu case 'p': pintu=pintu-5; if (pintu<-45) pintu=-45; glutPostRedisplay(); break; //tutup pintu case 'o': pintu=pintu+5; if (pintu>0) pintu=0; glutPostRedisplay(); break; //buka laptop case 'l': laptop=laptop-5; if (laptop<-60) laptop=-60; glutPostRedisplay(); break; //tutup laptop case 'k': laptop=laptop+5; if (laptop>90) laptop=90; glutPostRedisplay(); break; //buka laci case '.': laci=laci+0.1; if (laci>2) laci=2; glutPostRedisplay(); break; //tutup laci case ',': laci=laci-0.1; if (laci<0) laci=0; glutPostRedisplay(); break; //buka kursi case 'm': kursi=kursi+0.1; if (kursi>2.5) kursi=2.5; glutPostRedisplay(); break; //tutup kursi case 'n': kursi=kursi-0.1; if (kursi<-4) kursi=-4; glutPostRedisplay(); break; //putar arah jarum jam (menambah derajat putaran) case 'z': xpos=xpos+5; if (xpos>360) xpos=0; glutPostRedisplay(); break; //putar berlawanan arah jarum jam (mengurangi derajat putaran) case 'c': xpos=xpos-5; if (xpos>360) xpos=0; glutPostRedisplay(); } } void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); glEnable(GL_DEPTH_TEST); //perpindahan glTranslatef(a,b,c); //putaran glRotatef(xpos,1,0,0); glRotatef(ypos,0,1,0); glRotatef(zpos,0,0,1); //lantai glPushMatrix(); glBegin(GL_QUADS); glColor3f(0.3f,0.3f,0.3f); kotak(0,0,18,25,0.5,0); glEnd(); glPopMatrix(); //dinding kiri glPushMatrix(); glBegin(GL_QUADS); glColor3ub(255, 125, 185); kotak(0,0.5,18,0.5,10,0); glEnd(); glPopMatrix(); //dinding belakang glPushMatrix(); glBegin(GL_QUADS); glColor3ub(5, 140, 250); kotak(6,0.5,0.5,25,10,0.0); glEnd(); glPopMatrix(); //meja //atas glPushMatrix(); glBegin(GL_QUADS); glColor3ub(255, 234, 166); kotak(21,3.5,16,24.8,3.8,9.5); //kaki kanan belakang kotak(24.3,0.5,15.9,24.6,3.6,15.6); //kaki kiri belakang kotak(24.3,0.5,9.9,24.6,3.6,9.6); //kaki kiri depan kotak(21.1,0.5,9.9,21.4,3.6,9.6); //kaki kanan depan kotak(21.1,0.5,15.9,21.4,3.6,15.6); glEnd(); glPopMatrix(); //pc glPushMatrix(); glBegin(GL_QUADS); glColor3f(0.0f,0.0f,0.0f); //keyboard kotak(23.3,3.8,15.0,22,4,13.0); glEnd(); glPopMatrix(); //Monitor lcd glPushMatrix(); glTranslatef(23.3,3.8,13.0); glRotatef(laptop, 0.0, 0.0, 0.1); glBegin(GL_QUADS); glColor3f(0.0f,0.0f,0.0f); //Monitor lcd kotak(0,0,0,0.1,1.5,2.0); glEnd(); glPopMatrix(); //layar lcd glPushMatrix(); glTranslatef(23.29,3.8,13.0); glRotatef(laptop, 0.0, 0.0, 0.1); glBegin(GL_QUADS); glColor3f(1.1f,1.0f,1.0f); kotak(0,0.1,0.1,0.01,1.4,1.9); glEnd(); glPopMatrix(); //kursi //alas glPushMatrix(); glTranslatef(kursi,0,0); glBegin(GL_QUADS); glColor3f(0.2f,0.1f,0.1f); kotak(18,2.2,15.5,20.8,2.5,12.8); //kiri depan kotak(20.5,0.5,15.5,20.8,2.5,15.2); //kanan depan kotak(20.5,0.5,13.1,20.8,2.5,12.8); //kanan belakang kotak(18,0.5,13.1,18.3,5.2,12.8); //kiri belakang kotak(18,0.5,15.5,18.3,5.2,15.2); //senderan kotak(18,3.8,15.5,18.2,4.9,12.8); glEnd(); glPopMatrix(); //kasur //rangka alas glPushMatrix(); glBegin(GL_QUADS); glColor3f(0.6f,0.1f,0.1f); kotak(1.1,1.4,15.5,13.4,3,8.7); //kaki 1 kotak(0.5,0.5,15.6,1.2,6,14.9); //kaki 2 kotak(0.5,0.5,9.4,1.1,6,8.7); //kaki 3 kotak(12.9,0.5,9.4,13.6,5,8.7); //kaki 4 kotak(12.9,0.5,15.6,13.6,5,14.9); //penyangga depan kotak(0.6,3,15.4,1,5.1,8.9); //penyangga belakang kotak(12.9,1.4,15.4,13.6,4.5,8.9); glEnd(); glPopMatrix(); //kasurnya glPushMatrix(); glBegin(GL_QUADS); glColor3f(1.1f,1.1f,1.1f); kotak(1.1,2.5,15.4,13.4,3.5,9); //bantal glColor3f(0.6f,0.6f,0.6f); kotak(1.3,3.5,14.4,4,4,10); //selimut glColor3f(0.1f,1.1f,0.1f); kotak(5,3.5,15.4,13.4,3.7,9); //kanan kotak(5,3,9,13.4,3.6,8.9); //kiri kotak(5,3,15.5,13.4,3.6,15.4); glEnd(); glPopMatrix(); //Pintu glPushMatrix(); glRotatef(pintu, 0.0, 1.0, 0.0); glBegin(GL_QUADS); glColor3f(0.1f,0.0f,0.0f); kotak(0.5,0.5,0.5,6,10,0); glEnd(); glPopMatrix(); //gagang pintu glPushMatrix(); glRotatef(pintu, 0.0, 1.0, 0.0); glBegin(GL_QUADS); //gagang pintu glColor3f(1.0f,1.0f,1.0f); kotak(5.2,5.8,0.7,5.5,6,0.5); kotak(4.5,5.8,0.9,5.6,6,0.7); //alas gagang kotak(5.1,6.5,0.55,5.7,5,0.5); glColor3f(0.0f,0.0f,0.0f); kotak(5.35,5.2,0.56,5.45,5.5,0.55); glEnd(); glPopMatrix(); //gagang pintu belakang glPushMatrix(); glRotatef(pintu, 0.0, 1.0, 0.0); glBegin(GL_QUADS); //gagang pintu glColor3f(1.0f,1.0f,1.0f); kotak(5.2,5.8,0,5.5,6,-0.2); kotak(4.5,5.8,-0.2,5.6,6,-0.4); //alas gagang kotak(5.1,6.5,0,5.7,5,-0.05); glColor3f(0.0f,0.0f,0.0f); kotak(5.35,5.2,-0.05,5.45,5.5,-0.06); glEnd(); glPopMatrix(); //saklar glPushMatrix(); glBegin(GL_QUADS); glColor3f(1.1f,1.0f,1.0f); kotak(6.5,6.5,0.6,7.5,7.5,0.5); glColor3f(0.1f,0.0f,0.0f); kotak(6.65,6.7,0.65,6.92,7.3,0.6); kotak(7.08,6.7,0.65,7.35,7.3,0.6); glEnd(); glPopMatrix(); //lukisan atas kasur glPushMatrix(); glBindTexture(GL_TEXTURE_2D, texture[9]); glBegin(GL_QUADS); glColor3f(1.0f,1.0f,1.0f); kotak(0.6,6.6,15.5,0.61,8.8,8.9); glColor3f(0.0f,0.0f,0.0f); kotak(0.5,6.4,15.7,0.6,9,8.7); glEnd(); glPopMatrix(); //lemari kecil glPushMatrix(); glBegin(GL_QUADS); glColor3ub(209, 129, 67); kotak(0.5,0.8,8.5,4,4.5,4.7); //kaki kiri kotak(0.5,0.5,8.5,4.3,4.9,8.3); //kaki kanan kotak(0.5,0.5,4.5,4.3,4.9,4.7); glEnd(); glPopMatrix(); //pegangan glPushMatrix(); glTranslatef(laci,0,0); glBegin(GL_QUADS); glColor3ub(209, 129, 67); kotak(4.2,2.1,6.9,4.3,2.3,6.2); kotak(4.2,3.9,6.9,4.3,4.1,6.2); glEnd(); glPopMatrix(); //lacinya glPushMatrix(); glTranslatef(laci,0,0); glBegin(GL_QUADS); glColor3f(0.3f,0.1f,0.1f); kotak(1.9,1.0,8.2,4.2,2.5,4.9); kotak(1.9,2.7,8.2,4.2,4.3,4.9); glEnd(); glPopMatrix(); //Rak Dinding glPushMatrix(); glBegin(GL_QUADS); glColor3ub(255, 8, 70); //bawah kotak(10,6,1.5,18,6.2,0.5); //atas kotak(10,7,1.5,18,7.2,0.5); glColor3ub(82, 8, 255); //kanan kotak(15.0,5.0,1.5,15.2,8.5,0.5); //kiri kotak(13,5.0,1.5,13.2,8.5,0.5); glEnd(); glPopMatrix(); glFlush(); glutSwapBuffers(); } void reshape (int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, 1.0 * (GLfloat) w / (GLfloat) h, 1.0, 40.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0, 0.0, 0.0); gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (800, 600); glutInitWindowPosition (20, 75); glutCreateWindow ("Interior rumah q"); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }




Thursday 6 January 2022

Projek OpenGL C++ transportasi Umum (pesawat terbang, mobil, kapal laut, rumah, pohon dan awan) OpenGL C++

 

Projek OpenGL C++ animasi transportasi

Pada projek OpenGL c++ yang kita buat kali ini adalah projek openGL Transportasi. dalam projek ini disekenariokan bahwa membuat tansportasi umum berjalan dipedesaan, ada laut dan kapal yang berjalan. rumah pedesaan dengan pohon-pohonannya , pesawat diatas awan bersama burung-burung berterbangan, serta kendaraan yang lalu lalang di jalan raya. 

Kemudian projek ini juga akan memperkirakan waktu yang terjadi didalamnya ada waktu siang cerah, hujan rintik-rintik serta cuaca malam hari yang menyeramkan. Untuk merubah waktu dari siang ke malam, malam ke hujan dan lain sebagainya dapat menggunakan tombol dibawah ini.

  1. n = untuk suasana malam hari.
  2. r = untuk suasana ketika sedang hujan.
  3. d = untuk suasana menjadi cerah kembali. 

Jika anda penasaran dengan apa yang akan anda buat silahkan ikuti langkah-langkah dibawah ini.

Persiapan Membuat Projek OpenGL dengan Codeblock

Untuk memulai membuat projek open GL ini anda harus menseting beberapa komponen kedalam codeblock dan ketika sudah selesai menseting semuanya saatnya membuat projeknya. untul langkah-langkah persiapannya dapat melakukan beberapa langkah-langkah dibawah ini.

  1. Open GL download disini :View openGL
  2. CodeBlock setting dengan openGL caranya lihat disini: view
  3. buka codeblock dan buat projek baru caranya dapat dilihat disini : view
  4. copy semua sourcode yang tersedia di blog ini.
silahkan copy contoh program dibawah ini ke projek yang anda buat. adapun sourcode yang akan anda coba adalah sebagai berikut.

  

#include <iostream>
#include <cstdlib> #include <cmath> #include <fstream> #include <windows.h> #include<GL/gl.h> #include <GL/glut.h> #define PI 3.14159265 #define CTRL_COUNT 100 int ctrlPointsCount; int ctrlPointsX[CTRL_COUNT], ctrlPointsY[CTRL_COUNT]; int X1[3]= {20,25,20}, Y1[3]= {5,24,38}; int X2[3]= {0,-5,0}, Y2[3]= {1,static_cast<int>(0.5),0}; int X3[3]= {22,0,18}, Y3[3]= {30,38,45}; int X4[3]= {28,50,32}, Y4[3]= {30,38,45}; int X5[3]= {18,25,32}, Y5[3]= {45,60,45}; double var = -6; double rainX = -6; double rainY; bool Rain = false; bool night = false; //colors variables double sky[3] = {19,190,242}; double cloud[3] = {255,255,255}; double sun[3] = {219,230,21}; double tree[3] = {34, 139, 34}; double bush[3] = {127,162,12}; double soil[3] = {199,192,141}; double cowFood[3] = {235,222,164}; double water[3] = {152,222,245}; double building3[3] = {102,102,102}; double building2[3] = {217,217,50}; double building1Box2[3] = {237,237,187}; double building1Box3[3] = {30,186,79}; using namespace std; double train = 0; double car1 = 0; double car2 = 0; double fly = 0; double ship = 0; double ship2 = 0; double rain = 0; GLuint LoadTexture(const char * filename) { GLuint texture; int width, height; unsigned char * data; FILE * file; file = fopen(filename, "Rb"); if (file == NULL) return 0; width = 1024; height = 512; data = (unsigned char *)malloc(width * height * 3); fread(data, width * height * 3, 1, file); fclose(file); for (int i = 0; i < width * height; ++i) { int index = i * 3; unsigned char B, R; B = data[index]; R = data[index + 2]; data[index] = R; data[index + 2] = B; } glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, width, height, GL_RGB, GL_UNSIGNED_BYTE, data); free(data); return texture; } void draw_cylinder(GLfloat radius, GLfloat height, GLubyte R, GLubyte G, GLubyte B) { GLfloat x = 0.0; GLfloat y = 0.0; GLfloat angle = 0.0; GLfloat angle_stepsize = 0.1; /** Draw the tube */ glColor3ub(R,G,B); glBegin(GL_QUAD_STRIP); angle = 0.0; while( angle < 2*3.1416 ) { x = radius * cos(angle); y = radius * sin(angle); glVertex3f(x, y, height); glVertex3f(x, y, 0.0); angle = angle + angle_stepsize; } glVertex3f(radius, 0.0, height); glVertex3f(radius, 0.0, 0.0); glEnd(); /** Draw the circle on top of cylinder */ glColor3ub(R,G,B); glBegin(GL_POLYGON); angle = 0.0; while( angle < 2*3.1416 ) { x = radius * cos(angle); y = radius * sin(angle); glVertex3f(x, y, height); angle = angle + angle_stepsize; } glVertex3f(radius, 0.0, height); glEnd(); } void drawCloud() { glutSolidSphere(0.4,40,40); glScalef(1,0.4,1); glTranslatef(-0.1,0,0); glBegin(GL_POLYGON); glColor3ub(cloud[0], cloud[1], cloud[2]); glutSolidSphere(0.7,40,40); } void drawTree() { //Tree glColor3ub(tree[0], tree[1], tree[2]); glPushMatrix(); glutSolidSphere(0.25,40,40); glPopMatrix(); glPushMatrix(); glTranslatef(0.15,-0.15,0); glutSolidSphere(0.25,40,40); glPopMatrix(); glPushMatrix(); glTranslatef(-0.15,-0.15,0); glutSolidSphere(0.25,40,40); glPopMatrix(); glPushMatrix(); glTranslatef(0,-0.3,0); glRotatef(90,1,0,0); draw_cylinder(0.04,0.7,137, 94, 41); glPopMatrix(); } void drawBush() { glBegin(GL_TRIANGLES); glColor3ub(bush[0],bush[1],bush[2]); glVertex3f(0,0,0); glVertex3f(0.3,0,0); glVertex3f(0.4,0.6,0); glEnd(); glBegin(GL_TRIANGLES); glColor3ub(bush[0],bush[1],bush[2]); glVertex3f(0.2,0,0); glVertex3f(0.5,0,0); glVertex3f(0.55,0.4,0); glEnd(); glBegin(GL_TRIANGLES); glColor3ub(bush[0],bush[1],bush[2]); glVertex3f(-0.1,0,0); glVertex3f(0.1,0,0); glVertex3f(0.2,0.5,0); glEnd(); } void DrawHouse() { //--------------Upper Triangle----------------- glPushMatrix(); glBegin(GL_TRIANGLES); glColor3f(0.392, 0.694, 1); glVertex3f(0, 0.5,1); glVertex3f(-0.5, 0,1); glVertex3f(0.5, 0,1); glEnd(); glFlush(); glPopMatrix(); //--------------Main Rectangle----------------- glPushMatrix(); glTranslatef(0,-1,0); glColor3f(0.502, 0.502, 0.502); glBegin(GL_QUADS); glVertex3f(-0.5,0,1); glVertex3f(0.5,0,1); glVertex3f(0.5,1,1); glVertex3f(-0.5,1,1); glEnd(); glFlush(); glPopMatrix(); //--------------Door----------------- glPushMatrix(); glTranslatef(0.79,-0.75,0); glColor3f(0.863, 0.863, 0.863); glBegin(GL_QUADS); glVertex3f(-0.5,0,1.5); glVertex3f(-0.3,0,1.5); glVertex3f(-0.3,0.4,1.5); glVertex3f(-0.5,0.4,1.5); glEnd(); glFlush(); glPopMatrix(); //window glPushMatrix(); glTranslatef(0.75,-0.25,0); glScalef(0.4,0.4,1); glColor3f(0.863, 0.863, 0.863); glBegin(GL_QUADS); glVertex3f(-0.5,0,1.5); glVertex3f(0,0,1.5); glVertex3f(0,0.5,1.5); glVertex3f(-0.5,0.5,1.5); glEnd(); glFlush(); glPopMatrix(); //window glPushMatrix(); glTranslatef(0.25,-0.25,0); glScalef(0.4,0.4,1); glColor3f(0.863, 0.863, 0.863); glBegin(GL_QUADS); glVertex3f(-0.5,0,1.5); glVertex3f(0,0,1.5); glVertex3f(0,0.5,1.5); glVertex3f(-0.5,0.5,1.5); glEnd(); glPopMatrix(); //--------------Chimney----------------- glPushMatrix(); glColor3f(0.502, 0.000, 0.000); glBegin(GL_QUADS); glVertex3f(-0.5,0,1); glVertex3f(-0.35,0,1); glVertex3f(-0.35,0.3,1); glVertex3f(-0.5,0.3,1); glEnd(); glPopMatrix(); //--------------------------------------------- } void DrawHouse2() { //--------------Upper Triangle----------------- glPushMatrix(); glBegin(GL_TRIANGLES); glColor3ub(130, 85, 13); glVertex3f(0, 0.5,1); glVertex3f(-0.5, 0,1); glVertex3f(0.5, 0,1); glEnd(); glFlush(); glPopMatrix(); //--------------Main Rectangle----------------- glPushMatrix(); glTranslatef(0,-1,0); glColor3ub(104, 120, 222); glBegin(GL_QUADS); glVertex3f(-0.5,0,1); glVertex3f(0.5,0,1); glVertex3f(0.5,1,1); glVertex3f(-0.5,1,1); glEnd(); glFlush(); glPopMatrix(); //--------------Door----------------- glPushMatrix(); glTranslatef(0.55,-0.69,0); glColor3f(0.863, 0.863, 0.863); glBegin(GL_QUADS); glVertex3f(-0.5,0,1.5); glVertex3f(-0.3,0,1.5); glVertex3f(-0.3,0.4,1.5); glVertex3f(-0.5,0.4,1.5); glEnd(); glFlush(); glPopMatrix(); //window glPushMatrix(); glTranslatef(0.48,-0.15,0); glScalef(0.4,0.4,1); glColor3f(0.863, 0.863, 0.863); glBegin(GL_QUADS); glVertex3f(-0.5,0,1.5); glVertex3f(0,0,1.5); glVertex3f(0,0.5,1.5); glVertex3f(-0.5,0.5,1.5); glEnd(); glFlush(); glPopMatrix(); //window glPushMatrix(); glTranslatef(0,-0.15,0); glScalef(0.4,0.4,1); glColor3f(0.863, 0.863, 0.863); glBegin(GL_QUADS); glVertex3f(-0.5,0,1.5); glVertex3f(0,0,1.5); glVertex3f(0,0.5,1.5); glVertex3f(-0.5,0.5,1.5); glEnd(); glPopMatrix(); //--------------Chimney----------------- glPushMatrix(); glColor3f(0.502, 0.000, 0.000); glBegin(GL_QUADS); glVertex3f(-0.5,0,1); glVertex3f(-0.35,0,1); glVertex3f(-0.35,0.3,1); glVertex3f(-0.5,0.3,1); glEnd(); glPopMatrix(); //--------------------------------------------- } void drawTrain() { //body glPushMatrix(); glTranslatef(0, -1, 0); glColor3f(1, 0, 0); glScalef(1.5, 0.8, 0.1); glutSolidCube(1.3); glPopMatrix(); //smoke place glPushMatrix(); glColor3f(0, 0, 1); glTranslatef(-0.8, -0.28, 1); glScalef(0.9, 1.3, 0.01); glutSolidCube(0.35); glPopMatrix(); //top of smoke place glPushMatrix(); glTranslatef(-0.81, 0.06, 1); glScalef(1, 1, 0.01); glColor3f(0, 1, 1); glRotatef(90, 1, 0, 0); glutSolidCone(0.26, 0.3, 20, 20); glPopMatrix(); //top body glPushMatrix(); glTranslatef(0.28, -0.2, 0); glScalef(1.6, 1, 0.1); glColor3f(0.5, 1, 0.1); glutSolidCube(0.8); glPopMatrix(); //window 1 glPushMatrix(); glColor3f(1, 0, 0); glTranslatef(0, -0.12, 1); glutSolidCube(0.4); glPopMatrix(); //window 2 glPushMatrix(); glColor3f(1, 0, 0); glTranslatef(0.5, -0.12, 1); glutSolidCube(0.4); glPopMatrix(); //wheel 1 glPushMatrix(); glColor3f(0, 0, 1); glTranslatef(0.5, -1.4, 1); glutSolidTorus(0.1, 0.2, 20, 20); glPopMatrix(); //wheel 2 glPushMatrix(); glColor3f(0, 0, 1); glTranslatef(-0.5, -1.4, 1); glutSolidTorus(0.1, 0.2, 20, 20); glPopMatrix(); //body to bogy connector glPushMatrix(); glTranslatef(1.1, -1.1, 0); glScalef(1, 3, 0.01); glutSolidCube(0.25); glPopMatrix(); //bogy glPushMatrix(); glColor3f(0.343, 0.565, 1); glScalef(1.3, 0.75, 0.01); glTranslatef(1.65, -1.45, 0); glutSolidCube(1.5); glPopMatrix(); glPushMatrix(); glTranslatef(0.05, 0, 0); //bogy window 1 glPushMatrix(); glTranslatef(1.5, -0.9, 1); glScalef(1, 1, 0.01); glColor3f(0.4, 1, 1); glutSolidCube(0.4); glPopMatrix(); //bogy window 2 glPushMatrix(); glTranslatef(2.0, -0.9, 1); glScalef(1, 1, 0.01); glColor3f(0.4, 1, 1); glutSolidCube(0.4); glPopMatrix(); //bogy window 2 glPushMatrix(); glTranslatef(2.5, -0.9, 1); glScalef(1, 1, 0.01); glColor3f(0.4, 1, 1); glutSolidCube(0.4); glPopMatrix(); glPopMatrix(); //bogy wheel glPushMatrix(); glTranslatef(1.5, -1.55, 1); glScalef(0.7, 0.7, 0.01); glColor3f(0, 0, 1); glutSolidTorus(0.1, 0.2, 20, 20); glPopMatrix(); //bogy wheel glPushMatrix(); glTranslatef(2.6, -1.55, 1); glScalef(0.7, 0.7, 0.01); glColor3f(0, 0, 1); glutSolidTorus(0.1, 0.2, 20, 20); glPopMatrix(); //smoke glPushMatrix(); glTranslatef(-0.65, 0.2, 1); glScalef(1, 1, 0.01); glColor3f(1, 1, 1); glutSolidSphere(0.1, 20, 20); glPopMatrix(); //smoke glPushMatrix(); glTranslatef(-0.4, 0.5, 1); glScalef(1.4, 1.4, 0.01); glColor3f(1, 1, 1); glutSolidSphere(0.1, 20, 20); glPopMatrix(); //smoke glPushMatrix(); glTranslatef(-0.1, 0.8, 1); glScalef(2, 2, 0.01); glColor3f(1, 1, 1); glutSolidSphere(0.1, 20, 20); glPopMatrix(); } void building() { //Bottom box 1 glColor3ub(building3[0],building3[1],building3[2]); glBegin(GL_POLYGON); glVertex2i(100,50); glVertex2i(100,250); glVertex2i(250,250); glVertex2i(250, 50); glEnd(); //Box padding - glColor3f(0.827451, 0.827451, 0.827451); glBegin(GL_POLYGON); glVertex2i(100,250); glVertex2i(100,260); glVertex2i(250,260); glVertex2i(250,250); glEnd(); //Bottom box 2 glColor3ub(building1Box2[0],building1Box2[1],building1Box2[2]); glBegin(GL_POLYGON); glVertex2i(100,260); glVertex2i(100,370); glVertex2i(250,370); glVertex2i(250,260); glEnd(); //Box padding - glColor3f(0.827451, 0.827451, 0.827451); glBegin(GL_POLYGON); glVertex2i(100,370); glVertex2i(100,380); glVertex2i(250,380); glVertex2i(250,370); glEnd(); //Bottom box 3 //Top glColor3ub(building1Box3[0],building1Box3[1],building1Box3[2]); glBegin(GL_POLYGON); glVertex2i(100,380); glVertex2i(100,500); glVertex2i(250,500); glVertex2i(250,380); glEnd(); //Coloumn 2 //Bottom box 1 from bottom //Top glColor3ub(building2[0], building2[1], building2[2]); glBegin(GL_POLYGON); glVertex2i(250,50); glVertex2i(250,525); glVertex2i(425,525); glVertex2i(425,50); glEnd(); //Coloumn 3 //Bottom box 1 from bottom //Top glColor3ub(building3[0], building3[1], building3[2]); glBegin(GL_POLYGON); glVertex2i(425,50); glVertex2i(425,550); glVertex2i(525,550); glVertex2i(525,50); glEnd(); //Shadow //glColor3f(0.827451, 0.827451, 0.827451); glColor3f(0.517647, 0.517647, 0.517647); glBegin(GL_POLYGON); glVertex2i(100,50); glVertex2i(100,500); glVertex2i(50,400); glVertex2i(50,75); glEnd(); //shadow lines //Box padding - glColor3f(0.827451, 0.827451, 0.827451); glBegin(GL_POLYGON); glVertex2i(100,370); glVertex2i(100,380); glVertex2i(50,300); glVertex2i(50,290); glEnd(); //shadow lines //Box padding - glColor3f(0.827451, 0.827451, 0.827451); glBegin(GL_POLYGON); glVertex2i(100,250); glVertex2i(100,260); glVertex2i(50,190); glVertex2i(50,180); glEnd(); //Shadow triangle glColor3f(0.517647, 0.517647, 0.517647); glBegin(GL_TRIANGLES); glVertex2i(250, 525); glVertex2i(250, 500); glVertex2i(240, 500); glEnd(); //Shadow triangle glColor3f(0.517647, 0.517647, 0.517647); glBegin(GL_TRIANGLES); glVertex2i(425, 525); glVertex2i(425, 550); glVertex2i(415, 525); glEnd(); glFlush(); } void bezierCoefficients(int n,int *c) { int k,i; for(k=0; k<=n; k++) { c[k]=1; for(i=n; i>=k+1; i--) c[k]*=i; for(i=n-k; i>=2; i--) c[k]/=i; } } void drawCurve() { glPushMatrix(); int cp[4][2]= {{10,10},{100,200},{200,50},{300,300}}; int c[4],k,n=3; float x,y,u,blend; bezierCoefficients(n,c); glColor3f(1.0,0.0,0.0); glLineWidth(20.0); glBegin(GL_LINE_STRIP); for(u=0; u<1.0; u+=0.01) { x=0; y=0; for(k=0; k<4; k++) { blend=c[k]*pow(u,k)*pow(1-u,n-k); x+=cp[k][0]*blend; y+=cp[k][1]*blend; } glVertex2f(x,y); } glEnd(); glPopMatrix(); } void drawBoat() { //glScaled(20,20,0); glColor3f(0,0,0); glBegin(GL_POLYGON); glVertex2f(3.5,5.5); glVertex2f(3.5,8.5); glVertex2f(19.5,8.5); glVertex2f(19.5,5.5); glEnd(); glColor3f(0.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(1,5.5); glVertex2f(4,1); glVertex2f(19,1); glVertex2f(21.5,5.5); glEnd(); glColor3f(0.7,0.4,0.2); glBegin(GL_POLYGON); glVertex2f(4,5.5); glVertex2f(4,8); glVertex2f(5,8); glVertex2f(5,5.5); glEnd(); glColor3f(0.9,0.9,0.9); glBegin(GL_POLYGON); glVertex2f(7,7.5); glVertex2f(7,8); glVertex2f(10,8); glVertex2f(10,7.5); glEnd(); glBegin(GL_POLYGON); glVertex2f(11.5,7.5); glVertex2f(11.5,8); glVertex2f(15,8); glVertex2f(15,7.5); glEnd(); glBegin(GL_POLYGON); glVertex2f(16,7.5); glVertex2f(16,8); glVertex2f(19,8); glVertex2f(19,7.5); glEnd(); glColor3f(0.5,0.5,0.5); glBegin(GL_POLYGON); glVertex2f(4.5,8.5); glVertex2f(4.5,10); glVertex2f(18.5,10); glVertex2f(18.5,8.5); glEnd(); glColor3f(0.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(5.5,10); glVertex2f(5.5,12.9); glVertex2f(7,12.9); glVertex2f(7,10); glEnd(); glColor3f(0.9,0.5,0.2); glBegin(GL_POLYGON); glVertex2f(5.5,12.9); glVertex2f(5.5,13.5); glVertex2f(7,13.5); glVertex2f(7,12.9); glEnd(); glColor3f(0.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(8.5,10); glVertex2f(8.5,12.9); glVertex2f(10,12.9); glVertex2f(10,10); glEnd(); glColor3f(0.9,0.5,0.2); glBegin(GL_POLYGON); glVertex2f(8.5,12.9); glVertex2f(8.5,13.5); glVertex2f(10,13.5); glVertex2f(10,12.9); glEnd(); glColor3f(0.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(11.5,10); glVertex2f(11.5,12.9); glVertex2f(13,12.9); glVertex2f(13,10); glEnd(); glColor3f(0.9,0.5,0.2); glBegin(GL_POLYGON); glVertex2f(11.5,12.9); glVertex2f(11.5,13.5); glVertex2f(13,13.5); glVertex2f(13,12.9); glEnd(); glColor3f(0.0,0.0,0.0); glBegin(GL_POLYGON); glVertex2f(14.5,10); glVertex2f(14.5,12.9); glVertex2f(16,12.9); glVertex2f(16,10); glEnd(); glColor3f(0.9,0.5,0.2); glBegin(GL_POLYGON); glVertex2f(14.5,12.9); glVertex2f(14.5,13.5); glVertex2f(16,13.5); glVertex2f(16,12.9); glEnd(); glColor3f(0.0,0.0,0.0); glBegin(GL_LINE_LOOP); glVertex2f(1.5,5.5); glVertex2f(1.5,6.5); glVertex2f(2,6.2); glVertex2f(3,6.2); glVertex2f(3.5,6.5); glVertex2f(3.5,5.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(3.5,5.5); glVertex2f(3.5,6.5); glVertex2f(4,6.2); glVertex2f(5,6.2); glVertex2f(5.5,6.5); glVertex2f(5.5,5.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(5.5,5.5); glVertex2f(5.5,6.5); glVertex2f(6,6.2); glVertex2f(7,6.2); glVertex2f(7.5,6.5); glVertex2f(7.5,5.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(7.5,5.5); glVertex2f(7.5,6.5); glVertex2f(8,6.2); glVertex2f(9,6.2); glVertex2f(9.5,6.5); glVertex2f(9.5,5.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(9.5,5.5); glVertex2f(9.5,6.5); glVertex2f(10,6.2); glVertex2f(11,6.2); glVertex2f(11.5,6.5); glVertex2f(11.5,5.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(11.5,5.5); glVertex2f(11.5,6.5); glVertex2f(12,6.2); glVertex2f(13,6.2); glVertex2f(13.5,6.5); glVertex2f(13.5,5.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(13.5,5.5); glVertex2f(13.5,6.5); glVertex2f(14,6.2); glVertex2f(15,6.2); glVertex2f(15.5,6.5); glVertex2f(15.5,5.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(15.5,5.5); glVertex2f(15.5,6.5); glVertex2f(16,6.2); glVertex2f(17,6.2); glVertex2f(17.5,6.5); glVertex2f(17.5,5.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(17.5,5.5); glVertex2f(17.5,6.5); glVertex2f(18,6.2); glVertex2f(19,6.2); glVertex2f(19.5,6.5); glVertex2f(19.5,5.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(19.5,5.5); glVertex2f(19.5,6.5); glVertex2f(20,6.2); glVertex2f(20.5,6.2); glVertex2f(21,6.5); glVertex2f(21,5.5); glEnd(); glColor3f(1.0,1.0,1.0); glBegin(GL_LINE_LOOP); glVertex2f(4.5,3.5); glVertex2f(4.5,4.5); glVertex2f(5.5,4.5); glVertex2f(5.5,3.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(7,3.5); glVertex2f(7,4.5); glVertex2f(8,4.5); glVertex2f(8,3.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(9.5,3.5); glVertex2f(9.5,4.5); glVertex2f(10.5,4.5); glVertex2f(10.5,3.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(12,3.5); glVertex2f(12,4.5); glVertex2f(13,4.5); glVertex2f(13,3.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(14.5,3.5); glVertex2f(14.5,4.5); glVertex2f(15.5,4.5); glVertex2f(15.5,3.5); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(17,3.5); glVertex2f(17,4.5); glVertex2f(18,4.5); glVertex2f(18,3.5); glEnd(); glColor3f(0.0,0.0,0.0); glBegin(GL_LINE_LOOP); glVertex2f(5,10); glVertex2f(5,11); glVertex2f(5.5,10.8); glVertex2f(6.5,10.8); glVertex2f(7,11); glVertex2f(7,10); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(7,10); glVertex2f(7,11); glVertex2f(7.5,10.8); glVertex2f(8.5,10.8); glVertex2f(9,11); glVertex2f(9,10); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(9,10); glVertex2f(9,11); glVertex2f(9.5,10.8); glVertex2f(10.5,10.8); glVertex2f(11,11); glVertex2f(11,10); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(11,10); glVertex2f(11,11); glVertex2f(11.5,10.8); glVertex2f(12.5,10.8); glVertex2f(13,11); glVertex2f(13,10); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(13,10); glVertex2f(13,11); glVertex2f(13.5,10.8); glVertex2f(14.5,10.8); glVertex2f(15,11); glVertex2f(15,10); glEnd(); glBegin(GL_LINE_LOOP); glVertex2f(15,10); glVertex2f(15,11); glVertex2f(15.5,10.8); glVertex2f(16.5,10.8); glVertex2f(17,11); glVertex2f(17,10); glEnd(); } void drawEllipse(void) { GLint i; GLfloat xradius=3.5; GLfloat yradius=2; const GLfloat DEG2RAD = 3.14159/180; glColor3ub(23,145,62); glBegin(GL_POLYGON); for (i=0; i < 360; i++) { float degInRad = i*DEG2RAD; glVertex2f ( cos (degInRad) *xradius, sin (degInRad) *yradius); } glEnd(); } void drawRedEllipse(void) { GLint i; GLfloat xradius=3.5; GLfloat yradius=2; const GLfloat DEG2RAD = 3.14159/180; glColor3ub(242,46,49); glBegin(GL_POLYGON); for (i=0; i < 360; i++) { float degInRad = i*DEG2RAD; glVertex2f ( cos (degInRad) *xradius, sin (degInRad) *yradius); } glEnd(); } void drawFlower() { glPushMatrix() ; glTranslatef(5,5,1) ; glRotatef(90,0,0,1) ; glColor3ub(23,145,62); drawEllipse() ; glPopMatrix() ; //right petal glPushMatrix() ; glTranslatef(1.25, 7.5,1); glRotatef(20,0,0,1) ; glScalef(1.1,1.1, 0.0); glColor3ub(23,145,62); drawEllipse() ; glPopMatrix() ; //left petal glPushMatrix() ; glTranslatef(8.7, 7.5,1) ; glRotatef(160,0,0,1) ; glScalef(1.1,1.1, 0.0); glColor3ub(23,145,62); drawEllipse() ; glPopMatrix() ; } void drawRedFlower() { glPushMatrix() ; glTranslatef(5,5,1) ; glRotatef(90,0,0,1) ; glScalef(1.1,1.1, 0.0); glColor3ub(23,145,62); drawRedEllipse() ; glPopMatrix() ; //right petal glPushMatrix() ; glTranslatef(1.25, 7.5,1); glRotatef(20,0,0,1) ; glScalef(1.1,1.1, 0.0); glColor3ub(23,145,62); drawRedEllipse() ; glPopMatrix() ; //left petal glPushMatrix() ; glTranslatef(8.7, 7.5,1) ; glRotatef(160,0,0,1) ; glScalef(1.1,1.1, 0.0); glColor3ub(23,145,62); drawRedEllipse() ; glPopMatrix() ; } void dp(GLint cx,GLint cy) { glColor3ub(237,52,52); glBegin(GL_POINTS); glVertex2i(cx,cy); glEnd(); } void pix(GLint h,GLint k,GLint x,GLint y) { glColor3ub(237,52,52); dp(x+h,y+k); dp(x+h,-y+k); dp(-x+h,-y+k); dp(-x+h,y+k); dp(y+h,x+k); dp(y+h,-x+k); dp(-y+h,-x+k); dp(-y+h,x+k); } void cd(GLint h,GLint k,GLint r) { glColor3ub(237,52,52); GLint d=1-r,x=0,y=r; while(y>x) { pix(h,k,x,y); if(d<0) d+=2*x+3; else { d+=2*(x-y)+5; --y; } ++x; } pix(h,k,x,y); } void drawHeli() { glPushMatrix(); glTranslatef(0,0,0); glScalef(0.01,0.01,1); glPushMatrix(); glTranslatef(0,0,0); glScalef(0.3,0.3,1); glColor3ub(237,52,52); //*************************Body Of HELICOPTER************************************* glBegin(GL_POLYGON); glColor3ub(23,40,230); glVertex2i(20,850); glVertex2i(30,820); glVertex2i(100,820); glVertex2i(110,800); glVertex2i(200,800); glVertex2i(200,815); glVertex2i(190,830); glVertex2i(180,830); glVertex2i(170,860); glVertex2i(155,860); glVertex2i(150,870); glVertex2i(135,860); glVertex2i(115,860); glVertex2i(100,825); glVertex2i(30,850); glEnd(); //********************End of Body of Helicopter**************** //**********************************Tire, Tail and Fan of Helicopter*************************************** cd(142,890,20); cd(170,790,5); cd(130,790,5); cd(22,850,10); //**********************************End of Tire, Tail and Fan of Helicopter*************************************** //*****************************************Bullets of Helicopter************************************************* glBegin(GL_TRIANGLES); glVertex2i(200,800); glVertex2i(200,815); glVertex2i(215,808); glEnd(); glBegin(GL_TRIANGLES); glVertex2i(200,800); glVertex2i(200,815); glVertex2i(215,808); glEnd(); glBegin(GL_TRIANGLES); glVertex2i(200,800); glVertex2i(200,815); glVertex2i(215,808); glEnd(); glPopMatrix(); glPopMatrix(); } void drawRailTrack() { glBegin(GL_LINES); glColor3f(0,0,0); glTranslatef(0,0,1); glVertex3f(-6,0.2,0); glVertex3f(5,0.2,0); glEnd(); glBegin(GL_LINES); glColor3f(0,0,0); glTranslatef(0,0,1); glVertex3f(-6,0.1,0); glVertex3f(5,0.1,0); glEnd(); for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(0,0,0); glTranslatef(0,0,1); glVertex3f(var,0.1,0); glVertex3f(var,0.2,0); glEnd(); var += 0.1; } var = -6; } void drawRoad() { glPushMatrix(); glTranslatef(0,-0.08,-0.25); glScalef(25,0.8,1); glColor3ub(128,128,128); glutSolidCube(0.5); glPopMatrix(); glPushMatrix(); glTranslatef(0,-0.06,0); glPushMatrix(); glTranslatef(-1,0,0); glScalef(5,0.8,0.1); glColor3f(1,1,1); glutSolidCube(0.1); glPopMatrix(); glPushMatrix(); glTranslatef(-2,0,0); glScalef(5,0.8,0.1); glColor3f(1,1,1); glutSolidCube(0.1); glPopMatrix(); glPushMatrix(); glTranslatef(-3,0,0); glScalef(5,0.8,0.1); glColor3f(1,1,1); glutSolidCube(0.1); glPopMatrix(); glPushMatrix(); glTranslatef(-4,0,0); glScalef(5,0.8,0.1); glColor3f(1,1,1); glutSolidCube(0.1); glPopMatrix(); glPushMatrix(); glTranslatef(-5,0,0); glScalef(5,0.8,0.1); glColor3f(1,1,1); glutSolidCube(0.1); glPopMatrix(); glPushMatrix(); glTranslatef(0,0,0); glScalef(5,0.8,0.1); glColor3f(1,1,1); glutSolidCube(0.1); glPopMatrix(); glPushMatrix(); glTranslatef(1,0,0); glScalef(5,0.8,0.1); glColor3f(1,1,1); glutSolidCube(0.1); glPopMatrix(); glPushMatrix(); glTranslatef(2,0,0); glScalef(5,0.8,0.1); glColor3f(1,1,1); glutSolidCube(0.1); glPopMatrix(); glPushMatrix(); glTranslatef(3,0,0); glScalef(5,0.8,0.1); glColor3f(1,1,1); glutSolidCube(0.1); glPopMatrix(); glPopMatrix(); } void wheel(float k,float m,float rad) { glBegin(GL_POLYGON); for(int i=0; i<200; i++) { glColor3f(1.0,1.0,1.0); float pi=3.1416; float A=(i*2*pi)/100; float r=rad-0.15; float x =k+r * cos(A); float y =m+r * sin(A); glVertex3f(x,y,0); } glEnd(); glBegin(GL_POLYGON); for(int i=0; i<200; i++) { glColor3f(0.0,0.0,0.0); float pi=3.1416; float A=(i*2*pi)/100; float r=rad; float x =k+r * cos(A); float y =m+r * sin(A); glVertex3f(x,y,0); } glEnd(); } void drawCar() { wheel(-5.1,-1.5,0.3); wheel(-3.8,-1.5,0.3); //body glBegin(GL_POLYGON); glColor3f(1.0,0.0,0.0); glVertex3f(-5.5, -1.45, 0.0); glVertex3f(-3.4, -1.45, 0.0); glVertex3f(-3.4,-1.05, 0.0); glVertex3f(-5.5, -1.05, 0.0); glEnd(); //window 1 glBegin(GL_POLYGON); glColor3f(0,0,0); glVertex3f(-4.90,-1.0,0.0); glVertex3f(-4.55,-1.0,0.0); glVertex3f(-4.55,-0.75,0.0); glVertex3f(-4.90,-0.75,0.0); glEnd(); //window 2 glBegin(GL_POLYGON); glColor3f(0,0,0); glVertex3f(-4.45,-1.0,0.0); glVertex3f(-4.1,-1.0,0.0); glVertex3f(-4.1,-0.75,0.0); glVertex3f(-4.45,-0.75,0.0); glEnd(); //hood glBegin(GL_POLYGON); glColor3f(1.0,0.0,0.0); glVertex3f(-4.98,-1.05,0.0); glVertex3f(-4.0,-1.05,0.0); glVertex3f(-4.0,-0.69,0.0); glVertex3f(-4.98,-0.69,0.0); glEnd(); glBegin(GL_POLYGON); glColor3f(1.0,0.0,0.0); glVertex3f(-4.0,-1.05,0.0); glVertex3f(-4.0,-0.69,0.0); glVertex3f(-3.6,-1.05,0.0); glEnd(); glBegin(GL_POLYGON); glColor3f(1.0,0.0,0.0); glVertex3f(-4.98,-1.05,0.0); glVertex3f(-4.98,-0.69,0.0); glVertex3f(-5.4,-1.05,0.0); glEnd(); } void drawPlane() { //body glPushMatrix(); glTranslatef(0,-1,0); glScalef(5,0.8,0.1); glColor3f(1,1,1); glutSolidCube(0.2); glPopMatrix(); //head glPushMatrix(); glTranslatef(0.5,-0.92,0); glScalef(0.15,0.16,1); glRotatef(90,0,0,-1); glColor3f(1,0,0); glBegin(GL_TRIANGLES); glVertex3f(0,0,0); glVertex3f(1,0,0); glVertex3f(0.5,1,0); glEnd(); glPopMatrix(); //tail glPushMatrix(); glTranslatef(-0.5,-0.92,0); glScalef(0.2,0.2,1); glBegin(GL_QUADS); glVertex3f(0,0,0); glVertex3f(0,1,0); glVertex3f(0.3,1,0); glVertex3f(1,0,0); glEnd(); glPopMatrix(); //left wing glPushMatrix(); glTranslatef(0,-0.92,0); glScalef(0.2,0.3,1); glBegin(GL_QUADS); glVertex3f(0,0,0); glVertex3f(1,0,0); glVertex3f(0.2,1,0); glVertex3f(-0.5,1,0); glEnd(); glPopMatrix(); //left wing glPushMatrix(); glTranslatef(-0.1,-1.48,0); glScalef(0.2,0.4,1); glBegin(GL_QUADS); glVertex3f(0,0,0); glVertex3f(0.7,0,0); glVertex3f(1.5,1,0); glVertex3f(0.5,1,0); glEnd(); glPopMatrix(); } void drawRainbow() { float i; float px = -0.2; float py = -0.5; float side_length = -0.7; float r = 1.625; // sculling constant for a 500:800 float sectx = px+side_length; float secty = py; float topx = px+(side_length/2.0); float topy = (py+side_length*-0.866*r); float hit = 0.7; // Where to hit [0,1] // `cept` is computing where the light ray will hit the prism float ceptx =sectx-(hit*(side_length/2.0)); float cepty =-1.73205*r*hit*(side_length/2.0)+py; // These are the parameters for the spread of the inside refraction hit = 0.4; // Where to on the right side, [0,1] float exitxU = (px+side_length/2.0)-hit*side_length/2.0; float exityU = (-1.73205*r*(1-hit)*(side_length/2.0))+py; hit=0.1; // Try changing this number float exitxL=(px+side_length/2.0)-hit*side_length/2.0; float exityL=(-1.73205*r*(1-hit)*(side_length/2.0))+py; // #Draw the rainbow tail // The rainbow is made of 50 small rectangles that have rainbow shading. They are painted one after the other but the y coordinate is mapped to a sine wave. The height of the rainbow slices are based on the refraction triangle boundaries in the prism. float dx=exitxL; float dy=exityL; float w=0.014; float step=(exityL-exityU)/5.0; for(i=0; i<50; i++) { glBegin(GL_QUAD_STRIP); glColor3f(1,0,0); glVertex2f(dx,dy); glVertex2f(dx+w,dy); glColor3f(1,0.6,0); glVertex2f(dx,dy-step); glVertex2f(dx+w,dy-step); glColor3f(1,1,0); glVertex2f(dx,dy-step*2); glVertex2f(dx+w,dy-step*2); glColor3f(0.2,1,0); glVertex2f(dx,dy-step*3); glVertex2f(dx+w,dy-step*3); glColor3f(0,0.6,1); glVertex2f(dx,dy-step*4); glVertex2f(dx+w,dy-step*4); glColor3f(0.4,0.2,1); glVertex2f(dx,dy-step*5); glVertex2f(dx+w,dy-step*5); glEnd(); dx+=w; dy+=0.01*sin(i*3.14/5.0); } } void drawRain() { for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,-0.1,0); glVertex3f(rainX,-0.2,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,-0.4,0); glVertex3f(rainX,-0.5,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,-0.7,0); glVertex3f(rainX,-0.8,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,-1,0); glVertex3f(rainX,-1.1,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,-1.3,0); glVertex3f(rainX,-1.4,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,-1.6,0); glVertex3f(rainX,-1.7,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,-1.9,0); glVertex3f(rainX,-2,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,0.1,0); glVertex3f(rainX,0.2,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,0.4,0); glVertex3f(rainX,0.5,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,0.7,0); glVertex3f(rainX,0.8,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,1,0); glVertex3f(rainX,1.1,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,1.3,0); glVertex3f(rainX,1.4,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,1.6,0); glVertex3f(rainX,1.7,0); glEnd(); rainX += 0.1; } rainX = -6; for(int i=0; i<100; i++) { glBegin(GL_LINES); glColor3f(1,1,1); glVertex3f(rainX,1.9,0); glVertex3f(rainX,2,0); glEnd(); rainX += 0.1; } rainX = -6; } void drawBird() { glPushMatrix(); int i; GLfloat mm=0.182f; GLfloat nn=.801f; GLfloat radiusmm =.01f; int triangleAmount = 100; GLfloat twicePi = 2.0f * PI; glBegin(GL_TRIANGLE_FAN); glColor3ub(225, 225, 208); glVertex2f(mm, nn); // center of circle for(i = 0; i <= triangleAmount; i++) { glVertex2f( mm + (radiusmm * cos(i * twicePi / triangleAmount)), nn + (radiusmm * sin(i * twicePi / triangleAmount)) ); } glEnd(); glBegin(GL_POLYGON); glColor3ub(225, 225, 208 ); glVertex2f(0.1f,0.8f); glVertex2f(0.11f,0.79f); glVertex2f(0.12f,0.78f); glVertex2f(0.16f,0.77f); glVertex2f(0.19f,0.79f); glVertex2f(0.201f,0.8f); glEnd(); glBegin(GL_TRIANGLES); glColor3ub(217, 217, 217); glVertex2f(0.175f,0.8f); glVertex2f(0.15f,0.8f); glVertex2f(0.14f,0.84f); glEnd(); glBegin(GL_TRIANGLES); glColor3ub(242, 242, 242 ); glVertex2f(0.175f,0.8f); glVertex2f(0.144f,0.8f); glVertex2f(0.12f,0.83f); glEnd(); /////2nd bird//// glBegin(GL_POLYGON); glColor3ub(225, 225, 208 ); glVertex2f(-0.02f,0.8f); glVertex2f(-0.01f,0.79f); glVertex2f(0.0f,0.78f); glVertex2f(0.04f,0.77f); glVertex2f(0.07f,0.79f); glVertex2f(0.081f,0.8f); glEnd(); glBegin(GL_TRIANGLES); glColor3ub(217, 217, 217); glVertex2f(0.055f,0.8f); glVertex2f(0.03f,0.8f); glVertex2f(0.02f,0.84f); glEnd(); glBegin(GL_TRIANGLES); glColor3ub(242, 242, 242 ); glVertex2f(0.055f,0.8f); glVertex2f(0.024f,0.8f); glVertex2f(0.0f,0.83f); glEnd(); GLfloat mmm=0.062f; GLfloat nnn=.801f; GLfloat radiusmmm =.01f; glBegin(GL_TRIANGLE_FAN); glColor3ub(225, 225, 208); glVertex2f(mmm, nnn); // center of circle for(i = 0; i <= triangleAmount; i++) { glVertex2f( mmm + (radiusmmm * cos(i * twicePi / triangleAmount)), nnn + (radiusmmm * sin(i * twicePi / triangleAmount)) ); } glEnd(); /////3rd bird///// glBegin(GL_POLYGON); glColor3ub(225, 225, 208 ); glVertex2f(-0.72f,0.8f); glVertex2f(-0.71f,0.79f); glVertex2f(-0.7f,0.78f); glVertex2f(-0.66f,0.77f); glVertex2f(-0.63f,0.79f); glVertex2f(-0.619f,0.8f); glEnd(); glBegin(GL_TRIANGLES); glColor3ub(217, 217, 217); glVertex2f(-0.645f,0.8f); glVertex2f(-0.67f,0.8f); glVertex2f(-0.68f,0.84f); glEnd(); glBegin(GL_TRIANGLES); glColor3ub(242, 242, 242 ); glVertex2f(-0.645f,0.8f); glVertex2f(-0.676f,0.8f); glVertex2f(-0.7f,0.83f); glEnd(); GLfloat mmmm=-0.638f; GLfloat nnnn=.801f; glBegin(GL_TRIANGLE_FAN); glColor3ub(225, 225, 208); glVertex2f(mmmm,nnnn); // center of circle for(i = 0; i <= triangleAmount; i++) { glVertex2f( mmmm + (radiusmmm * cos(i * twicePi / triangleAmount)), nnnn + (radiusmmm * sin(i * twicePi / triangleAmount)) ); } glEnd(); ////4th bird//// GLfloat mmmmm=-0.518f; GLfloat nnnnn=.801f; glBegin(GL_TRIANGLE_FAN); glColor3ub(225, 225, 208); glVertex2f(mmmmm, nnnnn); // center of circle for(i = 0; i <= triangleAmount; i++) { glVertex2f( mmmmm + (radiusmm * cos(i * twicePi / triangleAmount)), nnnnn + (radiusmm * sin(i * twicePi / triangleAmount)) ); } glEnd(); glBegin(GL_POLYGON); glColor3ub(225, 225, 208 ); glVertex2f(-0.6f,0.8f); glVertex2f(-0.59f,0.79f); glVertex2f(-0.58f,0.78f); glVertex2f(-0.54f,0.77f); glVertex2f(-0.51f,0.79f); glVertex2f(-0.499f,0.8f); glEnd(); glBegin(GL_TRIANGLES); glColor3ub(217, 217, 217); glVertex2f(-0.525f,0.8f); glVertex2f(-0.55f,0.8f); glVertex2f(-0.56f,0.84f); glEnd(); glBegin(GL_TRIANGLES); glColor3ub(242, 242, 242 ); glVertex2f(-0.525f,0.8f); glVertex2f(-0.556f,0.8f); glVertex2f(-0.58f,0.83f); glEnd(); glPopMatrix(); } void drawBird2() { glPushMatrix(); glBegin(GL_LINES); glColor3f(0, 0, 0); glVertex3f(0,0,0); glVertex3f(1, 0.5, 0); glVertex3f(1, 0.5, 0); glVertex3f(0, 1, 0); glEnd(); glPopMatrix(); } //Initializes 3D rendering void initRendering() { glEnable(GL_DEPTH_TEST); } //Called when the window is resized void handleResize(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, (double)w / (double)h, 1.0, 200.0); } float _angle = 0.0; float _cameraAngle = 0.0; float _ang_tri = 0.0; //Draws the 3D scene void drawScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective glLoadIdentity(); //Reset the drawing perspective glTranslatef(0.0, 0.0, -7.0); //Move forward 5 units //Sky glPushMatrix(); glScalef(7,3,2); glTranslatef(0,1.21,0); glColor3ub(sky[0], sky[1], sky[2]); glBegin(GL_QUADS); glVertex3f(-1.0, -1.0, 0.0); glVertex3f(-1.0, 1.0, 0.0); glVertex3f(1.0, 1.0, 0.0); glVertex3f(1.0, -1.0, 0.0); glEnd(); glPopMatrix(); //Ground glPushMatrix(); glTranslatef(0,-3.68,0); glScalef(6,4,1); glColor3ub(soil[0],soil[1],soil[2]); glBegin(GL_QUADS); glVertex3f(-1.0, -1.0, 0.0); glVertex3f(-1.0, 1.0, 0.0); glVertex3f(1.0, 1.0, 0.0); glVertex3f(1.0, -1.0, 0.0); glEnd(); glPopMatrix(); //SUN glPushMatrix(); glTranslatef(0,-_angle,0); glTranslatef(4,3,0); glScalef(1,1,0.1); glColor3ub(sun[0], sun[1], sun[2]); glutSolidSphere(0.4,40,40); glPopMatrix(); glPushMatrix(); glTranslatef(_angle,0,0); //Cloud glPushMatrix(); glColor3ub(cloud[0], cloud[1], cloud[2]); glTranslatef(-1,2.3,0); drawCloud(); glPopMatrix(); //Cloud glPushMatrix(); glColor3ub(cloud[0], cloud[1], cloud[2]); glScalef(0.7,0.7,1); glTranslatef(1,2.5,0); drawCloud(); glPopMatrix(); //Cloud glPushMatrix(); glColor3ub(cloud[0], cloud[1], cloud[2]); glScalef(0.7,0.7,1); glTranslatef(1,2.5,0); drawCloud(); glPopMatrix(); //Cloud glPushMatrix(); glColor3ub(cloud[0], cloud[1], cloud[2]); glScalef(0.7,0.7,1); glTranslatef(2.6,2.7,0); drawCloud(); glPopMatrix(); //Cloud glPushMatrix(); glColor3ub(cloud[0], cloud[1], cloud[2]); glTranslatef(-3.6,2.0,0); drawCloud(); glPopMatrix(); glPopMatrix(); glTranslatef(0,0,0.1); //tree glPushMatrix(); glScalef(0.7,0.7,1); glTranslatef(-4,1.4,0); drawTree(); glPopMatrix(); //tree glPushMatrix(); glScalef(0.7,0.7,1); glTranslatef(-6,1.4,0); drawTree(); glPopMatrix(); //tree glPushMatrix(); glScalef(0.7,0.7,1); glTranslatef(-5.5,1.4,0); drawTree(); glPopMatrix(); //tree glPushMatrix(); glScalef(0.7,0.7,1); glTranslatef(0,1.4,0); drawTree(); glPopMatrix(); //tree glPushMatrix(); glScalef(0.7,0.7,1); glTranslatef(-1,1.4,0); drawTree(); glPopMatrix(); //tree glPushMatrix(); glScalef(0.7,0.7,1); glTranslatef(2,1.4,0); drawTree(); glPopMatrix(); //tree glPushMatrix(); glScalef(0.7,0.7,1); glTranslatef(4,1.4,0); drawTree(); glPopMatrix(); //tree glPushMatrix(); glScalef(0.7,0.7,1); glTranslatef(6,1.4,0); drawTree(); glPopMatrix(); //tree glPushMatrix(); glScalef(0.7,0.7,1); glTranslatef(6.5,1.4,0); drawTree(); glPopMatrix(); //tree glPushMatrix(); glTranslatef(-2,1,0); glScalef(0.7,0.7,1); drawTree(); glPopMatrix(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(-5,0.3,0); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(-4.5,0.3,0); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(-3.5,0.3,0); glScalef(0.8,0.8,1); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(-3,0.3,0); glScalef(1.5,1.5,1); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(-1.5,0.3,0); glScalef(1,2,1); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(-1,0.3,0); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(2,0.3,0); glScalef(1,2,1); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(2.5,0.3,0); glScalef(1,2,1); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(3.5,0.3,0); glScalef(0.8,0.8,1); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(4,0.3,0); glScalef(0.8,0.8,1); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(0,0.3,0); glScalef(0.8,0.8,1); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(0.3,0.3,0); glScalef(0.8,0.8,1); drawBush(); glPopMatrix(); //bush glPushMatrix(); glTranslatef(0.6,0.3,0); glScalef(1,1.3,1); drawBush(); glPopMatrix(); //Train glPushMatrix(); glScalef(0.2, 0.2, 0.1); glTranslatef(9, 2.5, 1); glTranslatef(-train, 0, 0); drawTrain(); glPopMatrix(); //house 1 glPushMatrix(); glTranslatef(-3,-1,0.5); glScalef(0.7,0.7,1); DrawHouse(); glPopMatrix(); //house 2 glPushMatrix(); glTranslatef(-3.8,-1,0); glScalef(0.7,0.7,1); DrawHouse(); glPopMatrix(); //house3 glPushMatrix(); glTranslatef(-4,-1.3,0.5); glScalef(0.7,0.7,1); DrawHouse(); glPopMatrix(); //tree glPushMatrix(); glTranslatef(-3.5,-0.5,0.5); glScalef(0.8,0.8,1); drawTree(); glPopMatrix(); //tree glPushMatrix(); glTranslatef(-3.2,-0.8,0.5); glScalef(0.8,0.8,1); drawTree(); glPopMatrix(); //circle tree glPushMatrix(); glTranslatef(-5,-0.95,0); glScalef(1,1,0.2); glColor3ub(38, 171, 80); glutSolidSphere(0.55,40,40); glPopMatrix(); //circle tree 2 glPushMatrix(); glTranslatef(-4.5,-0.9,0); glScalef(1,1,0.1); glColor3ub(14, 125, 49); glutSolidSphere(0.55,40,40); glPopMatrix(); //Building glPushMatrix(); glTranslatef(2.8,-0.5,1); glScalef(0.003,0.003,1); building(); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.24,0.8,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.43,0.8,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.24,0.45,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.43,0.45,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.24,0.07,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.43,0.07,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.24,-0.15,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.43,-0.15,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //2nd building glPushMatrix(); glTranslatef(0.47,0,0); glPushMatrix(); glTranslatef(3.24,0.8,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.43,0.8,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.24,0.45,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.43,0.45,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.24,0.07,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.43,0.07,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.24,-0.15,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); //buiding 1 WIndow glPushMatrix(); glTranslatef(3.43,-0.15,1); glColor3f(1,1,1); glScalef(1,1,0.1); glutSolidCube(0.12); glPopMatrix(); glPopMatrix(); //building 3 windows glPushMatrix(); glTranslatef(0,0.1,0); glPushMatrix(); glTranslatef(4.25,-0.15,1); glColor3f(1,1,1); glScalef(1,1.5,0.1); glutSolidCube(0.12); glPopMatrix(); glPushMatrix(); glTranslatef(4.25,0.15,1); glColor3f(1,1,1); glScalef(1,1.5,0.1); glutSolidCube(0.12); glPopMatrix(); glPushMatrix(); glTranslatef(4.25,0.45,1); glColor3f(1,1,1); glScalef(1,1.5,0.1); glutSolidCube(0.12); glPopMatrix(); glPushMatrix(); glTranslatef(4.25,0.75,1); glColor3f(1,1,1); glScalef(1,1.5,0.1); glutSolidCube(0.12); glPopMatrix(); glPopMatrix(); //water circle glPushMatrix(); glColor3ub(water[0],water[1],water[2]); glTranslatef(4.5,-3,1.2); glScalef(1.3,0.8,0.1); glutSolidSphere(3,80,80); glPopMatrix(); glPushMatrix(); glColor3ub(140,82,41); glTranslatef(4.5,-3,0); glScalef(1.3,0.8,0.1); glutSolidSphere(3.5,80,80); glPopMatrix(); glPushMatrix(); glColor3ub(163,147,135); glTranslatef(4.5,-3,1.1); glScalef(1.3,0.8,0.1); glutSolidSphere(3.2,80,80); glPopMatrix(); //pol ar gada glPushMatrix(); glTranslatef(-2.2,-0.8,1); glScalef(0.4,0.8,1); glRotatef(180,0,0,1); glColor3ub(cowFood[0],cowFood[1],cowFood[2]); GLfloat midY = 0.001; GLfloat midX = 0.001; GLfloat y = 0; glBegin(GL_POLYGON); for(GLfloat x = -1; x <= 1.05; x+=0.05) { y = x*x; glVertex2f(midX + x, midY + y); } glEnd(); glPopMatrix(); //house 2 glPushMatrix(); glTranslatef(-1,-1.7,0); glScalef(0.7,0.7,1); DrawHouse2(); glPopMatrix(); //house 2 glPushMatrix(); glTranslatef(-0.7,-1.7,-0.5); glScalef(0.7,0.7,1); DrawHouse2(); glPopMatrix(); //ship 1 glPushMatrix(); glTranslatef(ship,0,0); glTranslatef(1,-1.5,2); glScalef(0.05,0.05,1); drawBoat(); glPopMatrix(); //ship 2 glPushMatrix(); glTranslatef(ship2,0.5,0); glTranslatef(5,-1.5,2); glScalef(0.05,0.05,1); drawBoat(); glPopMatrix(); //flower on water glPushMatrix(); glTranslatef(3.5,-1.8,1); glScalef(0.02,0.02,1); glRotatef(180,0,0,1); drawFlower(); glPopMatrix(); //flower on water glPushMatrix(); glTranslatef(3.2,-1.8,1); glScalef(0.02,0.02,1); glRotatef(180,0,0,1); drawFlower(); glPopMatrix(); //flower on water glPushMatrix(); glTranslatef(3.4,-1.6,1); glScalef(0.02,0.02,1); glRotatef(180,0,0,1); drawFlower(); glPopMatrix(); //Red flower glPushMatrix(); glTranslatef(-0.2,-1.8,1); glScalef(0.015,0.015,1); glRotatef(180,0,0,1); drawRedFlower(); glPopMatrix(); //Red flower glPushMatrix(); glTranslatef(-0.1,-1.9,1); glScalef(0.015,0.015,1); glRotatef(180,0,0,1); drawRedFlower(); glPopMatrix(); //Red flower glPushMatrix(); glTranslatef(-0.3,-1.9,1); glScalef(0.015,0.015,1); glRotatef(180,0,0,1); drawRedFlower(); glPopMatrix(); //Red Track glPushMatrix(); glTranslated(0,0.05,0); drawRailTrack(); glPopMatrix(); //road glPushMatrix(); drawRoad(); glPopMatrix(); //car glPushMatrix(); glTranslatef(car1,0,0); glTranslatef(0,0.15,1); glScalef(0.2,0.2,1); drawCar(); glPopMatrix(); //car glPushMatrix(); glTranslatef(car1,0,0); glTranslatef(-2,0.15,1); glScalef(0.2,0.2,1); drawCar(); glPopMatrix(); //car glPushMatrix(); glTranslatef(-car1,0,0); glTranslatef(3,0.3,1); glScalef(0.2,0.2,1); drawCar(); glPopMatrix(); //car glPushMatrix(); glTranslatef(-car1,0,0); glTranslatef(5,0.3,1); glScalef(0.2,0.2,1); drawCar(); glPopMatrix(); //car glPushMatrix(); glTranslatef(-car1,0,0); glTranslatef(3,0.3,1); glScalef(0.2,0.2,1); drawCar(); glPopMatrix(); //heli glPushMatrix(); glTranslatef(fly,-1,0); glTranslatef(-6,0,0); //glScalef(1,1,1); drawHeli(); glPopMatrix(); //plane glPushMatrix(); glTranslatef(fly,0,0); glTranslatef(-16,3,0); drawPlane(); glPopMatrix(); if(Rain && !night) { //rain glPushMatrix(); glTranslatef(0,-rain,3); glRotatef(10,0,0,1); drawRain(); glPopMatrix(); //rainbow glPushMatrix(); glTranslatef(-3,1,0); glScalef(4,1.5,1); drawRainbow(); glPopMatrix(); } if(Rain && night) { //rain glPushMatrix(); glTranslatef(0,-rain,3); glRotatef(10,0,0,1); drawRain(); glPopMatrix(); } glPushMatrix(); glTranslatef(ship, 0, 0); glTranslatef(0, 2, 0); //draw Bird glPushMatrix(); drawBird(); glPopMatrix(); //draw Bird glPushMatrix(); glTranslatef(0, 0, 1); glScalef(0.05, 0.05, 1); drawBird2(); glPopMatrix(); //draw Bird glPushMatrix(); glTranslatef(-0.1, 0, 1); glScalef(0.05, 0.05, 1); drawBird2(); glPopMatrix(); //draw Bird glPushMatrix(); glTranslatef(-0.1, 0.1, 1); glScalef(0.05, 0.05, 1); drawBird2(); glPopMatrix(); //draw Bird glPushMatrix(); glTranslatef(-0.1, -0.1, 1); glScalef(0.05, 0.05, 1); drawBird2(); glPopMatrix(); //draw Bird glPushMatrix(); glTranslatef(-0.2, -0.1, 1); glScalef(0.05, 0.05, 1); drawBird2(); glPopMatrix(); //draw Bird glPushMatrix(); glTranslatef(-0.2, -0.2, 1); glScalef(0.05, 0.05, 1); drawBird2(); glPopMatrix(); //draw Bird glPushMatrix(); glTranslatef(-0.2, 0, 1); glScalef(0.05, 0.05, 1); drawBird2(); glPopMatrix(); //draw Bird glPushMatrix(); glTranslatef(-0.2, 0.1, 1); glScalef(0.05, 0.05, 1); drawBird2(); glPopMatrix(); //draw Bird glPushMatrix(); glTranslatef(-0.2, 0.2, 1); glScalef(0.05, 0.05, 1); drawBird2(); glPopMatrix(); glPopMatrix(); glutSwapBuffers(); } void update(int value) { _angle += 0.002f; glutPostRedisplay(); //Tell GLUT that the display has changed //Tell GLUT to call update again in 25 milliseconds glutTimerFunc(25, update, 0); } void trainAnimation(int value) { train += 0.1f; glutPostRedisplay(); glutTimerFunc(25, trainAnimation, 0); } void carAnimation1(int value) { car1 += 0.03f; if(car1>10.0f) { car1 = -5.0f; } glutPostRedisplay(); glutTimerFunc(25, carAnimation1, 0); } void flyAnimation(int value) { fly += 0.04f; if(fly>25.0f) { //move=true; fly = -10.0f; } glutPostRedisplay(); glutTimerFunc(25, flyAnimation, 0); } void shipAnimation(int value) { ship += 0.005f; glutPostRedisplay(); glutTimerFunc(25, shipAnimation, 0); } void shipAnimation2(int value) { if(ship2 <= -3.2) { return; } else { ship2 -= 0.005f; } glutPostRedisplay(); glutTimerFunc(25, shipAnimation2, 0); } void rainAnimation(int value) { rain += 0.02f; if(rain>0.1f) { //move=true; rain = -0.1f; } glutPostRedisplay(); glutTimerFunc(25, rainAnimation, 0); } void keyboard(unsigned char key, int x, int y) { switch (key) { case 'r': Rain = true; if(!night) { sky[0] = 128; sky[1] = 137; sky[2] = 140; cloud[0] = 87; cloud[1] = 98; cloud[2] = 102; sun[0] = 128; sun[1] = 137; sun[2] = 140; PlaySound(TEXT("rain.wav"),NULL,SND_ASYNC|SND_FILENAME|SND_LOOP); } if(night && Rain) { sun[0] = 77; sun[1] = 77; sun[2] = 77; PlaySound(TEXT("rain.wav"),NULL,SND_ASYNC|SND_FILENAME|SND_LOOP); } break; case 's': Rain = false; if(!night) { sky[0] = 19; sky[1] = 190; sky[2] = 242; cloud[0] = 255; cloud[1] = 255; cloud[2] = 255; sun[0] = 219; sun[1] = 230; sun[2] = 21; tree[0] = 34; tree[1] = 139; tree[2] = 34; bush[0] = 127; bush[1] = 162; bush[2] = 12; soil[0] = 199; soil[1] = 192; soil[2] = 141; cowFood[0] = 235; cowFood[1] = 222; cowFood[2] = 164; water[0] = 152; water[1] = 222; water[2] = 245; double building2[3] = {217,217,50}; building2[0] = 217; building2[1] = 217; building2[2] = 50; building1Box2[0] = 237; building1Box2[1] = 237; building1Box2[2] = 187; building1Box3[0] = 30; building1Box3[1] = 186; building1Box3[2] = 79; PlaySound(TEXT("sun.wav"),NULL,SND_ASYNC|SND_FILENAME|SND_LOOP); } if(!Rain && night) { sun[0] = 255; sun[1] = 255; sun[2] = 255; PlaySound(TEXT("night.wav"),NULL,SND_ASYNC|SND_FILENAME|SND_LOOP); } break; case 'n': night = true; if(night && !Rain) { sky[0] = 77; sky[1] = 77; sky[2] = 77; cloud[0] = 125; cloud[1] = 125; cloud[2] = 125; sun[0] = 255; sun[1] = 255; sun[2] = 255; tree[0] = 125; tree[1] = 125; tree[2] = 125; bush[0] = 125; bush[1] = 125; bush[2] = 125; soil[0] = 123; soil[1] = 128; soil[2] = 28; cowFood[0] = 128; cowFood[1] = 103; cowFood[2] = 28; water[0] = 68; water[1] = 142; water[2] = 201; building2[0] = 102; building2[1] = 102; building2[2] = 102; building1Box2[0] = 102; building1Box2[1] = 102; building1Box2[2] = 102; building1Box3[0] = 102; building1Box3[1] = 102; building1Box3[2] = 102; PlaySound(TEXT("night.wav"),NULL,SND_ASYNC|SND_FILENAME|SND_LOOP); } else if(night && Rain) { sky[0] = 77; sky[1] = 77; sky[2] = 77; cloud[0] = 125; cloud[1] = 125; cloud[2] = 125; sun[0] = 77; sun[1] = 77; sun[2] = 77; tree[0] = 125; tree[1] = 125; tree[2] = 125; bush[0] = 125; bush[1] = 125; bush[2] = 125; soil[0] = 123; soil[1] = 128; soil[2] = 28; cowFood[0] = 128; cowFood[1] = 103; cowFood[2] = 28; water[0] = 68; water[1] = 142; water[2] = 201; building2[0] = 102; building2[1] = 102; building2[2] = 102; building1Box2[0] = 102; building1Box2[1] = 102; building1Box2[2] = 102; building1Box3[0] = 102; building1Box3[1] = 102; building1Box3[2] = 102; } break; case 'd': night = false; if(!Rain) { sky[0] = 19; sky[1] = 190; sky[2] = 242; cloud[0] = 255; cloud[1] = 255; cloud[2] = 255; sun[0] = 219; sun[1] = 230; sun[2] = 21; tree[0] = 34; tree[1] = 139; tree[2] = 34; bush[0] = 127; bush[1] = 162; bush[2] = 12; soil[0] = 199; soil[1] = 192; soil[2] = 141; cowFood[0] = 235; cowFood[1] = 222; cowFood[2] = 164; water[0] = 152; water[1] = 222; water[2] = 245; building2[0] = 217; building2[1] = 217; building2[2] = 50; building1Box2[0] = 237; building1Box2[1] = 237; building1Box2[2] = 187; building1Box3[0] = 30; building1Box3[1] = 186; building1Box3[2] = 79; PlaySound(TEXT("sun.wav"),NULL,SND_ASYNC|SND_FILENAME|SND_LOOP); } if(Rain && !night) { sky[0] = 128; sky[1] = 137; sky[2] = 140; cloud[0] = 87; cloud[1] = 98; cloud[2] = 102; sun[0] = 128; sun[1] = 137; sun[2] = 140; tree[0] = 34; tree[1] = 139; tree[2] = 34; bush[0] = 127; bush[1] = 162; bush[2] = 12; soil[0] = 199; soil[1] = 192; soil[2] = 141; cowFood[0] = 235; cowFood[1] = 222; cowFood[2] = 164; water[0] = 152; water[1] = 222; water[2] = 245; building2[0] = 217; building2[1] = 217; building2[2] = 50; building1Box2[0] = 237; building1Box2[1] = 237; building1Box2[2] = 187; building1Box3[0] = 30; building1Box3[1] = 186; building1Box3[2] = 79; PlaySound(TEXT("rain.wav"),NULL,SND_ASYNC|SND_FILENAME|SND_LOOP); } break; } } int main(int argc, char** argv) { //Initialize GLUT glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(800, 400); //Create the window glutCreateWindow("Transportation"); initRendering(); //Set handler functions glutDisplayFunc(drawScene); glutReshapeFunc(handleResize); glutTimerFunc(250, update, 0); //Add a timer glutTimerFunc(25, trainAnimation, 0); //Add a timer glutTimerFunc(25, carAnimation1, 0); //Add a timer glutTimerFunc(25, flyAnimation, 0); //Add a timer glutTimerFunc(25, shipAnimation, 0); glutTimerFunc(25, shipAnimation2, 0); glutTimerFunc(25, rainAnimation, 0); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }


Tingkat keanekaragaman hayati tingkat gen

Tingkat keanekaragaman hayati tingkat gen -- Keanekaragaman hayati adalah sebuah istilah untuk menggambarkan keanekaragaman mahluk hidup di ...