کد های opengl

شرح پروژه :

 

ابتدا روز هست و خورشید از سمت چپ مییاد و آسمون روشن میشه ، سپس خورشید به سمت راست میره و آسمون تیره میشه و بعد از ناپدید شدن خورشید آسمون تاریک و ستاره ها نمایان میشند.
کد:

#include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include<dos.h> int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xmax, ymax,maxx,maxy; int poly[16]; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, "f:\\borlandc\\bgi"); /* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } cleardevice(); setbkcolor(9); rectangle(0, 0, getmaxx(), getmaxy());

/************************** draw (chaman)********************************/ poly[0] = 0; poly[1] = 500; poly[2] = 1; poly[3] = 460; poly[4] = 150; poly[5] = 420; poly[6] = 200; poly[7] = 450; poly[8] = 350; poly[9] = 420; poly[10] = 400; poly[11] = 450; poly[12] = 550; poly[13] = 420; poly[14] = 680; poly[15] =480; setfillstyle(1,2); fillpoly(8, poly); /* putpixel(200,420,6); setfillstyle(1,6); fillellipse(200, 400,10 , 50); /************************** draw (khorshid) ***********************/ /******** step 1 **************/ setfillstyle(1,14); fillellipse(20, 200,20,20); /*********** step 2 *************/ delay(3500); cleardevice(); setbkcolor(9); rectangle(0, 0, getmaxx(), getmaxy()); poly[0] = 0; poly[1] = 500; poly[2] = 1; poly[3] = 460; poly[4] = 150; poly[5] = 420; poly[6] = 200; poly[7] = 450; poly[8] = 350; poly[9] = 420; poly[10] = 400; poly[11] = 450; poly[12] = 550; poly[13] = 420; poly[14] = 680; poly[15] =480; setfillstyle(1,10); fillpoly(8, poly); setfillstyle(1,14); fillellipse(300,50,20,20); /****************************** step 3 *********************************/ delay(3500); cleardevice(); setbkcolor(1); rectangle(0, 0, getmaxx(), getmaxy()); poly[0] = 0; poly[1] = 500; poly[2] = 1; poly[3] = 460; poly[4] = 150; poly[5] = 420; poly[6] = 200; poly[7] = 450; poly[8] = 350; poly[9] = 420; poly[10] = 400; poly[11] = 450; poly[12] = 550; poly[13] = 420; poly[14] = 680; poly[15] =480; setfillstyle(1,2); fillpoly(8, poly); setfillstyle(1,14); fillellipse(620, 200,20 , 20); /***************** step 4 *************/ delay(3500); cleardevice(); setbkcolor(0); rectangle(0, 0, getmaxx(), getmaxy()); poly[0] = 0; poly[1] = 500; poly[2] = 1; poly[3] = 460; poly[4] = 150; poly[5] = 420; poly[6] = 200; poly[7] = 450; poly[8] = 350; poly[9] = 420; poly[10] = 400; poly[11] = 450; poly[12] = 550; poly[13] = 420; poly[14] = 680; poly[15] =480; setfillstyle(1,2); fillpoly(8, poly); /*********************** star ************************/ putpixel(100,100,15); putpixel(150,180,15); putpixel(250,180,15); putpixel(150,280,15); putpixel(350,280,15); putpixel(350,80,15); putpixel(150,80,15); putpixel(500,280,15); putpixel(350,280,15); putpixel(550,280,15); putpixel(600,180,15); setfillstyle(1,15); fillellipse(300, 50,5 , 25); // arc(300, 100, 290, 140, 30); /****************************** clean up *****************************/ getch(); closegraph(); return 0; }

/ 0 نظر / 5 بازدید