Advertisement
raisul2010

1stLab

Feb 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. //Write a program using openGL to draw some points
  2.  
  3. #include<windows.h>
  4. #include<stdio.h>
  5. #include<stdlib.h>
  6. #include<GL/glut.h>
  7.  
  8. void myInit(void)
  9. {
  10. glClearColor(1.0, 1.0, 1.0, 0.0); //BG color is white
  11. glColor3f(0.0f,0.0f,0.0f); //drawing color is black
  12. glPointSize(4.0);// a dot is 2 by 2 pixels
  13.  
  14. //init view (simple orthographic projection)
  15. glMatrixMode(GL_PROJECTION);
  16. glLoadIdentity();
  17. glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);
  18. //set the viewing coordinates
  19. gluOrtho2D(0.0,640.0,0.0,480.0);
  20. }
  21. void myDisplay(void)
  22. {
  23. glClear(GL_COLOR_BUFFER_BIT); //clear the screen
  24. glBegin(GL_POINTS);
  25. {
  26. glVertex2i(20,10);
  27. glVertex2i(50,10);
  28. glVertex2i(20,80);
  29. glVertex2i(50,80);
  30. }
  31. glEnd();
  32. glFlush();
  33. }
  34. int main(int argc, char** argv)
  35. {
  36. glutInit(&argc,argv);//init the toolkit
  37. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //set the display
  38. glutInitWindowSize(640,480);//set window size
  39. //set window position on screen
  40. glutInitWindowPosition(100,150);
  41. //open the screen window and set the name
  42. glutCreateWindow("My First Window");
  43. //register the callback functions
  44. glutDisplayFunc(myDisplay);
  45. myInit();
  46. glutMainLoop(); //go into a perpetual loop
  47. return 1;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement