Advertisement
tareqmahmud9

Draw_A

Apr 14th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. #pragma comment (lib,"glut32.lib")
  2.  
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5. #include<math.h>
  6.  
  7. #include<GL/glut.h>
  8.  
  9. #define BLACK 0.9, .9, 0.9
  10.  
  11. void display(){
  12.  
  13.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  14.     glClearColor(BLACK, 0); //color black
  15.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  16.  
  17.     glMatrixMode(GL_MODELVIEW);
  18.  
  19.     glLoadIdentity();
  20.  
  21.     gluLookAt( .01,  0, 150,   0,0,0,   0,0,1);
  22.  
  23.     glMatrixMode(GL_MODELVIEW);
  24.  
  25.  
  26.     /****************************
  27.     / Add your objects from here
  28.     ****************************/
  29.     /*
  30.         Task: Draw A
  31.     */
  32.  
  33.     glColor3f(1, 0, 0);
  34.     glBegin(GL_LINES);{
  35.         float i=50;
  36.         // Vertical Line |
  37.         glVertex3f(-i,0,0);//x
  38.         glVertex3f(i,-50,0);
  39.  
  40.         // Vertical Line |
  41.         glColor3f(1, 0, 0);
  42.         glVertex3f(i,50,0);//x
  43.         glVertex3f(-i,0,0);
  44.  
  45.         // Horizontal Line ---
  46.         glColor3f(.75, 0, .55);
  47.         glVertex3f(0,-25,0);//y
  48.         glVertex3f(0,25,0);
  49.  
  50.     }glEnd();
  51.     glutSwapBuffers();
  52. }
  53.  
  54. void animate(){
  55.     //codes for any changes in Models, Camera
  56. }
  57.  
  58. void init(){
  59.     //codes for initialization
  60.  
  61.     //clear the screen
  62.     glClearColor(BLACK, 0);
  63.  
  64.     /************************
  65.     / set-up projection here
  66.     ************************/
  67.     //load the PROJECTION matrix
  68.     glMatrixMode(GL_PROJECTION);
  69.  
  70.     //initialize the matrix
  71.     glLoadIdentity();
  72.  
  73.     //give PERSPECTIVE parameters
  74.     gluPerspective(7010.1,    10000.0);
  75.     //field of view in the Y (vertically)
  76.     //aspect ratio that determines the field of view in the X direction (horizontally)
  77.     //near distance
  78.     //far distance
  79. }
  80.  
  81. int main(int argc, char **argv){
  82.     glutInit(&argc,argv);
  83.     glutInitWindowSize(500, 500);
  84.     glutInitWindowPosition(0, 0);
  85.     glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);   //Depth, Double buffer, RGB color
  86.  
  87.     glutCreateWindow("My OpenGL Program");
  88.  
  89.     init();
  90.  
  91.     glEnable(GL_DEPTH_TEST);    //enable Depth Testing
  92.  
  93.     glutDisplayFunc(display);   //display callback function
  94.     glutIdleFunc(animate);      //what you want to do in the idle time (when no drawing is occuring)
  95.  
  96.     glutMainLoop();     //The main loop of OpenGL
  97.  
  98.     return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement