Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. double kat=0;
  2. #include <GL/glut.h>
  3.  
  4. void InitGL(void)
  5. {
  6. glClearColor(0.0, 0.8, 0.8, 0.0);
  7. glClearDepth( 1.0 );
  8. glEnable( GL_DEPTH_TEST ); //rysowanie z glebią ekranu
  9. }
  10. void Idle(void) {
  11. kat +=5;
  12. glutPostRedisplay();
  13. }
  14. void text(char*string)
  15. {
  16. char*p;
  17. for(p=string;*p;p++)
  18. glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *p);
  19. }
  20.  
  21. void reshape(int w, int h)
  22. {
  23. GLdouble aspect = (GLdouble) w / h;
  24. glViewport (0, 0, (GLsizei) w, (GLsizei) h);
  25. glMatrixMode(GL_PROJECTION); //macierz projekcji
  26. glLoadIdentity(); //zerowanie macierzy
  27. if (w <= h)
  28. glOrtho(-250.0, 250, -250./ aspect, 250.0/ aspect, -100, 100);
  29. else
  30. glOrtho (-250.*aspect, 250.*aspect, -250, 250, -100.0, 100);
  31. glMatrixMode(GL_MODELVIEW); //macierz wyglądu
  32. glLoadIdentity();
  33.  
  34. }
  35.  
  36. void displayCallBack(void)
  37. {
  38. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //czyszczenie buforów
  39.  
  40. glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  41. glColor3d(0.1,0.3,0);
  42. glRotatef(kat, 1.0, 0.0, 0.0);
  43. glRotatef(15, 1, 1, 0);
  44. glRotatef(15,0,1,0);
  45. glutSolidCube(100);
  46.  
  47. glLoadIdentity();
  48. glColor3d(0,0,0);
  49. glRasterPos2f(-200,200);
  50. text("Biblioteka GLUT:teskst");
  51.  
  52. glFlush();
  53.  
  54. glutSwapBuffers(); //zamienia bufory
  55. }
  56.  
  57. void main(int argc, char** argv)
  58. {
  59. glutInit(&argc, argv);
  60.  
  61. glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
  62. glutInitWindowSize(600, 600);
  63. glutCreateWindow("Program_1");
  64.  
  65.  
  66. InitGL();
  67.  
  68. float pos[4] = { 1.50F, 3.50F, 0.25F, 0.00F };
  69. float dir[3] = {-1, -1, -1};
  70. glEnable(GL_COLOR_MATERIAL);
  71. glEnable(GL_LIGHTING);
  72. glEnable(GL_LIGHT0);
  73.  
  74. glLightfv(GL_LIGHT0, GL_POSITION, pos);
  75. glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir);
  76.  
  77.  
  78. glutReshapeFunc(reshape);
  79. glutDisplayFunc(displayCallBack);
  80. glutIdleFunc(Idle);
  81. glutMainLoop();
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement