Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.3 KiB

  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <gl\gl.h>
  4. #include "skeltest.h"
  5. #include "small1.h"
  6. SmallTriangle::SmallTriangle()
  7. {
  8. td.swapbuffers = FALSE;
  9. td.iDuration = 10000;
  10. td.iX = 0;
  11. td.iY = 0;
  12. td.iW = 640;
  13. td.iH = 480;
  14. sprintf(td.acName, "Small Triangle (demo only)");
  15. bd.cColorBits = 8;
  16. bd.cDepthBits = 16;
  17. bFlip = FALSE;
  18. }
  19. void SmallTriangle::INITFUNCTION()
  20. {
  21. if (h == 0)
  22. h = 1;
  23. td.iW = w;
  24. td.iH = h;
  25. glViewport(0,0,w,h);
  26. glLoadIdentity();
  27. glOrtho(0.0f, w, 0.0f, h, 1.0f, -1.0f);
  28. }
  29. void SmallTriangle::IDLEFUNCTION()
  30. {
  31. bFlip = !bFlip;
  32. }
  33. void SmallTriangle::RENDFUNCTION()
  34. {
  35. int xa,xb,ya,yb;
  36. // glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  37. // glClear(GL_COLOR_BUFFER_BIT);
  38. if (bFlip)
  39. glColor3f(1.0f, 0.0f, 0.0f);
  40. else
  41. glColor3f(0.0f, 0.0f, 1.0f);
  42. glBegin(GL_TRIANGLES);
  43. for(ya = 0, yb = 10 ; yb <= td.iH ; ya += 10, yb += 10)
  44. for(xa = 0, xb = 10 ; xb <= td.iW ; xa += 10, xb += 10) {
  45. if (bFlip) {
  46. glVertex2i(xa, ya);
  47. glVertex2i(xa, yb);
  48. glVertex2i(xb, yb);
  49. } else {
  50. glVertex2i(xa, ya);
  51. glVertex2i(xb, yb);
  52. glVertex2i(xb, ya);
  53. }
  54. }
  55. glEnd();
  56. glFlush();
  57. }