Advertisement
fus3rx

sahid minar

Mar 19th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.18 KB | None | 0 0
  1. #include <GL/gl.h>
  2. #include <glut.h>
  3. #include <Math.h>
  4. #include <stdio.h>
  5.  
  6.     const float DEG2RAD = 3.14159/180;
  7.     const float PI = 3.1415;
  8.  
  9.     double angle,x,y;
  10.  
  11.     void drawCircle(GLfloat x, GLfloat y, GLfloat radius){
  12.         int i;
  13.         int triangleAmount = 1000;
  14.         float twicePi = 2.0f * PI;
  15.  
  16.         glEnable(GL_LINE_SMOOTH);
  17.         glLineWidth(5.0);
  18.  
  19.         glBegin(GL_LINES);
  20.  
  21.         for(i = 0; i <= triangleAmount; i++){
  22.             glVertex2f( x, y);
  23.             glVertex2f(x + (radius * cos(i * twicePi / triangleAmount)),
  24.                         y + (radius * sin(i * twicePi / triangleAmount)));
  25.             }
  26.             glEnd();
  27.     }
  28.  
  29.     void display(void){
  30.             /* clear all pixels */
  31.             glClear (GL_COLOR_BUFFER_BIT);
  32.  
  33.             glColor3ub (102,178,255);
  34.             glBegin(GL_POLYGON);
  35.             glVertex2d (-600,-100);
  36.             glVertex2d (600,-100);
  37.             glVertex2d (600,500);
  38.             glVertex2d (-600, 500);
  39.             glEnd();
  40.             //sun
  41.             glColor3ub(255, 0, 0);
  42.             drawCircle(0,200,110);
  43.  
  44.             //Square 1st one
  45.  
  46.  
  47.              glColor3ub (255,255,255);
  48.             glBegin(GL_POLYGON);
  49.             glVertex2d (70,0);
  50.             glVertex2d (70,400);
  51.             glVertex2d (90,400);
  52.             glVertex2d (90, 0);
  53.             glEnd();
  54.  
  55.  
  56.  
  57.             glColor3ub (255,255,255);
  58.             glBegin(GL_POLYGON);
  59.             glVertex2d (10,0);
  60.             glVertex2d (10,400);
  61.             glVertex2d (-10,400);
  62.             glVertex2d (-10, 0);
  63.             glEnd();
  64.  
  65.  
  66.  
  67.             glColor3ub (255,255,255);
  68.             glBegin(GL_POLYGON);
  69.             glVertex2d (-70,0);
  70.             glVertex2d (-70,400);
  71.             glVertex2d (-90,400);
  72.             glVertex2d (-90, 0);
  73.             glEnd();
  74.  
  75.  
  76.  
  77.  
  78.             glColor3ub (255,255,255);
  79.             glBegin(GL_POLYGON);
  80.             glVertex2d (90,0);
  81.             glVertex2d (90,20);
  82.             glVertex2d (-90,20);
  83.             glVertex2d (-90, 0);
  84.             glEnd();
  85.  
  86.  
  87.             glColor3ub (255,255,255);
  88.             glBegin(GL_POLYGON);
  89.             glVertex2d (90,400);
  90.             glVertex2d (90,420);
  91.             glVertex2d (-90,420);
  92.             glVertex2d (-90, 400);
  93.             glEnd();
  94.  
  95.  
  96.  
  97.  
  98.             //right 1st
  99.  
  100.             glColor3ub (255,255,255);
  101.             glBegin(GL_POLYGON);
  102.             glVertex2d (200,0);
  103.             glVertex2d (200,360);
  104.             glVertex2d (220,360);
  105.             glVertex2d (220, 0);
  106.             glEnd();
  107.  
  108.  
  109.             glColor3ub (255,255,255);
  110.             glBegin(GL_POLYGON);
  111.             glVertex2d (280,0);
  112.             glVertex2d (280,360);
  113.             glVertex2d (300,360);
  114.             glVertex2d (300, 0);
  115.             glEnd();
  116.  
  117.  
  118.             glColor3ub (255,255,255);
  119.             glBegin(GL_POLYGON);
  120.             glVertex2d (200,0);
  121.             glVertex2d (300,0);
  122.             glVertex2d (300,20);
  123.             glVertex2d (200, 20);
  124.             glEnd();
  125.  
  126.  
  127.             glColor3ub (255,255,255);
  128.             glBegin(GL_POLYGON);
  129.             glVertex2d (200,380);
  130.             glVertex2d (200,360);
  131.             glVertex2d (300,360);
  132.             glVertex2d (300, 380);
  133.             glEnd();
  134.  
  135.  
  136.              //left 1st
  137.  
  138.             glColor3ub (255,255,255);
  139.             glBegin(GL_POLYGON);
  140.             glVertex2d (-200,0);
  141.             glVertex2d (-200,360);
  142.             glVertex2d (-220,360);
  143.             glVertex2d (-220, 0);
  144.             glEnd();
  145.  
  146.  
  147.             glColor3ub (255,255,255);
  148.             glBegin(GL_POLYGON);
  149.             glVertex2d (-280,0);
  150.             glVertex2d (-280,360);
  151.             glVertex2d (-300,360);
  152.             glVertex2d (-300, 0);
  153.             glEnd();
  154.  
  155.  
  156.             glColor3ub (255,255,255);
  157.             glBegin(GL_POLYGON);
  158.             glVertex2d (-200,0);
  159.             glVertex2d (-300,0);
  160.             glVertex2d (-300,20);
  161.             glVertex2d (-200, 20);
  162.             glEnd();
  163.  
  164.  
  165.             glColor3ub (255,255,255);
  166.             glBegin(GL_POLYGON);
  167.             glVertex2d (-200,380);
  168.             glVertex2d (-200,360);
  169.             glVertex2d (-300,360);
  170.             glVertex2d (-300, 380);
  171.             glEnd();
  172.  
  173.  
  174.              //right 2nd
  175.  
  176.             glColor3ub (255,255,255);
  177.             glBegin(GL_POLYGON);
  178.             glVertex2d (410,0);
  179.             glVertex2d (410,330);
  180.             glVertex2d (430,330);
  181.             glVertex2d (430, 0);
  182.             glEnd();
  183.  
  184.  
  185.             glColor3ub (255,255,255);
  186.             glBegin(GL_POLYGON);
  187.             glVertex2d (490,0);
  188.             glVertex2d (490,330);
  189.             glVertex2d (510,330);
  190.             glVertex2d (510, 0);
  191.             glEnd();
  192.  
  193.  
  194.             glColor3ub (255,255,255);
  195.             glBegin(GL_POLYGON);
  196.             glVertex2d (410,0);
  197.             glVertex2d (510,0);
  198.             glVertex2d (510,20);
  199.             glVertex2d (410, 20);
  200.             glEnd();
  201.  
  202.  
  203.             glColor3ub (255,255,255);
  204.             glBegin(GL_POLYGON);
  205.             glVertex2d (410,310);
  206.             glVertex2d (510,310);
  207.             glVertex2d (510,330);
  208.             glVertex2d (410, 330);
  209.             glEnd();
  210.  
  211.  
  212.             //left 2nd
  213.  
  214.             glColor3ub (255,255,255);
  215.             glBegin(GL_POLYGON);
  216.             glVertex2d (-410,0);
  217.             glVertex2d (-410,330);
  218.             glVertex2d (-430,330);
  219.             glVertex2d (-430, 0);
  220.             glEnd();
  221.  
  222.  
  223.             glColor3ub (255,255,255);
  224.             glBegin(GL_POLYGON);
  225.             glVertex2d (-490,0);
  226.             glVertex2d (-490,330);
  227.             glVertex2d (-510,330);
  228.             glVertex2d (-510, 0);
  229.             glEnd();
  230.  
  231.  
  232.             glColor3ub (255,255,255);
  233.             glBegin(GL_POLYGON);
  234.             glVertex2d (-410,0);
  235.             glVertex2d (-510,0);
  236.             glVertex2d (-510,20);
  237.             glVertex2d (-410, 20);
  238.             glEnd();
  239.  
  240.  
  241.             glColor3ub (255,255,255);
  242.             glBegin(GL_POLYGON);
  243.             glVertex2d (-410,310);
  244.             glVertex2d (-510,310);
  245.             glVertex2d (-510,330);
  246.             glVertex2d (-410, 330);
  247.             glEnd();
  248.  
  249.             glFlush ();
  250. }
  251.     void init (void)
  252.             {
  253.             /* select clearing (background) color */
  254.             glColor3f(0.68, 0.85, 0.9);
  255.             /* initialize viewing values */
  256.             glMatrixMode(GL_PROJECTION);
  257.             glLoadIdentity();
  258.             gluOrtho2D(-600, 600, -100, 500);
  259.     }
  260.  
  261.  
  262.     /*
  263.     * Declare initial window size, position, and display mode
  264.     * (single buffer and RGBA). Open window with "hello"
  265.     * in its title bar. Call initialization routines.
  266.     * Register callback function to display graphics.
  267.     * Enter main loop and process events.
  268.     */
  269.     int main(int argc, char** argv){
  270.             glutInit(&argc, argv);
  271.             glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
  272.             glutInitWindowSize (1200, 700);
  273.             glutInitWindowPosition (0, 0);
  274.             glutCreateWindow ("M. Onirban 143-15-4385 Shahid Minar");
  275.             init ();
  276.             glutDisplayFunc(display);
  277.             glutMainLoop();
  278.             return 0; /* ISO C requires main to return int. */
  279.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement