Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 29.87 KB | None | 0 0
  1. // Gl_template.c
  2. //Wyłšczanie błędów przed "fopen"
  3. #define  _CRT_SECURE_NO_WARNINGS
  4.  
  5. // Ładowanie bibliotek:
  6. #ifdef _MSC_VER                         // Check if MS Visual C compiler
  7. #  pragma comment(lib, "opengl32.lib")  // Compiler-specific directive to avoid manually configuration
  8. #  pragma comment(lib, "glu32.lib")     // Link libraries
  9. #endif
  10.  
  11. // Ustalanie trybu tekstowego:
  12. #ifdef _MSC_VER        // Check if MS Visual C compiler
  13. #   ifndef _MBCS
  14. #      define _MBCS    // Uses Multi-byte character set
  15. #   endif
  16. #   ifdef _UNICODE     // Not using Unicode character set
  17. #      undef _UNICODE
  18. #   endif
  19. #   ifdef UNICODE
  20. #      undef UNICODE
  21. #   endif
  22. #endif
  23.  
  24.  
  25. #include <windows.h>            // Window defines
  26. #include <gl\gl.h>              // OpenGL
  27. #include <gl\glu.h>             // GLU library
  28. #include <math.h>               // Define for sqrt
  29. #include <stdio.h>
  30. #include "resource.h"           // About box resource identifiers.
  31.  
  32. #define glRGB(x, y, z)  glColor3ub((GLubyte)x, (GLubyte)y, (GLubyte)z)
  33. #define BITMAP_ID 0x4D42        // identyfikator formatu BMP
  34. #define GL_PI 3.14
  35.  
  36. // Color Palette handle
  37. HPALETTE hPalette = NULL;
  38.  
  39. // Application name and instance storeage
  40. static LPCTSTR lpszAppName = "GL Template";
  41. static HINSTANCE hInstance;
  42.  
  43. // Rotation amounts
  44. static GLfloat xRot = 0.0f;
  45. static GLfloat yRot = 0.0f;
  46.  
  47. static GLfloat xRot2 = 0.0f;
  48. static GLfloat yRot2 = 0.0f;
  49.  
  50.  
  51. static GLsizei lastHeight;
  52. static GLsizei lastWidth;
  53.  
  54. // Opis tekstury
  55. BITMAPINFOHEADER    bitmapInfoHeader;   // nagłówek obrazu
  56. unsigned char*      bitmapData;         // dane tekstury
  57. unsigned int        texture[2];         // obiekt tekstury
  58.  
  59.  
  60.                                         // Declaration for Window procedure
  61. LRESULT CALLBACK WndProc(HWND    hWnd,
  62.     UINT    message,
  63.     WPARAM  wParam,
  64.     LPARAM  lParam);
  65.  
  66. // Dialog procedure for about box
  67. BOOL APIENTRY AboutDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam);
  68.  
  69. // Set Pixel Format function - forward declaration
  70. void SetDCPixelFormat(HDC hDC);
  71.  
  72. double rot1, rot2, rot3, rot4, rot5, rot6;
  73. int licznik;
  74.  
  75.  
  76.  
  77. // Reduces a normal vector specified as a set of three coordinates,
  78. // to a unit normal vector of length one.
  79. void ReduceToUnit(float vector[3])
  80. {
  81.     float length;
  82.  
  83.     // Calculate the length of the vector      
  84.     length = (float)sqrt((vector[0] * vector[0]) +
  85.         (vector[1] * vector[1]) +
  86.         (vector[2] * vector[2]));
  87.  
  88.     // Keep the program from blowing up by providing an exceptable
  89.     // value for vectors that may calculated too close to zero.
  90.     if (length == 0.0f)
  91.         length = 1.0f;
  92.  
  93.     // Dividing each element by the length will result in a
  94.     // unit normal vector.
  95.     vector[0] /= length;
  96.     vector[1] /= length;
  97.     vector[2] /= length;
  98. }
  99.  
  100.  
  101. // Points p1, p2, & p3 specified in counter clock-wise order
  102. void calcNormal(float v[3][3], float out[3])
  103. {
  104.     float v1[3], v2[3];
  105.     static const int x = 0;
  106.     static const int y = 1;
  107.     static const int z = 2;
  108.  
  109.     // Calculate two vectors from the three points
  110.     v1[x] = v[0][x] - v[1][x];
  111.     v1[y] = v[0][y] - v[1][y];
  112.     v1[z] = v[0][z] - v[1][z];
  113.  
  114.     v2[x] = v[1][x] - v[2][x];
  115.     v2[y] = v[1][y] - v[2][y];
  116.     v2[z] = v[1][z] - v[2][z];
  117.  
  118.     // Take the cross product of the two vectors to get
  119.     // the normal vector which will be stored in out
  120.     out[x] = v1[y] * v2[z] - v1[z] * v2[y];
  121.     out[y] = v1[z] * v2[x] - v1[x] * v2[z];
  122.     out[z] = v1[x] * v2[y] - v1[y] * v2[x];
  123.  
  124.     // Normalize the vector (shorten length to one)
  125.     ReduceToUnit(out);
  126. }
  127.  
  128.  
  129.  
  130. // Change viewing volume and viewport.  Called when window is resized
  131. void ChangeSize(GLsizei w, GLsizei h)
  132. {
  133.     GLfloat nRange = 100.0f;
  134.     GLfloat fAspect;
  135.     // Prevent a divide by zero
  136.     if (h == 0)
  137.         h = 1;
  138.  
  139.     lastWidth = w;
  140.     lastHeight = h;
  141.  
  142.     fAspect = (GLfloat)w / (GLfloat)h;
  143.     // Set Viewport to window dimensions
  144.     glViewport(0, 0, w, h);
  145.  
  146.     // Reset coordinate system
  147.     glMatrixMode(GL_PROJECTION);
  148.     glLoadIdentity();
  149.  
  150.     // Establish clipping volume (left, right, bottom, top, near, far)
  151.     if (w <= h)
  152.         glOrtho(-nRange, nRange, -nRange*h / w, nRange*h / w, -nRange, nRange);
  153.     else
  154.         glOrtho(-nRange*w / h, nRange*w / h, -nRange, nRange, -nRange, nRange);
  155.  
  156.     // Establish perspective:
  157.     /*
  158.     gluPerspective(60.0f,fAspect,1.0,400);
  159.     */
  160.  
  161.     glMatrixMode(GL_MODELVIEW);
  162.     glLoadIdentity();
  163. }
  164.  
  165.  
  166.  
  167. // This function does any needed initialization on the rendering
  168. // context.  Here it sets up and initializes the lighting for
  169. // the scene.
  170. GLfloat  lightPos[] = { 0.0f, 0.0f, 75.0f, 1.0f };
  171. GLfloat  spotDir[] = { 0.0f, 0.0f, -1.0f };
  172.  
  173. void SetupRC()
  174. {
  175.     // Light values and coordinates
  176.     GLfloat  diffuseLight[] = { 0.7f, 0.7f, 0.7f, 1.0f };
  177.    
  178.     GLfloat  specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
  179.     GLfloat  specref[] = { 1.0f, 1.0f, 1.0f, 1.0f };
  180.     GLfloat  ambientLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
  181.    
  182.  
  183.  
  184.     glEnable(GL_DEPTH_TEST);    // Hidden surface removal
  185.     glFrontFace(GL_CCW);        // Counter clock-wise polygons face out
  186.                                 glEnable(GL_CULL_FACE);     // Do not calculate inside of jet
  187.  
  188.                                 // Enable lighting
  189.                                 glEnable(GL_LIGHTING);
  190.  
  191.                                 // Setup and enable light 0
  192.                                 glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);
  193.                                 glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);
  194.                                 glLightfv(GL_LIGHT0,GL_SPECULAR,specular);
  195.                                 glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
  196.                                 glEnable(GL_LIGHT0);
  197.  
  198.                                 // Reflektor
  199.                                 glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 60.0f);
  200.                                 glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 100.0f);
  201.                                 glEnable(GL_LIGHT0);
  202.  
  203.                                 // Enable color tracking
  204.                                 glEnable(GL_COLOR_MATERIAL);
  205.  
  206.                                 // Set Material properties to follow glColor values
  207.                                 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
  208.  
  209.                                 // All materials hereafter have full specular reflectivity
  210.                                 // with a high shine
  211.                                 glMaterialfv(GL_FRONT, GL_SPECULAR,specref);
  212.                                 glMateriali(GL_FRONT,GL_SHININESS,128);
  213.  
  214.  
  215.                                 // White background
  216.     glClearColor(0.f, 0.f, 0.f, 1.0f);
  217.     // Black brush
  218.     glColor3f(0.0, 0.0, 0.0);
  219. }
  220.  
  221. void skrzynka(void)
  222. {
  223.     glColor3d(0.8, 0.7, 0.3);
  224.  
  225.  
  226.     glEnable(GL_TEXTURE_2D); // Włącz teksturowanie
  227.  
  228.     glBindTexture(GL_TEXTURE_2D, texture[0]);
  229.     glBegin(GL_QUADS);
  230.     glNormal3d(0, 0, 1);
  231.     glTexCoord2d(1.0, 1.0); glVertex3d(25, 25, 25);
  232.     glTexCoord2d(0.0, 1.0); glVertex3d(-25, 25, 25);
  233.     glTexCoord2d(0.0, 0.0); glVertex3d(-25, -25, 25);
  234.     glTexCoord2d(1.0, 0.0); glVertex3d(25, -25, 25);
  235.     glEnd();
  236.     glBindTexture(GL_TEXTURE_2D, texture[1]);
  237.     glBegin(GL_QUADS);
  238.     glNormal3d(1, 0, 0);
  239.     glTexCoord2d(1.0, 1.0); glVertex3d(25, 25, 25);
  240.     glTexCoord2d(0.0, 1.0); glVertex3d(25, -25, 25);
  241.     glTexCoord2d(0.0, 0.0); glVertex3d(25, -25, -25);
  242.     glTexCoord2d(1.0, 0.0); glVertex3d(25, 25, -25);
  243.     glEnd();
  244.  
  245.     glDisable(GL_TEXTURE_2D); // Wyłącz teksturowanie
  246.  
  247.  
  248.  
  249.     glBegin(GL_QUADS);
  250.     glNormal3d(0, 0, -1);
  251.     glVertex3d(25, 25, -25);
  252.     glVertex3d(25, -25, -25);
  253.     glVertex3d(-25, -25, -25);
  254.     glVertex3d(-25, 25, -25);
  255.  
  256.     glNormal3d(-1, 0, 0);
  257.     glVertex3d(-25, 25, -25);
  258.     glVertex3d(-25, -25, -25);
  259.     glVertex3d(-25, -25, 25);
  260.     glVertex3d(-25, 25, 25);
  261.  
  262.     glNormal3d(0, 1, 0);
  263.     glVertex3d(25, 25, 25);
  264.     glVertex3d(25, 25, -25);
  265.     glVertex3d(-25, 25, -25);
  266.     glVertex3d(-25, 25, 25);
  267.  
  268.     glNormal3d(0, -1, 0);
  269.     glVertex3d(25, -25, 25);
  270.     glVertex3d(-25, -25, 25);
  271.     glVertex3d(-25, -25, -25);
  272.     glVertex3d(25, -25, -25);
  273.     glEnd();
  274. }
  275.  
  276. void walec01(void)
  277. {
  278.     GLUquadricObj*obj;
  279.     obj = gluNewQuadric();
  280.     gluQuadricNormals(obj, GLU_SMOOTH);
  281.     glColor3d(1, 0, 0);
  282.     glPushMatrix();
  283.     gluCylinder(obj, 20, 20, 30, 15, 7);
  284.     gluCylinder(obj, 0, 20, 0, 15, 7);
  285.     glTranslated(0, 0, 60);
  286.     glRotated(180.0, 0, 1, 0);
  287.     gluCylinder(obj, 0, 20, 30, 15, 7);
  288.     glPopMatrix();
  289. }
  290.  
  291. void kula(void)
  292. {
  293.     GLUquadricObj*obj;
  294.     obj = gluNewQuadric();
  295.     gluQuadricTexture(obj, GL_TRUE);
  296.     glBindTexture(GL_TEXTURE_2D, texture[0]);
  297.     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  298.     glColor3d(1.0, 0.8, 0.8);
  299.     glEnable(GL_TEXTURE_2D);
  300.     gluSphere(obj, 20, 15, 7);
  301.     glDisable(GL_TEXTURE_2D);
  302. }
  303.  
  304.  
  305.  
  306.  
  307. // LoadBitmapFile
  308. // opis: ładuje mapę bitową z pliku i zwraca jej adres.
  309. //       Wypełnia strukturę nagłówka.
  310. //   Nie obsługuje map 8-bitowych.
  311. unsigned char *LoadBitmapFile(char *filename, BITMAPINFOHEADER *bitmapInfoHeader)
  312. {
  313.     FILE *filePtr;                          // wskaźnik pozycji pliku
  314.     BITMAPFILEHEADER    bitmapFileHeader;       // nagłówek pliku
  315.     unsigned char       *bitmapImage;           // dane obrazu
  316.     int                 imageIdx = 0;       // licznik pikseli
  317.     unsigned char       tempRGB;                // zmienna zamiany składowych
  318.  
  319.                                                 // otwiera plik w trybie "read binary"
  320.     filePtr = fopen(filename, "rb");
  321.     if (filePtr == NULL)
  322.         return NULL;
  323.  
  324.     // wczytuje nagłówek pliku
  325.     fread(&bitmapFileHeader, sizeof(BITMAPFILEHEADER), 1, filePtr);
  326.  
  327.     // sprawdza, czy jest to plik formatu BMP
  328.     if (bitmapFileHeader.bfType != BITMAP_ID)
  329.     {
  330.         fclose(filePtr);
  331.         return NULL;
  332.     }
  333.  
  334.     // wczytuje nagłówek obrazu
  335.     fread(bitmapInfoHeader, sizeof(BITMAPINFOHEADER), 1, filePtr);
  336.  
  337.     // ustawia wskaźnik pozycji pliku na początku danych obrazu
  338.     fseek(filePtr, bitmapFileHeader.bfOffBits, SEEK_SET);
  339.  
  340.     // przydziela pamięć buforowi obrazu
  341.     bitmapImage = (unsigned char*)malloc(bitmapInfoHeader->biSizeImage);
  342.  
  343.     // sprawdza, czy udało się przydzielić pamięć
  344.     if (!bitmapImage)
  345.     {
  346.         free(bitmapImage);
  347.         fclose(filePtr);
  348.         return NULL;
  349.     }
  350.  
  351.     // wczytuje dane obrazu
  352.     fread(bitmapImage, 1, bitmapInfoHeader->biSizeImage, filePtr);
  353.  
  354.     // sprawdza, czy dane zostały wczytane
  355.     if (bitmapImage == NULL)
  356.     {
  357.         fclose(filePtr);
  358.         return NULL;
  359.     }
  360.  
  361.     // zamienia miejscami składowe R i B
  362.     for (imageIdx = 0; imageIdx < bitmapInfoHeader->biSizeImage; imageIdx += 3)
  363.     {
  364.         tempRGB = bitmapImage[imageIdx];
  365.         bitmapImage[imageIdx] = bitmapImage[imageIdx + 2];
  366.         bitmapImage[imageIdx + 2] = tempRGB;
  367.     }
  368.  
  369.     // zamyka plik i zwraca wskaźnik bufora zawierającego wczytany obraz
  370.     fclose(filePtr);
  371.     return bitmapImage;
  372. }
  373.  
  374. void szescian()
  375. {
  376.     glBegin(GL_QUADS);
  377.     glNormal3d(0, 0, 1);
  378.     glColor3d(1, 0.5, 0);
  379.     glVertex3d(20, 20, 20);
  380.     glVertex3d(-20, 20, 20);
  381.     glVertex3d(-20, -20, 20);
  382.     glVertex3d(20, -20, 20);
  383.     glNormal3d(1, 0, 0);
  384.     glVertex3d(20, 20, 20);
  385.     glVertex3d(20, -20, 20);
  386.     glVertex3d(20, -20, -20);
  387.     glVertex3d(20, 20, -20);
  388.     glNormal3d(0, 0, -1);
  389.     glVertex3d(-20, 20, 20);
  390.     glVertex3d(-20, 20, -20);
  391.     glVertex3d(-20, -20, -20);
  392.     glVertex3d(-20, -20, 20);
  393.     glNormal3d(-1, 0, 0);
  394.     glVertex3d(-20, 20, -20);
  395.     glVertex3d(20, 20, -20);
  396.     glVertex3d(20, -20, -20);
  397.     glVertex3d(-20, -20, -20);
  398.     glNormal3d(0, 1, 0);
  399.     glVertex3d(-20, -20, 20);
  400.     glVertex3d(-20, -20, -20);
  401.     glVertex3d(20, -20, -20);
  402.     glVertex3d(20, -20, 20);
  403.     glNormal3d(0, -1, 0);
  404.     glVertex3d(20, 20, 20);
  405.     glVertex3d(20, 20, -20);
  406.     glVertex3d(-20, 20, -20);
  407.     glVertex3d(-20, 20, 20);
  408. }
  409.  
  410. void walec(double r, double h)
  411. {
  412.     glColor3d(1, 0.5, 0);
  413.     glNormal3d(0, 0, -1);
  414.     double angle, x, y;
  415.     glBegin(GL_TRIANGLE_FAN);
  416.     glVertex3d(0.0f, 0.0f, 0.0f);
  417.     for (angle = 0.0f; angle <= (2.0f*GL_PI); angle += (GL_PI / 8.0f))
  418.     {
  419.         x = r*sin(angle);
  420.         y = r*cos(angle);
  421.         glVertex3d(x, y, 0.0);
  422.     }
  423.     glEnd();
  424.     glBegin(GL_QUAD_STRIP);
  425.     for (angle = 0.0f; angle >= -(2.0f*GL_PI); angle -= (GL_PI / 8.0f))
  426.     {
  427.         x = r*sin(angle);
  428.         y = r*cos(angle);
  429.         glNormal3d(sin(angle), cos(angle), 0);
  430.         glVertex3d(x, y, h);
  431.         glVertex3d(x, y, 0);
  432.     }
  433.     glEnd();
  434.     glNormal3d(0, 0, 1);
  435.     glBegin(GL_TRIANGLE_FAN);
  436.     glVertex3d(0.0f, 0.0f, h);
  437.     for (angle = (2.0f*GL_PI) + (GL_PI / 8.0f); angle > 0; angle -= (GL_PI / 8.0f))
  438.     {
  439.         x = r*sin(angle);
  440.         y = r*cos(angle);
  441.         glVertex3d(x, y, h);
  442.     }
  443.     glEnd();
  444. }
  445.  
  446. void ramie(double r1, double r2, double h, double d)
  447. {
  448.     glColor3d(1, 0.5, 0);
  449.     double angle, x, y;
  450.     glBegin(GL_TRIANGLE_FAN);
  451.     glNormal3d(0, 0, -1);
  452.     glVertex3d(0.0f, 0.0f, 0.0f);
  453.     for (angle = GL_PI; angle <= 2.0f*GL_PI; angle += (GL_PI / 8.0f))
  454.     {
  455.         x = r1*sin(angle);
  456.         y = r1*cos(angle);
  457.         glVertex3d(x, y, 0.0);
  458.     }
  459.     glEnd();
  460.     glBegin(GL_QUAD_STRIP);
  461.     for (angle = 2.0f*GL_PI; angle > GL_PI-(GL_PI / 8.0f); angle -= (GL_PI / 8.0f))
  462.     {
  463.         x = r1*sin(angle);
  464.         y = r1*cos(angle);
  465.         glNormal3d(sin(angle), cos(angle), 0);
  466.         glVertex3d(x, y, h);
  467.         glVertex3d(x, y, 0);
  468.     }
  469.     glEnd();
  470.     glBegin(GL_TRIANGLE_FAN);
  471.     glNormal3d(0, 0, 1);
  472.     glVertex3d(0.0f, 0.0f, h);
  473.     for (angle = 2.0f*GL_PI; angle >= GL_PI-(GL_PI / 8.0f); angle -= (GL_PI / 8.0f))
  474.     {
  475.         x = r1*sin(angle);
  476.         y = r1*cos(angle);
  477.         glVertex3d(x, y, h);
  478.     }
  479.     glEnd();
  480.  
  481.     float v[3][3] = {
  482.         {0, r1, 0},
  483.         {d, r2, 0},
  484.         {d,0, 0 }
  485.     };
  486.  
  487.     float norm[3];
  488.     calcNormal(v, norm);
  489.     glNormal3d(norm[0], norm[1], norm[2]);
  490.     glBegin(GL_QUADS);
  491.     glVertex3d(0, r1, 0);
  492.     glVertex3d(d, r2, 0);
  493.     glVertex3d(d, 0, 0);
  494.     glVertex3d(0, 0, 0);
  495.     glEnd();
  496.  
  497.     float v1[3][3] = {
  498.         { 0, 0, 0 },
  499.         { d, 0, 0 },
  500.         { d, -r2, 0 }
  501.     };
  502.  
  503.     norm[3];
  504.     calcNormal(v1, norm);
  505.     glNormal3d(norm[0], norm[1], norm[2]);
  506.     glBegin(GL_QUADS);
  507.     glVertex3d(0, 0, 0);
  508.     glVertex3d(d, 0, 0);
  509.     glVertex3d(d, -r2, 0);
  510.     glVertex3d(0, -r1, 0);
  511.     glEnd();
  512.  
  513.     float v2[3][3] = {
  514.         { 0, 0, h },
  515.         { d, 0, h },
  516.         { d, r2, h }
  517.     };
  518.  
  519.     calcNormal(v2, norm);
  520.     glNormal3d(norm[0], norm[1], norm[2]);
  521.     glBegin(GL_QUADS);
  522.     glVertex3d(0, 0, h);
  523.     glVertex3d(d, 0, h);
  524.     glVertex3d(d, r2, h);
  525.     glVertex3d(0, r1, h);
  526.     glEnd();
  527.  
  528.     float v3[3][3] = {
  529.         { 0, -r1, h },
  530.         { d, -r2, h },
  531.         { d, 0, h }
  532.     };
  533.  
  534.     calcNormal(v3, norm);
  535.     glNormal3d(norm[0], norm[1], norm[2]);
  536.     glBegin(GL_QUADS);
  537.     glVertex3d(0, -r1, h);
  538.     glVertex3d(d, -r2, h);
  539.     glVertex3d(d, 0, h);
  540.     glVertex3d(0, 0, h);
  541.     glEnd();
  542.  
  543.     float v4[3][3] = {
  544.         { 0, -r1, 0 },
  545.         { d, -r2, 0 },
  546.         { d, -r2, h }
  547.     };
  548.  
  549.     calcNormal(v4, norm);
  550.     glNormal3d(norm[0], norm[1], norm[2]);
  551.     glBegin(GL_QUADS);
  552.     glVertex3d(0, -r1, 0);
  553.     glVertex3d(d, -r2, 0);
  554.     glVertex3d(d, -r2, h);
  555.     glVertex3d(0, -r1, h);
  556.     glEnd();
  557.  
  558.     float v5[3][3] = {
  559.         { 0, r1, h },
  560.         { d, r2, h },
  561.         { d, r2, 0 }
  562.     };
  563.  
  564.     calcNormal(v5, norm);
  565.     glNormal3d(norm[0], norm[1], norm[2]);
  566.     glBegin(GL_QUADS);
  567.     glVertex3d(0, r1, h);
  568.     glVertex3d(d, r2, h);
  569.     glVertex3d(d, r2, 0);
  570.     glVertex3d(0, r1, 0);
  571.     glEnd();
  572.  
  573.     glBegin(GL_TRIANGLE_FAN);
  574.     glNormal3d(0, 0, -1);
  575.     glVertex3d(d, 0.0f, 0.0f);
  576.     for (angle = 0; angle <= GL_PI; angle += (GL_PI / 8.0f))
  577.     {
  578.         x = r2*sin(angle) + d;
  579.         y = r2*cos(angle);
  580.         glVertex3d(x, y, 0.0);
  581.     }
  582.     glEnd();
  583.     glBegin(GL_QUAD_STRIP);
  584.     for (angle = GL_PI; angle > -(GL_PI / 8.0f); angle -= (GL_PI / 8.0f))
  585.     {
  586.         x = r2*sin(angle) + d;
  587.         y = r2*cos(angle);
  588.         glNormal3d(sin(angle), cos(angle), 0);
  589.         glVertex3d(x, y, h);
  590.         glVertex3d(x, y, 0);
  591.     }
  592.     glEnd();
  593.     glBegin(GL_TRIANGLE_FAN);
  594.     glNormal3d(0, 0, 1);
  595.     glVertex3d(d, 0.0f, h);
  596.     for (angle = GL_PI; angle >= -(GL_PI / 8.0f); angle -= (GL_PI / 8.0f))
  597.     {
  598.         x = r2*sin(angle) + d;
  599.         y = r2*cos(angle);
  600.         glVertex3d(x, y, h);
  601.     }
  602.     glEnd();
  603. }
  604.  
  605. void robot(double d1, double d2, double d3)
  606. {
  607.     glPushMatrix();
  608.     glRotated(-90, 1, 0, 0);
  609.     glTranslated(0, 0, -50);
  610.  
  611.     walec(30, 5);
  612.     glTranslated(0, 0, 5);
  613.     walec(10, 40);
  614.     glTranslated(0, 0, 40);
  615.     glRotated(d1, 0, 0, 1);
  616.     walec(10, 40);
  617.  
  618.     glTranslated(0, 0, 40);
  619.     glRotated(90, 0, 1, 0);
  620.     glTranslated(0, 0, -20);
  621.     walec(10, 40);
  622.  
  623.     glTranslated(0, 0, +40);
  624.     glRotated(90 + d2, 0, 0, 1);
  625.     ramie(15, 10, 5, 30);
  626.  
  627.     glTranslated(30, 0, -5);
  628.     glRotated(d3, 0, 0, 1);
  629.     ramie(15, 10, 5, 30);
  630.  
  631.     glPopMatrix(); 
  632. }
  633.  
  634. void dwa_roboty(double da1, double da2, double da3, double db1, double db2, double db3) {
  635.     glPushMatrix();
  636.     glRotated(-90, 1, 0, 0);
  637.     glTranslated(0, -50, -50);
  638.  
  639.     walec(30, 5);
  640.     glTranslated(0, 0, 5);
  641.     walec(10, 40);
  642.     glTranslated(0, 0, 40);
  643.     glRotated(da1, 0, 0, 1);
  644.     walec(10, 40);
  645.  
  646.     glTranslated(0, 0, 40);
  647.     glRotated(90, 0, 1, 0);
  648.     glTranslated(0, 0, -20);
  649.     walec(10, 40);
  650.  
  651.     glTranslated(0, 0, +40);
  652.     glRotated(90 + da2, 0, 0, 1);
  653.     ramie(15, 10, 5, 30);
  654.  
  655.     glTranslated(30, 0, -5);
  656.     glRotated(da3, 0, 0, 1);
  657.     ramie(15, 10, 5, 30);
  658.  
  659.     glPopMatrix();
  660.  
  661.     glPushMatrix();
  662.     glRotated(-90, 1, 0, 0);
  663.     glTranslated(0, 50, -50);
  664.  
  665.     walec(30, 5);
  666.     glTranslated(0, 0, 5);
  667.     walec(10, 40);
  668.     glTranslated(0, 0, 40);
  669.     glRotated(db1, 0, 0, 1);
  670.     walec(10, 40);
  671.  
  672.     glTranslated(0, 0, 40);
  673.     glRotated(90, 0, 1, 0);
  674.     glTranslated(0, 0, -20);
  675.     walec(10, 40);
  676.  
  677.     glTranslated(0, 0, +40);
  678.     glRotated(90 + db2, 0, 0, 1);
  679.     ramie(15, 10, 5, 30);
  680.  
  681.     glTranslated(30, 0, -5);
  682.     glRotated(db3, 0, 0, 1);
  683.     ramie(15, 10, 5, 30);
  684.  
  685.     glPopMatrix();
  686. }
  687.  
  688. // Called to draw scene
  689. void RenderScene(void)
  690. {
  691.     //float normal[3];  // Storeage for calculated surface normal
  692.  
  693.     // Clear the window with current clearing color
  694.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  695.     glEnable(GL_CULL_FACE);
  696.  
  697.     // Ustal kolor materiału i wyświetl sferę w środku okna
  698.     glRGB(0, 0, 255);
  699.    
  700.     // Umieść źródło oświetlenia
  701.     // Zachowaj bieżące położenie lokalnego uk. współrzędnych
  702.     glPushMatrix();
  703.     // Obróć lokalny układ współrzędnych
  704.     glRotatef(yRot2, 0.0f, 1.0f, 0.0f);
  705.     glRotatef(xRot2, 1.0f, 0.0f, 0.0f);
  706.    
  707.     // Podaj nowe położenie światła
  708.     glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
  709.     glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spotDir);
  710.     // Wyrysuj czerwony stożek do oznaczenia położenia reflektora
  711.     glRGB(255, 0, 0);
  712.     // Przesuń układ w celu dostosowania położenia światła do //stożka
  713.     glTranslatef(lightPos[0], lightPos[1], lightPos[2]);
  714.     walec01;
  715.     // Wyrysuj "żarówkę", zachowaj stan oświetlenia sceny
  716.     glPushAttrib(GL_LIGHTING_BIT);
  717.     // Wyłącz oświetlenie sceny
  718.     glDisable(GL_LIGHTING);
  719.     glRGB(255, 255, 0);
  720.     kula();
  721.     // Odzyskaj poprzednie parametry oświetlenia
  722.     glPopAttrib();
  723.     // Odzyskaj zachowane położenie lokalnego układu współrzędnych
  724.     glPopMatrix();
  725.  
  726.     // Save the matrix state and do the rotations
  727.     glPushMatrix();
  728.     glRotatef(xRot, 1.0f, 0.0f, 0.0f);
  729.     glRotatef(yRot, 0.0f, 1.0f, 0.0f);
  730.     dwa_roboty(rot1, rot2, rot3, rot4, rot5, rot6);
  731.     /////////////////////////////////////////////////////////////////
  732.     // MIEJSCE NA KOD OPENGL DO TWORZENIA WLASNYCH SCEN:           //
  733.     /////////////////////////////////////////////////////////////////
  734.  
  735.     //Sposób na odróźnienie "przedniej" i "tylniej" ściany wielokąta:
  736.     glPolygonMode(GL_BACK, GL_LINE);
  737.  
  738.     //Uzyskanie siatki:
  739.     //glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
  740.  
  741.     //Wyrysowanie prostokata:
  742.     /*glRectd(-10.0, -10.0, 20.0, 20.0);*/
  743.  
  744.    
  745.  
  746.     /////////////////////////////////////////////////////////////////
  747.     /////////////////////////////////////////////////////////////////
  748.     /////////////////////////////////////////////////////////////////
  749.     glPopMatrix();
  750.     glMatrixMode(GL_MODELVIEW);
  751.  
  752.     // Flush drawing commands
  753.     glFlush();
  754. }
  755.  
  756.  
  757. // Select the pixel format for a given device context
  758. void SetDCPixelFormat(HDC hDC)
  759. {
  760.     int nPixelFormat;
  761.  
  762.     static PIXELFORMATDESCRIPTOR pfd = {
  763.         sizeof(PIXELFORMATDESCRIPTOR),  // Size of this structure
  764.         1,                                                              // Version of this structure    
  765.         PFD_DRAW_TO_WINDOW |                    // Draw to Window (not to bitmap)
  766.         PFD_SUPPORT_OPENGL |                    // Support OpenGL calls in window
  767.         PFD_DOUBLEBUFFER,                       // Double buffered
  768.         PFD_TYPE_RGBA,                          // RGBA Color mode
  769.         24,                                     // Want 24bit color
  770.         0,0,0,0,0,0,                            // Not used to select mode
  771.         0,0,                                    // Not used to select mode
  772.         0,0,0,0,0,                              // Not used to select mode
  773.         32,                                     // Size of depth buffer
  774.         0,                                      // Not used to select mode
  775.         0,                                      // Not used to select mode
  776.         PFD_MAIN_PLANE,                         // Draw in main plane
  777.         0,                                      // Not used to select mode
  778.         0,0,0 };                                // Not used to select mode
  779.  
  780.                                                 // Choose a pixel format that best matches that described in pfd
  781.     nPixelFormat = ChoosePixelFormat(hDC, &pfd);
  782.  
  783.     // Set the pixel format for the device context
  784.     SetPixelFormat(hDC, nPixelFormat, &pfd);
  785. }
  786.  
  787.  
  788.  
  789. // If necessary, creates a 3-3-2 palette for the device context listed.
  790. HPALETTE GetOpenGLPalette(HDC hDC)
  791. {
  792.     HPALETTE hRetPal = NULL;    // Handle to palette to be created
  793.     PIXELFORMATDESCRIPTOR pfd;  // Pixel Format Descriptor
  794.     LOGPALETTE *pPal;           // Pointer to memory for logical palette
  795.     int nPixelFormat;           // Pixel format index
  796.     int nColors;                // Number of entries in palette
  797.     int i;                      // Counting variable
  798.     BYTE RedRange, GreenRange, BlueRange;
  799.     // Range for each color entry (7,7,and 3)
  800.  
  801.  
  802.     // Get the pixel format index and retrieve the pixel format description
  803.     nPixelFormat = GetPixelFormat(hDC);
  804.     DescribePixelFormat(hDC, nPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
  805.  
  806.     // Does this pixel format require a palette?  If not, do not create a
  807.     // palette and just return NULL
  808.     if (!(pfd.dwFlags & PFD_NEED_PALETTE))
  809.         return NULL;
  810.  
  811.     // Number of entries in palette.  8 bits yeilds 256 entries
  812.     nColors = 1 << pfd.cColorBits;
  813.  
  814.     // Allocate space for a logical palette structure plus all the palette entries
  815.     pPal = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) + nColors * sizeof(PALETTEENTRY));
  816.  
  817.     // Fill in palette header
  818.     pPal->palVersion = 0x300;       // Windows 3.0
  819.     pPal->palNumEntries = nColors; // table size
  820.  
  821.                                    // Build mask of all 1's.  This creates a number represented by having
  822.                                    // the low order x bits set, where x = pfd.cRedBits, pfd.cGreenBits, and
  823.                                    // pfd.cBlueBits.  
  824.     RedRange = (1 << pfd.cRedBits) - 1;
  825.     GreenRange = (1 << pfd.cGreenBits) - 1;
  826.     BlueRange = (1 << pfd.cBlueBits) - 1;
  827.  
  828.     // Loop through all the palette entries
  829.     for (i = 0; i < nColors; i++)
  830.     {
  831.         // Fill in the 8-bit equivalents for each component
  832.         pPal->palPalEntry[i].peRed = (i >> pfd.cRedShift) & RedRange;
  833.         pPal->palPalEntry[i].peRed = (unsigned char)(
  834.             (double)pPal->palPalEntry[i].peRed * 255.0 / RedRange);
  835.  
  836.         pPal->palPalEntry[i].peGreen = (i >> pfd.cGreenShift) & GreenRange;
  837.         pPal->palPalEntry[i].peGreen = (unsigned char)(
  838.             (double)pPal->palPalEntry[i].peGreen * 255.0 / GreenRange);
  839.  
  840.         pPal->palPalEntry[i].peBlue = (i >> pfd.cBlueShift) & BlueRange;
  841.         pPal->palPalEntry[i].peBlue = (unsigned char)(
  842.             (double)pPal->palPalEntry[i].peBlue * 255.0 / BlueRange);
  843.  
  844.         pPal->palPalEntry[i].peFlags = (unsigned char)NULL;
  845.     }
  846.  
  847.  
  848.     // Create the palette
  849.     hRetPal = CreatePalette(pPal);
  850.  
  851.     // Go ahead and select and realize the palette for this device context
  852.     SelectPalette(hDC, hRetPal, FALSE);
  853.     RealizePalette(hDC);
  854.  
  855.     // Free the memory used for the logical palette structure
  856.     free(pPal);
  857.  
  858.     // Return the handle to the new palette
  859.     return hRetPal;
  860. }
  861.  
  862.  
  863. // Entry point of all Windows programs
  864. int APIENTRY WinMain(HINSTANCE       hInst,
  865.     HINSTANCE       hPrevInstance,
  866.     LPSTR           lpCmdLine,
  867.     int                     nCmdShow)
  868. {
  869.     MSG                     msg;            // Windows message structure
  870.     WNDCLASS        wc;                     // Windows class structure
  871.     HWND            hWnd;           // Storeage for window handle
  872.  
  873.     hInstance = hInst;
  874.  
  875.     // Register Window style
  876.     wc.style = CS_HREDRAW | CS_VREDRAW;
  877.     wc.lpfnWndProc = (WNDPROC)WndProc;
  878.     wc.cbClsExtra = 0;
  879.     wc.cbWndExtra = 0;
  880.     wc.hInstance = hInstance;
  881.     wc.hIcon = NULL;
  882.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  883.  
  884.     // No need for background brush for OpenGL window
  885.     wc.hbrBackground = NULL;
  886.  
  887.     wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
  888.     wc.lpszClassName = lpszAppName;
  889.  
  890.     // Register the window class
  891.     if (RegisterClass(&wc) == 0)
  892.         return FALSE;
  893.  
  894.  
  895.     // Create the main application window
  896.     hWnd = CreateWindow(
  897.         lpszAppName,
  898.         lpszAppName,
  899.  
  900.         // OpenGL requires WS_CLIPCHILDREN and WS_CLIPSIBLINGS
  901.         WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
  902.  
  903.         // Window position and size
  904.         50, 50,
  905.         400, 400,
  906.         NULL,
  907.         NULL,
  908.         hInstance,
  909.         NULL);
  910.  
  911.     // If window was not created, quit
  912.     if (hWnd == NULL)
  913.         return FALSE;
  914.  
  915.  
  916.     // Display the window
  917.     ShowWindow(hWnd, SW_SHOW);
  918.     UpdateWindow(hWnd);
  919.  
  920.     // Process application messages until the application closes
  921.     while (GetMessage(&msg, NULL, 0, 0))
  922.     {
  923.         TranslateMessage(&msg);
  924.         DispatchMessage(&msg);
  925.     }
  926.  
  927.     return msg.wParam;
  928. }
  929.  
  930.  
  931.  
  932.  
  933. // Window procedure, handles all messages for this program
  934. LRESULT CALLBACK WndProc(HWND    hWnd,
  935.     UINT    message,
  936.     WPARAM  wParam,
  937.     LPARAM  lParam)
  938. {
  939.     static HGLRC hRC;               // Permenant Rendering context
  940.     static HDC hDC;                 // Private GDI Device context
  941.  
  942.     switch (message)
  943.     {
  944.         // Window creation, setup for OpenGL
  945.     case WM_CREATE:
  946.         // Store the device context
  947.         hDC = GetDC(hWnd);
  948.  
  949.         // Select the pixel format
  950.         SetDCPixelFormat(hDC);
  951.  
  952.         // Create palette if needed
  953.         hPalette = GetOpenGLPalette(hDC);
  954.  
  955.         // Create the rendering context and make it current
  956.         hRC = wglCreateContext(hDC);
  957.         wglMakeCurrent(hDC, hRC);
  958.         SetupRC();
  959.         glGenTextures(2, &texture[0]);                  // tworzy obiekt tekstury          
  960.  
  961.                                                         // ładuje pierwszy obraz tekstury:
  962.         bitmapData = LoadBitmapFile("Bitmapy\\checker.bmp", &bitmapInfoHeader);
  963.  
  964.         glBindTexture(GL_TEXTURE_2D, texture[0]);       // aktywuje obiekt tekstury
  965.  
  966.         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  967.         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  968.  
  969.         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  970.         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  971.  
  972.         // tworzy obraz tekstury
  973.         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitmapInfoHeader.biWidth,
  974.             bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmapData);
  975.  
  976.         if (bitmapData)
  977.             free(bitmapData);
  978.  
  979.         // ładuje drugi obraz tekstury:
  980.         bitmapData = LoadBitmapFile("Bitmapy\\crate.bmp", &bitmapInfoHeader);
  981.         glBindTexture(GL_TEXTURE_2D, texture[1]);       // aktywuje obiekt tekstury
  982.  
  983.         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  984.         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  985.  
  986.         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  987.         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  988.  
  989.         // tworzy obraz tekstury
  990.         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitmapInfoHeader.biWidth,
  991.             bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmapData);
  992.  
  993.         if (bitmapData)
  994.             free(bitmapData);
  995.  
  996.         SetTimer(hWnd, 101, 20, NULL);
  997.  
  998.         // ustalenie sposobu mieszania tekstury z tłem
  999.         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  1000.         break;
  1001.  
  1002.     case WM_TIMER:
  1003.         if (wParam == 101)
  1004.         {
  1005.             licznik++;
  1006.             if (licznik < 150)
  1007.             {
  1008.                 rot2 += 1.50;
  1009.                 rot4 += 1.2;
  1010.             }
  1011.             if (licznik > 150 && licznik < 300)
  1012.             {
  1013.                 rot2 -= 1.50;
  1014.                 rot4 -= 1.2;
  1015.             }
  1016.             if (licznik>300)
  1017.             {
  1018.                 licznik = 0;
  1019.             }
  1020.             InvalidateRect(hWnd, NULL, FALSE);
  1021.         }
  1022.         break;
  1023.  
  1024.         // Window is being destroyed, cleanup
  1025.     case WM_DESTROY:
  1026.         // Deselect the current rendering context and delete it
  1027.         wglMakeCurrent(hDC, NULL);
  1028.         wglDeleteContext(hRC);
  1029.  
  1030.         // Delete the palette if it was created
  1031.         if (hPalette != NULL)
  1032.             DeleteObject(hPalette);
  1033.  
  1034.         KillTimer(hWnd, 101);
  1035.  
  1036.         // Tell the application to terminate after the window
  1037.         // is gone.
  1038.         PostQuitMessage(0);
  1039.         break;
  1040.  
  1041.         // Window is resized.
  1042.     case WM_SIZE:
  1043.         // Call our function which modifies the clipping
  1044.         // volume and viewport
  1045.         ChangeSize(LOWORD(lParam), HIWORD(lParam));
  1046.         break;
  1047.  
  1048.  
  1049.         // The painting function.  This message sent by Windows
  1050.         // whenever the screen needs updating.
  1051.     case WM_PAINT:
  1052.     {
  1053.         // Call OpenGL drawing code
  1054.         RenderScene();
  1055.  
  1056.         SwapBuffers(hDC);
  1057.  
  1058.         // Validate the newly painted client area
  1059.         ValidateRect(hWnd, NULL);
  1060.     }
  1061.     break;
  1062.  
  1063.     // Windows is telling the application that it may modify
  1064.     // the system palette.  This message in essance asks the
  1065.     // application for a new palette.
  1066.     case WM_QUERYNEWPALETTE:
  1067.         // If the palette was created.
  1068.         if (hPalette)
  1069.         {
  1070.             int nRet;
  1071.  
  1072.             // Selects the palette into the current device context
  1073.             SelectPalette(hDC, hPalette, FALSE);
  1074.  
  1075.             // Map entries from the currently selected palette to
  1076.             // the system palette.  The return value is the number
  1077.             // of palette entries modified.
  1078.             nRet = RealizePalette(hDC);
  1079.  
  1080.             // Repaint, forces remap of palette in current window
  1081.             InvalidateRect(hWnd, NULL, FALSE);
  1082.  
  1083.             return nRet;
  1084.         }
  1085.         break;
  1086.  
  1087.  
  1088.         // This window may set the palette, even though it is not the
  1089.         // currently active window.
  1090.     case WM_PALETTECHANGED:
  1091.         // Don't do anything if the palette does not exist, or if
  1092.         // this is the window that changed the palette.
  1093.         if ((hPalette != NULL) && ((HWND)wParam != hWnd))
  1094.         {
  1095.             // Select the palette into the device context
  1096.             SelectPalette(hDC, hPalette, FALSE);
  1097.  
  1098.             // Map entries to system palette
  1099.             RealizePalette(hDC);
  1100.  
  1101.             // Remap the current colors to the newly realized palette
  1102.             UpdateColors(hDC);
  1103.             return 0;
  1104.         }
  1105.         break;
  1106.  
  1107.         // Key press, check for arrow keys to do cube rotation.
  1108.     case WM_KEYDOWN:
  1109.     {
  1110.         if (wParam == VK_UP)
  1111.             xRot -= 5.0f;
  1112.  
  1113.         if (wParam == VK_DOWN)
  1114.             xRot += 5.0f;
  1115.  
  1116.         if (wParam == VK_LEFT)
  1117.             yRot -= 5.0f;
  1118.  
  1119.         if (wParam == VK_RIGHT)
  1120.             yRot += 5.0f;
  1121.  
  1122.         if (wParam == '7')
  1123.             xRot2 -= 5.0f;
  1124.  
  1125.         if (wParam == '8')
  1126.             xRot2 += 5.0f;
  1127.  
  1128.         if (wParam == '9')
  1129.             yRot2 -= 5.0f;
  1130.  
  1131.         if (wParam == '0')
  1132.             yRot2 += 5.0f;
  1133.  
  1134.         if (wParam == '1')
  1135.             rot1 -= 5.0f;
  1136.         if (wParam == '2')
  1137.             rot1 += 5.0f;
  1138.         if (wParam == '3')
  1139.             rot2 -= 5.0f;
  1140.         if (wParam == '4')
  1141.             rot2 += 5.0f;
  1142.         if (wParam == '5')
  1143.             rot3 -= 5.0f;
  1144.         if (wParam == '6')
  1145.             rot3 += 5.0f;
  1146.  
  1147.         if (wParam == 'Q')
  1148.             rot4 -= 5.0f;
  1149.         if (wParam == 'W')
  1150.             rot4 += 5.0f;
  1151.         if (wParam == 'E')
  1152.             rot5 -= 5.0f;
  1153.         if (wParam == 'R')
  1154.             rot5 += 5.0f;
  1155.         if (wParam == 'T')
  1156.             rot6 -= 5.0f;
  1157.         if (wParam == 'Y')
  1158.             rot6 += 5.0f;
  1159.  
  1160.         xRot = (const int)xRot % 360;
  1161.         yRot = (const int)yRot % 360;
  1162.  
  1163.         InvalidateRect(hWnd, NULL, FALSE);
  1164.     }
  1165.     break;
  1166.  
  1167.     // A menu command
  1168.     case WM_COMMAND:
  1169.     {
  1170.         switch (LOWORD(wParam))
  1171.         {
  1172.             // Exit the program
  1173.         case ID_FILE_EXIT:
  1174.             DestroyWindow(hWnd);
  1175.             break;
  1176.         }
  1177.     }
  1178.     break;
  1179.  
  1180.  
  1181.     default:   // Passes it on if unproccessed
  1182.         return (DefWindowProc(hWnd, message, wParam, lParam));
  1183.  
  1184.     }
  1185.  
  1186.     return (0L);
  1187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement