Advertisement
ALTEK

ZadDisplay

Jun 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <GL/glut.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7. #include <math.h>
  8.  
  9. int screenWidth = 1000;
  10. int screenHeight = 600;
  11.  
  12. GLfloat Points[4][3] = {
  13. {-5.0f,1.0f,1.0f},
  14. { -9.0f,5.0f,1.0f },
  15. { -1.0f,6.0f,1.0f },
  16. { -2.0f,2.0f,1.0f }
  17.  
  18. };
  19.  
  20. void initScene() {
  21. glEnable(GL_DEPTH_TEST);
  22. glEnable(GL_MAP1_VERTEX_3);
  23. glEnable(GL_POINT_SMOOTH);
  24. }
  25. void display() {
  26. glClearColor(0.0, 0.0, 0.0, 0.0);
  27. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  28. glLoadIdentity();
  29. glTranslatef(0, 0, -40.0f);
  30. glColor3f(1.0f, 0.0f, 0.0f);
  31. glutSolidCube(1);
  32. glutSwapBuffers();
  33. glutPostRedisplay();
  34.  
  35. }
  36. void reshape(int w, int h) {
  37. glViewport(0, 0, (GLsizei)w, (GLsizei)h);
  38. glMatrixMode(GL_PROJECTION);
  39. glLoadIdentity();
  40. gluPerspective(50,(float)w/h,0.1,1000);
  41. glMatrixMode(GL_MODELVIEW);
  42. glLoadIdentity();
  43.  
  44. }
  45.  
  46. int main(int argc, char *argv[])
  47. {
  48. glutInit(&argc, argv);
  49. glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE);
  50. glutInitWindowSize(screenWidth, screenHeight);
  51. glutCreateWindow(argv[0]);
  52. initScene();
  53. glutIdleFunc(display);
  54. glutDisplayFunc(display);
  55. glutReshapeFunc(reshape);
  56. glutMainLoop();
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement