daily pastebin goal
71%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <windows.h>
  2. #include "biblioteka.h"
  3. #ifdef __APPLE__
  4. #include <GLUT/glut.h>
  5. #else
  6. #include <GL/glut.h>
  7. #endif
  8.  
  9. #include <stdlib.h>
  10.  
  11. #define LICZBA_OB_TEXTUR 6
  12. GLuint obiektyTextur [LICZBA_OB_TEXTUR];
  13. char *plikiTextur[LICZBA_OB_TEXTUR] = {"C:/Users/Patryk/Documents/Programy GLUT/Literka/woda.tga",
  14.                         "C:/Users/Patryk/Documents/Programy GLUT/Literka/szklo.tga",
  15.                         "C:/Users/Patryk/Documents/Programy GLUT/Literka/szklo.tga",
  16.                         "C:/Users/Patryk/Documents/Programy GLUT/Literka/woda.tga",
  17.                         "C:/Users/Patryk/Documents/Programy GLUT/Literka/woda.tga",
  18.                         "C:/Users/Patryk/Documents/Programy GLUT/Literka/woda.tga"};
  19.  
  20. static int slices = 16;
  21. static int stacks = 16;
  22.  
  23. GLfloat cut_2=30;
  24. GLfloat exp_2=100;
  25.  
  26. const GLfloat light_ambient[]  = { 0.0f, 0.0f, 0.0f, 0.0f };
  27. const GLfloat light_diffuse[]  = { 1.0f, 1.0f, 1.0f, 1.0f };
  28. const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
  29. GLfloat light_position[] = { 0.0f, 0.0f, -2.5f, -5.0f };
  30. GLfloat kierunek[]={0.0f, 0.0f, -1.0f};
  31.  
  32.  
  33. const GLfloat mat_ambient[]    = { 0.7f, 0.7f, 0.7f, 1.0f };
  34. const GLfloat mat_diffuse[]    = { 0.8f, 0.8f, 1.0f, 1.0f };
  35. const GLfloat mat_specular[]   = { 1.0f, 1.0f, 0.0f, 0.0f };
  36. const GLfloat high_shininess[] = { 10.0f };
  37.  
  38. int rzut, skala;
  39. int fovy = 90;
  40. int xx, yy, xz, yz, zx, obrot_x, obrot_y, yx, xy, zy;
  41. enum {ORTO, ASPECT_1_1, PERSP, FULL_WINDOW, EXIT, FRUST};
  42.  
  43.  
  44. float k=0;
  45. GLPVector3 vPoints[3] = {{0.0f, -1.0f, 0.0f},
  46. {1.0f, -1.0f, 0.0f},
  47. {0, -1.0f, -1.0f}};
  48.  
  49. GLPMatrix Macierz_cieni;
  50. GLPVector4 vLightPos= { 2.0f, 5.0f, 5.0f, 0.0f };
  51.  
  52.  
  53. float xpos = 0, ypos = 3.4, zpos = -2.4, xrot = 0, yrot = 0, angle=0.0;
  54. GLfloat density = 0.01;
  55.  
  56. GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1.0}; //set the for
  57. //color to grey
  58. ///cien
  59. static void display(void);
  60.  
  61. bool pokaz=false;
  62.  
  63. void Widok (void) {
  64.     glRotatef(xrot,1.0,0.0,0.0);  //prawo/lewo
  65.     glRotatef(yrot,0.0,1.0,0.0);  //gora/dol
  66.     glTranslated(-xpos,-ypos,-zpos);
  67. }
  68.  
  69.  
  70. void Podloga ()
  71. {
  72.  
  73.         glPushMatrix();
  74.     glTranslated(0,0.3,-7);
  75.   // glRotated(10,1,0,0);
  76.  
  77.  
  78.     double dx=0.5;
  79.     double dy=0.5;
  80.  
  81.     glBegin(GL_QUADS);
  82.     for(double x=-10;x<10;x+=dx)
  83.         for(double y=-20;y<20;y+=dy)
  84.     {
  85.         if(static_cast<int> ((x+y)/dx)%2==0)
  86.         glColor4f(0,0,0,0.5);
  87.         else
  88.         glColor4f(1,1,0,0.0);
  89.         glVertex3f(x,0,y);
  90.         glVertex3f(x,0,y+dy);
  91.         glVertex3f(x+dx,0,y+dy);
  92.         glVertex3f(x+dx,0,y);
  93.     }
  94.     glEnd();
  95.     glPopMatrix();
  96. }
  97. void Literka() //Podstawa
  98. {
  99.  
  100.      glPushMatrix();
  101.     glTranslated(-2,0.3,-7);
  102.        glColor3d(0, 0, 0);
  103.  
  104.        glPushMatrix();
  105.     glTranslated(0,0.3,-7);
  106.        glColor3d(0, 0, 0);
  107.  
  108.  
  109.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[4]);
  110.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  111.     glTexCoord2f(0.0f,0.0f);
  112.     glVertex3f(0.0f, 0.0f, 2.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  113.     glTexCoord2f(1.0f,0.0f);
  114.     glVertex3f(2.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  115.     glTexCoord2f(1.0f,1.0f);
  116.     glVertex3f(2.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  117.     glTexCoord2f(0.0f,1.0f);
  118.     glVertex3f(0.0f, 2.0f, 2.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  119.  
  120.     glEnd();
  121.  
  122.  
  123.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  124.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  125.     glTexCoord2f(0.0f,0.0f);
  126.     glVertex3f(0.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  127.     glTexCoord2f(1.0f,0.0f);
  128.     glVertex3f(2.0f, 0.0f, 0.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  129.     glTexCoord2f(1.0f,1.0f);
  130.     glVertex3f(2.0f, 2.0f, 0.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  131.     glTexCoord2f(0.0f,1.0f);
  132.     glVertex3f(0.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  133.     glEnd();
  134.  
  135.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  136.  
  137.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  138.     glTexCoord2f(0.0f,0.0f);
  139.     glVertex3f(0.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  140.     glTexCoord2f(1.0f,0.0f);
  141.     glVertex3f(0.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  142.     glTexCoord2f(1.0f,1.0f);
  143.     glVertex3f(0.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  144.     glTexCoord2f(0.0f,1.0f);
  145.     glVertex3f(0.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  146.     glEnd();
  147.  
  148.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  149.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  150.     glTexCoord2f(0.0f,0.0f);
  151.     glVertex3f(2.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  152.     glTexCoord2f(1.0f,0.0f);
  153.     glVertex3f(2.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  154.     glTexCoord2f(1.0f,1.0f);
  155.     glVertex3f(2.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  156.     glTexCoord2f(0.0f,1.0f);
  157.     glVertex3f(2.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  158.     glEnd();
  159.  
  160.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[4]);
  161.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  162.     glTexCoord2f(0.0f,0.0f);
  163.     glVertex3f(0.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  164.     glTexCoord2f(1.0f,0.0f);
  165.     glVertex3f(0.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  166.     glTexCoord2f(1.0f,1.0f);
  167.     glVertex3f(2.0f, 0.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  168.     glTexCoord2f(0.0f,1.0f);
  169.     glVertex3f(2.0f, 0.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  170.     glEnd();
  171.  
  172.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  173.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  174.     glTexCoord2f(0.0f,0.0f);
  175.     glVertex3f(0.0f, 2.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  176.     glTexCoord2f(1.0f,0.0f);
  177.     glVertex3f(0.0f, 2.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  178.     glTexCoord2f(1.0f,1.0f);
  179.     glVertex3f(2.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  180.     glTexCoord2f(0.0f,1.0f);
  181.     glVertex3f(2.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  182.     glEnd();
  183.  
  184.     glPopMatrix();
  185.  
  186.  
  187.     glPushMatrix();
  188.     glTranslated(0,2.3,-7);
  189.         glColor3d(0, 0, 0);
  190.  
  191.  
  192.  
  193.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  194.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  195.     glTexCoord2f(0.0f,0.0f);
  196.     glVertex3f(0.0f, 0.0f, 2.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  197.     glTexCoord2f(1.0f,0.0f);
  198.     glVertex3f(2.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  199.     glTexCoord2f(1.0f,1.0f);
  200.     glVertex3f(2.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  201.     glTexCoord2f(0.0f,1.0f);
  202.     glVertex3f(0.0f, 2.0f, 2.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  203.  
  204.     glEnd();
  205.  
  206.  
  207.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  208.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  209.     glTexCoord2f(0.0f,0.0f);
  210.     glVertex3f(0.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  211.     glTexCoord2f(1.0f,0.0f);
  212.     glVertex3f(2.0f, 0.0f, 0.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  213.     glTexCoord2f(1.0f,1.0f);
  214.     glVertex3f(2.0f, 2.0f, 0.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  215.     glTexCoord2f(0.0f,1.0f);
  216.     glVertex3f(0.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  217.     glEnd();
  218.  
  219.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  220.  
  221.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  222.     glTexCoord2f(0.0f,0.0f);
  223.     glVertex3f(0.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  224.     glTexCoord2f(1.0f,0.0f);
  225.     glVertex3f(0.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  226.     glTexCoord2f(1.0f,1.0f);
  227.     glVertex3f(0.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  228.     glTexCoord2f(0.0f,1.0f);
  229.     glVertex3f(0.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  230.     glEnd();
  231.  
  232.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  233.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  234.     glTexCoord2f(0.0f,0.0f);
  235.     glVertex3f(2.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  236.     glTexCoord2f(1.0f,0.0f);
  237.     glVertex3f(2.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  238.     glTexCoord2f(1.0f,1.0f);
  239.     glVertex3f(2.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  240.     glTexCoord2f(0.0f,1.0f);
  241.     glVertex3f(2.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  242.     glEnd();
  243.  
  244.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  245.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  246.     glTexCoord2f(0.0f,0.0f);
  247.     glVertex3f(0.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  248.     glTexCoord2f(1.0f,0.0f);
  249.     glVertex3f(0.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  250.     glTexCoord2f(1.0f,1.0f);
  251.     glVertex3f(2.0f, 0.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  252.     glTexCoord2f(0.0f,1.0f);
  253.     glVertex3f(2.0f, 0.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  254.     glEnd();
  255.  
  256.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  257.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  258.     glTexCoord2f(0.0f,0.0f);
  259.     glVertex3f(0.0f, 2.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  260.     glTexCoord2f(1.0f,0.0f);
  261.     glVertex3f(0.0f, 2.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  262.     glTexCoord2f(1.0f,1.0f);
  263.     glVertex3f(2.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  264.     glTexCoord2f(0.0f,1.0f);
  265.     glVertex3f(2.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  266.     glEnd();
  267.  
  268.     glPopMatrix();
  269.  
  270.  
  271.     glPushMatrix();
  272.     glTranslated(0,4.3,-7);
  273.         glColor3d(0, 0, 0);
  274.  
  275.  
  276.  
  277.     glBindTexture(GL_TEXTURE_2D, obiektyTextur[2]);
  278.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  279.     glTexCoord2f(0.0f,0.0f);
  280.     glVertex3f(0.0f, 0.0f, 2.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  281.     glTexCoord2f(1.0f,0.0f);
  282.     glVertex3f(2.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  283.     glTexCoord2f(1.0f,1.0f);
  284.     glVertex3f(2.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  285.     glTexCoord2f(0.0f,1.0f);
  286.     glVertex3f(0.0f, 2.0f, 2.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  287.  
  288.     glEnd();
  289.  
  290.  
  291.     glBindTexture (GL_TEXTURE_2D, obiektyTextur[0]);
  292.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  293.     glTexCoord2f(0.0f,0.0f);
  294.     glVertex3f(0.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  295.     glTexCoord2f(1.0f,0.0f);
  296.     glVertex3f(2.0f, 0.0f, 0.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  297.     glTexCoord2f(1.0f,1.0f);
  298.     glVertex3f(2.0f, 2.0f, 0.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  299.     glTexCoord2f(0.0f,1.0f);
  300.     glVertex3f(0.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  301.     glEnd();
  302.  
  303.     glBindTexture (GL_TEXTURE_2D, obiektyTextur[1]);
  304.  
  305.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  306.     glTexCoord2f(0.0f,0.0f);
  307.     glVertex3f(0.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  308.     glTexCoord2f(1.0f,0.0f);
  309.     glVertex3f(0.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  310.     glTexCoord2f(1.0f,1.0f);
  311.     glVertex3f(0.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  312.     glTexCoord2f(0.0f,1.0f);
  313.     glVertex3f(0.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  314.     glEnd();
  315.  
  316.     glBindTexture (GL_TEXTURE_2D, obiektyTextur[3]);
  317.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  318.     glTexCoord2f(0.0f,0.0f);
  319.     glVertex3f(2.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  320.     glTexCoord2f(1.0f,0.0f);
  321.     glVertex3f(2.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  322.     glTexCoord2f(1.0f,1.0f);
  323.     glVertex3f(2.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  324.     glTexCoord2f(0.0f,1.0f);
  325.     glVertex3f(2.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  326.     glEnd();
  327.  
  328.     glBindTexture (GL_TEXTURE_2D, obiektyTextur[2]);
  329.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  330.     glTexCoord2f(0.0f,0.0f);
  331.     glVertex3f(0.0f, 0.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  332.     glTexCoord2f(1.0f,0.0f);
  333.     glVertex3f(0.0f, 0.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  334.     glTexCoord2f(1.0f,1.0f);
  335.     glVertex3f(2.0f, 0.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  336.     glTexCoord2f(0.0f,1.0f);
  337.     glVertex3f(2.0f, 0.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  338.     glEnd();
  339.  
  340.     glBindTexture (GL_TEXTURE_2D, obiektyTextur[4]);
  341.     glBegin(GL_QUADS); // obiekt podstawowy kwadrat
  342.     glTexCoord2f(0.0f,0.0f);
  343.     glVertex3f(0.0f, 2.0f, 0.0f); // zdefiniowanie pierwszego wierzcho3ka kwadratu
  344.     glTexCoord2f(1.0f,0.0f);
  345.     glVertex3f(0.0f, 2.0f, 2.0f); // zdefiniowanie drugiego wierzcho3ka kwadratu
  346.     glTexCoord2f(1.0f,1.0f);
  347.     glVertex3f(2.0f, 2.0f, 2.0f); // zdefiniowanie trzeciego wierzcho3ka kwadratu
  348.     glTexCoord2f(0.0f,1.0f);
  349.     glVertex3f(2.0f, 2.0f, 0.0f); // zdefiniowanie czwartego wierzcho3ka kwadratu
  350.     glEnd();
  351.  
  352.     glPopMatrix();
  353.  
  354.  
  355.  
  356. //*************************************************************************************************************************************
  357. //*************************************************************************************************************************************
  358. //*************************************************************************************************************************************
  359.  
  360.  
  361. //Gorna czesc litery(brzuszek)
  362.  
  363.     glPushMatrix();
  364.  
  365.     glTranslatef(2,4,2);
  366. glRotatef(0,0,1,0);
  367. glColor3d(0, 0, 0);
  368.         glTranslated(-2,7.2,-8);
  369.         glRotated(90,1,0,0);
  370.  
  371. glPushMatrix();
  372.  glColor3d(0, 0, 0);
  373.         {glRotated(0,0,0,1);}
  374.         glBindTexture (GL_TEXTURE_2D, obiektyTextur[4]);
  375. glBegin(GL_POLYGON);
  376.     glTexCoord2f(1.0f,1.0f);
  377.     glVertex3f(0,1,5);
  378.     glTexCoord2f(0.0f,1.0f);
  379.     glVertex3f(0,1,0);
  380.  
  381.     glTexCoord2f(0.0f,0.0f);
  382.     glVertex3f(0,0,0);
  383.     glTexCoord2f(1.0f,0.0f);
  384.     glVertex3f(0,0,5);
  385. glEnd();
  386. glBindTexture (GL_TEXTURE_2D, obiektyTextur[4]);
  387. glBegin(GL_POLYGON);
  388.  glTexCoord2f(1.0f,1.0f);
  389. glVertex3f(0,0,5);
  390.    glTexCoord2f(0.0f,1.0f);
  391.     glVertex3f(3,0,5);
  392.      glTexCoord2f(0.0f,0.0f);
  393.     glVertex3f(3,1,5);
  394.     glTexCoord2f(1.0f,0.0f);
  395.      glVertex3f(0,1,5);
  396. glEnd();
  397. glBindTexture (GL_TEXTURE_2D, obiektyTextur[4]);
  398. glBegin(GL_POLYGON);
  399.  glTexCoord2f(1.0f,1.0f);
  400.  glVertex3f(3,1,5);
  401.   glTexCoord2f(0.0f,1.0f);
  402.     glVertex3f(3,0,5);
  403.     glTexCoord2f(0.0f,0.0f);
  404.     glVertex3f(4,0,4);
  405.     glTexCoord2f(1.0f,0.0f);
  406.     glVertex3f(4,1,4);
  407.  glEnd();
  408. glBindTexture (GL_TEXTURE_2D, obiektyTextur[4]);
  409.  glBegin(GL_POLYGON);
  410.  glTexCoord2f(1.0f,1.0f);
  411.  
  412.     glVertex3f(4,1,4);
  413.      glTexCoord2f(0.0f,1.0f);
  414.     glVertex3f(4,0,4);
  415.     glTexCoord2f(0.0f,0.0f);
  416.     glVertex3f(4,0,1);
  417.     glTexCoord2f(1.0f,0.0f);
  418.     glVertex3f(4,1,1);
  419.  glEnd();
  420. glBindTexture (GL_TEXTURE_2D, obiektyTextur[4]);
  421. glBegin(GL_POLYGON);
  422.  glTexCoord2f(1.0f,1.0f);
  423.  
  424.     glVertex3f(4,1,1);
  425.       glTexCoord2f(0.0f,1.0f);
  426.     glVertex3f(4,0,1);
  427.     glTexCoord2f(0.0f,0.0f);
  428.  
  429.     glVertex3f(3,0,0);
  430.        glTexCoord2f(1.0f,0.0f);
  431.      glVertex3f(3,1,0);
  432.  glEnd();
  433.  
  434. glPopMatrix();
  435. glBindTexture (GL_TEXTURE_2D, obiektyTextur[2]);
  436. glBegin(GL_POLYGON);
  437.  glTexCoord2f(1.0f,1.0f);
  438.  
  439.     glVertex3f(3,1,0);
  440.      glTexCoord2f(0.0f,1.0f);
  441.     glVertex3f(3,0,0);
  442.     glTexCoord2f(0.0f,0.0f);
  443.     glVertex3f(0,0,0);
  444.      glTexCoord2f(1.0f,0.0f);
  445.      glVertex3f(0,1,0);
  446.  
  447.  glEnd();
  448.  
  449. glBindTexture (GL_TEXTURE_2D, obiektyTextur[2]);
  450.     glBegin(GL_POLYGON);
  451.           glTexCoord2f(1.0f,1.0f);
  452.             glVertex3f(0,0,0);
  453.               glTexCoord2f(0.0f,1.0f);
  454.             glVertex3f(1,0,0);
  455.              glTexCoord2f(0.0f,0.0f);
  456.             glVertex3f(1,0,5);
  457.              glTexCoord2f(1.0f,0.0f);
  458.  
  459.             glVertex3f(0,0,5);
  460.     glEnd();
  461. glBindTexture (GL_TEXTURE_2D, obiektyTextur[2]);
  462.     glBegin(GL_POLYGON);
  463.      glTexCoord2f(1.0f,1.0f);
  464.             glVertex3f(1,0,0);
  465.              glTexCoord2f(0.0f,1.0f);
  466.             glVertex3f(3,0,0);
  467.             glTexCoord2f(0.0f,0.0f);
  468.             glVertex3f(2.5,0,1);
  469.             glTexCoord2f(1.0f,0.0f);
  470.             glVertex3f(1,0,1);
  471.         glEnd();
  472. glBindTexture (GL_TEXTURE_2D, obiektyTextur[2]);
  473.     glBegin(GL_POLYGON);
  474.     glTexCoord2f(1.0f,1.0f);
  475.             glVertex3f(3,0,0);
  476.              glTexCoord2f(0.0f,1.0f);
  477.             glVertex3f(4,0,1);
  478.             glTexCoord2f(0.0f,0.0f);
  479.             glVertex3f(3,0,1.5);
  480.             glTexCoord2f(1.0f,0.0f);
  481.             glVertex3f(2.5,0,1);
  482.         glEnd();
  483. glBindTexture (GL_TEXTURE_2D, obiektyTextur[3]);
  484.     glBegin(GL_POLYGON);
  485.     glTexCoord2f(1.0f,1.0f);
  486.             glVertex3f(4,0,1);
  487.             glTexCoord2f(0.0f,1.0f);
  488.             glVertex3f(4,0,4);
  489.             glTexCoord2f(0.0f,0.0f);
  490.             glVertex3f(3,0,3.5);
  491.                 glTexCoord2f(1.0f,0.0f);
  492.             glVertex3f(3,0,1.5);
  493.         glEnd();
  494. glBindTexture (GL_TEXTURE_2D, obiektyTextur[1]);
  495.     glBegin(GL_POLYGON);
  496.     glTexCoord2f(1.0f,1.0f);
  497.             glVertex3f(3,0,3.5);
  498.             glTexCoord2f(0.0f,1.0f);
  499.             glVertex3f(4,0,4);
  500.             glTexCoord2f(0.0f,0.0f);
  501.             glVertex3f(3,0,5);
  502.                 glTexCoord2f(1.0f,0.0f);
  503.             glVertex3f(2.5,0,4);
  504.     glEnd();
  505. glBindTexture (GL_TEXTURE_2D, obiektyTextur[3]);
  506.     glBegin(GL_POLYGON);
  507.     glTexCoord2f(1.0f,1.0f);
  508.             glVertex3f(3,0,5);
  509.             glTexCoord2f(0.0f,1.0f);
  510.             glVertex3f(1,0,5);
  511.             glTexCoord2f(0.0f,0.0f);
  512.             glVertex3f(1,0,4);
  513.             glTexCoord2f(1.0f,0.0f);
  514.             glVertex3f(2.5,0,4);
  515.     glEnd();
  516.  
  517.  
  518. glBindTexture (GL_TEXTURE_2D, obiektyTextur[4]);
  519.     glTranslated(0,1,0);
  520.           glBegin(GL_POLYGON);
  521.           glTexCoord2f(1.0f,1.0f);
  522.           glVertex3f(1,0,0);
  523.           glTexCoord2f(0.0f,1.0f);
  524.           glVertex3f(0,0,0);
  525.           glTexCoord2f(0.0f,0.0f);
  526.           glVertex3f(0,0,5);
  527.           glTexCoord2f(1.0f,0.0f);
  528.           glVertex3f(1,0,5);
  529.     glEnd();
  530.  
  531.     glBegin(GL_POLYGON);
  532.     glTexCoord2f(1.0f,1.0f);
  533.             glVertex3f(3,0,0);
  534.             glTexCoord2f(0.0f,1.0f);
  535.             glVertex3f(1,0,0);
  536.             glTexCoord2f(0.0f,0.0f);
  537.             glVertex3f(1,0,1);
  538.             glTexCoord2f(1.0f,0.0f);
  539.             glVertex3f(2.5,0,1);
  540.  
  541.     glEnd();
  542.  
  543.     glBegin(GL_POLYGON);
  544.     glTexCoord2f(1.0f,1.0f);
  545.             glVertex3f(4,0,1);
  546.             glTexCoord2f(0.0f,1.0f);
  547.             glVertex3f(3,0,0);
  548.             glTexCoord2f(0.0f,0.0f);
  549.             glVertex3f(2.5,0,1);
  550.             glTexCoord2f(1.0f,0.0f);
  551.             glVertex3f(3,0,1.5);
  552.     glEnd();
  553.  
  554.     glBegin(GL_POLYGON);
  555.     glTexCoord2f(1.0f,1.0f);
  556.         glVertex3f(4,0,4);
  557.         glTexCoord2f(0.0f,1.0f);
  558.         glVertex3f(4,0,1);
  559.         glTexCoord2f(0.0f,0.0f);
  560.         glVertex3f(3,0,1.5);
  561.         glTexCoord2f(1.0f,0.0f);
  562.         glVertex3f(3,0,3.5);
  563.     glEnd();
  564.  
  565.     glBegin(GL_POLYGON);
  566.     glTexCoord2f(1.0f,1.0f);
  567.         glVertex3f(4,0,4);
  568.         glTexCoord2f(0.0f,1.0f);
  569.         glVertex3f(3,0,3.5);
  570.         glTexCoord2f(0.0f,0.0f);
  571.         glVertex3f(2.5,0,4);
  572.         glTexCoord2f(1.0f,0.0f);
  573.         glVertex3f(3,0,5);
  574.     glEnd();
  575.  
  576.     glBegin(GL_POLYGON);
  577.     glTexCoord2f(1.0f,1.0f);
  578.         glVertex3f(1,0,5);
  579.         glTexCoord2f(0.0f,1.0f);
  580.         glVertex3f(3,0,5);
  581.         glTexCoord2f(0.0f,0.0f);
  582.         glVertex3f(2.5,0,4);
  583.         glTexCoord2f(1.0f,0.0f);
  584.         glVertex3f(1,0,4);
  585.     glEnd();
  586.  
  587.  
  588.  
  589.  
  590.     glTranslated(0,-1,0);
  591.  
  592.     glBegin(GL_POLYGON);
  593.     glTexCoord2f(1.0f,1.0f);
  594.         glVertex3f(1,1,1);
  595.         glTexCoord2f(0.0f,1.0f);
  596.         glVertex3f(1,0,1);
  597.        glTexCoord2f(0.0f,0.0f);
  598.         glVertex3f(2.5,0,1);
  599.         glTexCoord2f(1.0f,0.0f);
  600.          glVertex3f(2.5,1,1);
  601.  
  602.     glEnd();
  603.  
  604. glBegin(GL_POLYGON);
  605.     glTexCoord2f(1.0f,1.0f);
  606.  
  607.         glVertex3f(2.5,1,1);
  608.         glTexCoord2f(0.0f,1.0f);
  609.         glVertex3f(2.5,0,1);
  610.         glTexCoord2f(0.0f,0.0f);
  611.         glVertex3f(3,0,1.5);
  612.         glTexCoord2f(1.0f,0.0f);
  613.         glVertex3f(3,1,1.5);
  614.     glEnd();
  615.  
  616. glBegin(GL_POLYGON);
  617.     glTexCoord2f(1.0f,1.0f);
  618.         glVertex3f(3,1,1.5);
  619.         glTexCoord2f(0.0f,1.0f);
  620.         glVertex3f(3,0,1.5);
  621.         glTexCoord2f(0.0f,0.0f);
  622.         glVertex3f(3,0,3.5);
  623.         glTexCoord2f(1.0f,0.0f);
  624.          glVertex3f(3,1,3.5);
  625.     glEnd();
  626.  
  627. glBegin(GL_POLYGON);
  628.     glTexCoord2f(1.0f,1.0f);
  629.  
  630.         glVertex3f(3,1,3.5);
  631.          glTexCoord2f(0.0f,1.0f);
  632.         glVertex3f(3,0,3.5);
  633.        glTexCoord2f(0.0f,0.0f);
  634.         glVertex3f(2.5,0,4);
  635.          glTexCoord2f(1.0f,0.0f);
  636.          glVertex3f(2.5,1,4);
  637.     glEnd();
  638.  
  639.  
  640. glBegin(GL_POLYGON);
  641.     glTexCoord2f(1.0f,1.0f);
  642.  
  643.         glVertex3f(2.5,1,4);
  644.         glTexCoord2f(0.0f,1.0f);
  645.         glVertex3f(2.5,0,4);
  646.         glTexCoord2f(0.0f,0.0f);
  647.          glVertex3f(1,0,4);
  648.         glTexCoord2f(1.0f,0.0f);
  649.  
  650.         glVertex3f(1,1,4);
  651.     glEnd();
  652.  
  653. glBegin(GL_POLYGON);
  654.     glTexCoord2f(1.0f,1.0f);
  655.  
  656.  
  657.         glVertex3f(1,1,4);
  658.          glTexCoord2f(0.0f,1.0f);
  659.         glVertex3f(1,0,4);
  660.         glTexCoord2f(0.0f,0.0f);
  661.        glVertex3f(1,0,1);
  662.         glTexCoord2f(1.0f,0.0f);
  663.          glVertex3f(1,1,1);
  664.     glEnd();
  665.  
  666. glPopMatrix();
  667.  
  668.     glPopMatrix();    //BIG BOY
  669. }
  670.  
  671.  
  672.  
  673. void Mgla (void)
  674. {
  675.  
  676. glEnable (GL_DEPTH_TEST); //enable the depth testing
  677.  
  678. glEnable (GL_FOG); //enable the fog
  679.  
  680. glFogi (GL_FOG_MODE, GL_EXP2); //set the fog mode to GL_EXP2
  681.  
  682. glFogfv (GL_FOG_COLOR, fogColor); //set the fog color to
  683. //our color chosen above
  684.  
  685. glFogf (GL_FOG_DENSITY, density); //set the density to the
  686. //value above
  687.  
  688. glHint (GL_FOG_HINT, GL_NICEST); // set the fog to look the
  689. //nicest, may slow down on older cards
  690.  
  691. }
  692.  
  693. void Reshape(int width, int height)
  694. {
  695.   glViewport(0, 0, width, height);
  696.  
  697.   glMatrixMode(GL_PROJECTION);
  698.  
  699.   glLoadIdentity();
  700.  
  701.   GLdouble aspect = 1;
  702.   GLfloat zakres = 3.0f;
  703.   GLfloat blisko = 1.0f;
  704.   GLfloat daleko = 5.0f;
  705.  
  706.   if (rzut == ORTO) {
  707.     if (skala == ASPECT_1_1) {
  708.       if (width < height && width > 0)
  709.         glOrtho(-zakres, zakres, -zakres * height / width, zakres * height / width, -zakres * 5, zakres * 5);
  710.       else
  711.       if (width >= height && height > 0)
  712.         glOrtho(-zakres * width / height, zakres * width / height, -zakres, zakres, -zakres * 5, zakres * 5);
  713.     } else
  714.       glOrtho(-zakres, zakres, -zakres, zakres, -zakres * 5, zakres * 5);
  715.   }
  716.   if (rzut == FRUST) {
  717.     if (skala == ASPECT_1_1) {
  718.       if (width < height && width > 0)
  719.         glFrustum(-zakres, zakres, -zakres * height / width, zakres * height / width, blisko, daleko * 5);
  720.       else
  721.       if (width >= height && height > 0)
  722.         glFrustum(-zakres * width / height, zakres * width / height, -zakres, zakres, blisko, daleko * 5);
  723.     } else
  724.       glFrustum(-zakres, zakres, -zakres, zakres, blisko, daleko);
  725.   }
  726.  
  727.   if (rzut == PERSP) {
  728.     if (height > 0)
  729.       aspect = width / (GLdouble) height;
  730.     gluPerspective(fovy, aspect, blisko, daleko);
  731.   }
  732.   glMatrixMode(GL_MODELVIEW);
  733.   glLoadIdentity();
  734.   display();
  735. }
  736.  
  737. void key(unsigned char key, int x, int y)
  738.  {
  739.   switch (key) {
  740. case 'g':
  741.     pokaz=true;
  742.     break;
  743. case 'G':
  744.     pokaz=false;
  745.     break;
  746.  case 'd':
  747.     kierunek[0] += 0.01;
  748.     glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, kierunek);
  749.     glutPostRedisplay();
  750.     break;
  751.   case 'a':
  752.     kierunek[0] -= 0.01;
  753.     glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, kierunek);
  754.  
  755.     glutPostRedisplay();
  756.     break;
  757.   case 'w':
  758.     kierunek[1] += 0.01;
  759.     glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, kierunek);
  760.  
  761.     glutPostRedisplay();
  762.     break;
  763.   case 's':
  764.     kierunek[1] -= 0.01;
  765.     glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, kierunek);
  766.     glutPostRedisplay();
  767.     break;
  768.   case 'e':
  769.     exp_2++;
  770.     glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, exp_2);
  771.  
  772.     glutPostRedisplay();
  773.     break;
  774.   case 'r':
  775.     exp_2--;
  776.     glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, exp_2);
  777.  
  778.     glutPostRedisplay();
  779.     break;
  780.   case 't':
  781.     cut_2++;
  782.     glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, cut_2);
  783.  
  784.     glutPostRedisplay();
  785.     break;
  786.   case 'y':
  787.     cut_2--;
  788.     glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, cut_2);
  789.  
  790.     glutPostRedisplay();
  791.     break;
  792.   case 'x':
  793.     glEnable(GL_LIGHT0);
  794.     break;
  795.   case 'X':
  796.     glDisable(GL_LIGHT0);
  797.     glutPostRedisplay();
  798.     break;
  799.  
  800. case 'p':
  801.     zpos += 0.1;
  802.     break;
  803.  
  804. case ';':
  805.     zpos -= 0.1;
  806.     break;
  807. case 'l':
  808.     xpos += 0.1 ;
  809.     break;
  810. case 'j':
  811.     xpos -= 0.1 ;
  812.     break;
  813. case 'i':
  814.     ypos += 0.1;
  815.     break;
  816. case 'k':
  817.     ypos -= 0.1;
  818.     break;
  819.  
  820. case 'u':
  821.     yrot += 1;
  822.     if (yrot >360) yrot -= 360;
  823.     break;
  824.  
  825. case 'o':
  826.     yrot -= 1;
  827.     if (yrot < -360)yrot += 360;
  828.     break;
  829.  
  830. case '[':
  831.     xrot += 1;
  832.     if (xrot >360) yrot -= 360;
  833.     break;
  834.  
  835. case ']':
  836.     xrot -= 1;
  837.     if (xrot < -360)yrot += 360;
  838.     break;
  839.  
  840. case 'm':
  841.     density += 0.11;
  842.     glFogf (GL_FOG_DENSITY, density);
  843.     break;
  844. case  'M':
  845.     density -= 0.11;
  846.     glFogf (GL_FOG_DENSITY, density);
  847.     break;
  848.  
  849.   case '1':
  850.  
  851.     {
  852.       xx = 0;
  853.       yx = 1;
  854.       zx = 0;
  855.       obrot_x = obrot_x + 5;
  856.       Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
  857.       break;
  858.     }
  859.   case '2':
  860.     {
  861.       xx = 0;
  862.       yx = 1;
  863.       zx = 0;
  864.       obrot_x = obrot_x - 5;
  865.       Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
  866.       break;
  867.     }
  868.   case '3':
  869.     {
  870.       xy = 1;
  871.       yy = 0;
  872.       zy = 0;
  873.       obrot_y = obrot_y + 5;
  874.       Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
  875.       break;
  876.     }
  877.   case '4':
  878.     {
  879.       xy = 1;
  880.       yy = 0;
  881.       zy = 0;
  882.       obrot_y = obrot_y - 5;
  883.  
  884.       Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
  885.       break;
  886.     }
  887.   }
  888. }
  889.  
  890. void Menu(int value)
  891. {
  892.   switch (value) {
  893.     // wyjście
  894.   case EXIT:
  895.     exit(0);
  896.   case FULL_WINDOW:
  897.     skala = FULL_WINDOW;
  898.     Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
  899.     break;
  900.   case ASPECT_1_1:
  901.     skala = ASPECT_1_1;
  902.     Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
  903.     break;
  904.   case ORTO:
  905.     rzut = ORTO;
  906.     Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
  907.     break;
  908.   case FRUST:
  909.     rzut = FRUST;
  910.     Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
  911.     break;
  912.   case PERSP:
  913.     rzut = PERSP;
  914.     Reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
  915.     break;
  916.   }
  917. }
  918.  
  919. static void resize(int width, int height)
  920. {
  921.     const float ar = (float) width / (float) height;
  922.  
  923.     glViewport(0, 0, width, height);
  924.     glMatrixMode(GL_PROJECTION);
  925.     glLoadIdentity();
  926.     glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
  927.  
  928.     glMatrixMode(GL_MODELVIEW);
  929.     glLoadIdentity() ;
  930. }
  931.  
  932. static void display(void) {
  933.  
  934.   const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
  935.   const double a = t * 90.0;
  936.  
  937.   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  938. glPushMatrix();
  939.     Widok();
  940.     Podloga();
  941.     glPushMatrix();
  942.  
  943.             glPushMatrix();
  944.                 glRotatef(obrot_x, 0.0f, 0.0f, 0.0f);
  945.                 glRotatef(obrot_y, xy, yy, zy);
  946.  
  947.               Literka();
  948.             glPopMatrix();
  949.  
  950.             glPushMatrix();
  951.                 glDisable (GL_LIGHTING);
  952.                 glRotatef(obrot_x, 0.0f, 1.0f, 0.0f);
  953.                 glColor3d(0, 0, 0);
  954.                 glTranslated(0,1.4,2);
  955.                 glMultMatrixf (Macierz_cieni);
  956.  
  957.                 Literka();
  958.                 glEnable(GL_LIGHTING);
  959.             glPopMatrix();
  960.  
  961.     glPopMatrix();
  962. glPopMatrix();
  963.   glutSwapBuffers();
  964.  
  965. }
  966.  
  967. static void idle(void)
  968. {
  969.     glutPostRedisplay();
  970. }
  971.  
  972. int main(int argc, char *argv[])
  973. {
  974.     glutInit(&argc, argv);
  975.     glutInitWindowSize(1600,900);
  976.     glutInitWindowPosition(10,10);
  977.     glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
  978.  
  979.     glutCreateWindow("Patryk Stramski Literka");
  980.     Mgla();
  981.     glClearColor(1,1,1,1);
  982.  
  983.  
  984.     glEnable(GL_DEPTH_TEST);
  985.     glDepthFunc(GL_LESS);
  986.  
  987.     glEnable(GL_LIGHT0);
  988.     glEnable(GL_NORMALIZE);
  989.     glEnable(GL_COLOR_MATERIAL);
  990.     glEnable(GL_LIGHTING);
  991.  
  992.     glutCreateMenu (Menu); // utworzenie menu podręcznego
  993. // dodadnie pozycji do menu podręcznego
  994.     glutAddMenuEntry ("Rodzaj skalowania - cale okno", FULL_WINDOW);
  995.     glutAddMenuEntry ("Rodzaj skalowania - skala 1:1",ASPECT_1_1);
  996.     glutAddMenuEntry ("Rzutowanie ortogonalne", ORTO);
  997.     glutAddMenuEntry ("Rzutowanie frustum", FRUST);
  998.     glutAddMenuEntry ("Rzutowanie perspective", PERSP);
  999.     glutAddMenuEntry ("Wyjscie",EXIT);
  1000.     glutAttachMenu (GLUT_RIGHT_BUTTON);
  1001.     glutKeyboardFunc(key);
  1002.  
  1003.     glutIdleFunc(idle);
  1004.     glutReshapeFunc(Reshape);
  1005.     glutDisplayFunc(display);
  1006.  
  1007.  
  1008.    glpMakeShadowMatrix (vPoints, vLightPos, Macierz_cieni);
  1009.     glClearColor(1,1,1,1);
  1010.  
  1011.     glEnable(GL_TEXTURE_2D); // włączenie teksturowania
  1012.     glGenTextures(LICZBA_OB_TEXTUR, obiektyTextur); /// wygenerowanie obiektów tekstur
  1013.     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // ustalenie trybu środowiska
  1014.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  1015.  
  1016.  
  1017.     for (int i = 0; i < LICZBA_OB_TEXTUR; i++)
  1018.     {
  1019.         GLubyte *pBytes;
  1020.         GLint iWidth, iHeight, iComponents;
  1021.         GLenum eFormat;
  1022.         glBindTexture(GL_TEXTURE_2D, obiektyTextur[i]); // dowiązanie obiektów tekstur
  1023.       pBytes = glploadtga(plikiTextur[i], &iWidth, &iHeight, &iComponents, &eFormat); // Załadowanie tekstur
  1024.  
  1025.         // utworzenie mipmap
  1026.         gluBuild2DMipmaps(GL_TEXTURE_2D, iComponents, iWidth, iHeight, eFormat, GL_UNSIGNED_BYTE, pBytes);
  1027.         free(pBytes); // zwolnienie pamięci
  1028.     }
  1029.  
  1030.  
  1031.     glLightfv(GL_LIGHT0, GL_AMBIENT,  light_ambient);
  1032.     glLightfv(GL_LIGHT0, GL_DIFFUSE,  light_diffuse);
  1033.     glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
  1034.     glLightfv(GL_LIGHT0, GL_POSITION, light_position);
  1035.  
  1036.     glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,cut_2);
  1037.     glLightf(GL_LIGHT0,GL_SPOT_EXPONENT,exp_2);
  1038.     glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,kierunek);
  1039.  
  1040.     glMaterialfv(GL_FRONT, GL_AMBIENT,   mat_ambient);
  1041.     glMaterialfv(GL_FRONT, GL_DIFFUSE,   mat_diffuse);
  1042.     glMaterialfv(GL_FRONT, GL_SPECULAR,  mat_specular);
  1043.     glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
  1044.  
  1045.     glutMainLoop();
  1046.  
  1047.     return EXIT_SUCCESS;
  1048. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top