Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include "GL\glew.h"
  5. #include "GL\freeglut.h"
  6.  
  7. char * shaderLoadSource(const char *filePath);
  8. // funkcja generująca scenę 3D
  9.  
  10.  
  11. void trojkat()
  12. {
  13. glBegin( GL_TRIANGLES );
  14.  
  15. glColor3f( 0.0f, 0.0f, 1.0f );
  16. glVertex3f( 0.0f, 0.0f, 0.0f );
  17. glVertex3f( 0.33f, 0.0f, 0.0f);
  18. glVertex3f( 0.0f, 0.33f, 0.0f );
  19.  
  20. glColor3f( 1.0f, 0.65f, 0.0f );
  21. glVertex3f( 0.33f, 0.0f, 0.0f );
  22. glVertex3f( 0.66f, 0.0f, 0.0f);
  23. glVertex3f( 0.33f, 0.33f, 0.0f );
  24.  
  25. glColor3f( 1.0f, 0.65f, 1.0f );
  26. glVertex3f( 0.66f, 0.0f, 0.0f );
  27. glVertex3f( 0.99f, 0.0f, 0.0f);
  28. glVertex3f( 0.66f, 0.33f, 0.0f );
  29.  
  30. glColor3f( 0.0f, 1.0f, 0.0f );
  31. glVertex3f( 0.0f, 0.33f, 0.0f );
  32. glVertex3f( 0.0f, 0.66f, 0.0f);
  33. glVertex3f( 0.33f, 0.33f, 0.0f );
  34.  
  35. glColor3f( 1.0f, 1.0f, 0.0f );
  36. glVertex3f( 0.33f, 0.33f, 0.0f );
  37. glVertex3f( 0.33f, 0.66f, 0.0f);
  38. glVertex3f( 0.66f, 0.33f, 0.0f );
  39.  
  40. glColor3f( 1.0f, 0.0f, 0.0f );
  41. glVertex3f( 0.0f, 0.66f, 0.0f );
  42. glVertex3f( 0.0f, 0.99f, 0.0f);
  43. glVertex3f( 0.33f, 0.66f, 0.0f );
  44.  
  45. glEnd();
  46. }
  47.  
  48. void linie()
  49. {
  50. glBegin( GL_LINE_LOOP );
  51. glColor3f( 0.0f, 0.0f, 0.0f );
  52. glVertex3f( 0.0f, 0.0f, 0.0f);
  53. glVertex3f( 0.99f, 0.0f, 0.0f );
  54. glVertex3f( 0.0f, 0.99f, 0.0f);
  55.  
  56. glVertex3f( 0.0f, 0.0f, 0.0f);
  57. glVertex3f( 0.66f, 0.0f, 0.0f );
  58. glVertex3f( 0.0f, 0.66f, 0.0f);
  59.  
  60. glVertex3f( 0.0f, 0.0f, 0.0f);
  61. glVertex3f( 0.33f, 0.0f, 0.0f );
  62. glVertex3f( 0.0f, 0.33f, 0.0f);
  63.  
  64. glEnd();
  65. }
  66.  
  67.  
  68. void Display()
  69. {
  70. // kolor tła - zawartość bufora koloru
  71. glClearColor( 1, 1, 1, 1 );
  72. // czyszczenie bufora koloru
  73. glClear( GL_COLOR_BUFFER_BIT );
  74.  
  75.  
  76.  
  77. trojkat();
  78. linie();
  79. glFlush();
  80. glRotatef(90, 0, 0, 1);
  81. //trojkat();
  82.  
  83. // zamiana buforów koloru
  84. glutSwapBuffers();
  85. }
  86.  
  87. int main( int argc, char * argv[] )
  88. {
  89. // inicjalizacja biblioteki GLUT
  90. glutInit( & argc, argv );
  91.  
  92. // inicjalizacja bufora ramki
  93. glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB );
  94.  
  95. // rozmiary głównego okna programu
  96. glutInitWindowSize( 640, 640 );
  97.  
  98. // utworzenie głównego okna programu
  99. glutCreateWindow( "Dupa" );
  100.  
  101. // dołączenie funkcji generującej scenę 3D
  102. glutDisplayFunc( Display );
  103.  
  104. // wprowadzenie programu do obsługi pętli komunikatów
  105. glutMainLoop();
  106. return 0;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement