Advertisement
Guest User

Untitled

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