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.

146 lines
2.6 KiB

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <windows.h>
  4. #include <GL/gl.h>
  5. #include <GL/glu.h>
  6. #include "glaux.h"
  7. GLboolean single = GL_FALSE;
  8. GLboolean no_op = GL_FALSE;
  9. int width = 512;
  10. int height = 512;
  11. void TriangleAt(GLfloat x, GLfloat y, GLfloat z,
  12. GLfloat w, GLfloat h,
  13. BOOL colors)
  14. {
  15. glPushMatrix();
  16. glTranslatef(x, y, z);
  17. glBegin (GL_TRIANGLES);
  18. if (colors)
  19. {
  20. glColor3f(1.0f, 0.0f, 0.0f);
  21. }
  22. glVertex2f (0.0f, 0.0f);
  23. if (colors)
  24. {
  25. glColor3f(0.0f, 1.0f, 0.0f);
  26. }
  27. glVertex2f (w, h);
  28. if (colors)
  29. {
  30. glColor3f(0.0f, 0.0f, 1.0f);
  31. }
  32. glVertex2f (0.0f, h);
  33. glEnd ();
  34. glPopMatrix();
  35. }
  36. void SquareAt(GLfloat x, GLfloat y, GLfloat z,
  37. GLfloat w, GLfloat h,
  38. BOOL colors)
  39. {
  40. glPushMatrix();
  41. glTranslatef(x, y, z);
  42. glBegin (GL_POLYGON);
  43. if (colors)
  44. {
  45. glColor3f(1.0f, 0.0f, 0.0f);
  46. }
  47. glVertex2f (0.0f, 0.0f);
  48. if (colors)
  49. {
  50. glColor3f(0.0f, 1.0f, 0.0f);
  51. }
  52. glVertex2f (w, 0.0f);
  53. if (colors)
  54. {
  55. glColor3f(0.0f, 0.0f, 1.0f);
  56. }
  57. glVertex2f (w, h);
  58. if (colors)
  59. {
  60. glColor3f(1.0f, 0.0f, 1.0f);
  61. }
  62. glVertex2f (0.0f, h);
  63. glEnd ();
  64. glPopMatrix();
  65. }
  66. void Test(void)
  67. {
  68. int x, y;
  69. for (y = 0; y < 4; y++)
  70. {
  71. for (x = 0; x < 4; x++)
  72. {
  73. glDisable(GL_COLOR_LOGIC_OP);
  74. glColor3ub(255, 0, 0);
  75. TriangleAt(-1.0f+x*0.5f, -1.0f+y*0.5f, 0.0f, 0.5f, 0.5f, FALSE);
  76. if (!no_op)
  77. {
  78. glEnable(GL_COLOR_LOGIC_OP);
  79. glLogicOp(GL_CLEAR+x+y*4);
  80. glColor3ub(255, 255, 0);
  81. SquareAt(-1.0f+x*0.5f, -1.0f+y*0.5f, 0.0f, 0.5f, 0.5f, FALSE);
  82. }
  83. }
  84. }
  85. }
  86. void Display(void)
  87. {
  88. glClear(GL_COLOR_BUFFER_BIT);
  89. Test();
  90. if (single)
  91. {
  92. glFlush();
  93. }
  94. else
  95. {
  96. auxSwapBuffers();
  97. }
  98. }
  99. void Reshape(GLsizei w, GLsizei h)
  100. {
  101. glViewport(0, 0, w, h);
  102. width = w;
  103. height = h;
  104. }
  105. int __cdecl main(int argc, char** argv)
  106. {
  107. GLenum mode;
  108. while (--argc > 0)
  109. {
  110. argv++;
  111. if (!strcmp(*argv, "-sb"))
  112. {
  113. single = GL_TRUE;
  114. }
  115. else if (!strcmp(*argv, "-noop"))
  116. {
  117. no_op = GL_TRUE;
  118. }
  119. }
  120. mode = AUX_RGB | (single ? AUX_SINGLE : AUX_DOUBLE);
  121. auxInitDisplayMode(mode);
  122. auxInitPosition(10, 10, width, height);
  123. auxInitWindow("RGB Logic Op Test");
  124. auxReshapeFunc(Reshape);
  125. auxMainLoop(Display);
  126. return 0;
  127. }