Clone of mesa.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

gamma.c 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* Draw test patterns to help determine correct gamma value for a display.
  2. When the intensities of the inner squares nearly match the intensities
  3. of their frames (from some distance the borders should disappear) then
  4. you've found the right gamma value.
  5. You can set Mesa's gamma values (for red, green and blue) with the
  6. MESA_GAMMA environment variable. But only on X windows!
  7. For example:
  8. setenv MESA_GAMMA 1.5 1.6 1.4
  9. Sets the red gamma value to 1.5, green to 1.6 and blue to 1.4.
  10. See the main README file for more information.
  11. For more info about gamma correction see:
  12. http://www.inforamp.net/~poynton/notes/colour_and_gamma/GammaFAQ.html
  13. This program is in the public domain
  14. Brian Paul 19 Oct 1995
  15. Kai Schuetz 05 Jun 1999 */
  16. /* Conversion to GLUT by Mark J. Kilgard */
  17. #include <stdio.h>
  18. #include <string.h>
  19. #include <stdlib.h>
  20. #include <GL/glut.h>
  21. static void
  22. Reshape(int width, int height)
  23. {
  24. glViewport(0, 0, (GLint) width, (GLint) height);
  25. glMatrixMode(GL_PROJECTION);
  26. glLoadIdentity();
  27. glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
  28. glMatrixMode(GL_MODELVIEW);
  29. glShadeModel(GL_FLAT);
  30. }
  31. /* ARGSUSED1 */
  32. static void
  33. key_esc(unsigned char key, int x, int y)
  34. {
  35. if(key == 27) exit(0); /* Exit on Escape */
  36. }
  37. static GLubyte p25[] = {
  38. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  39. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  40. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  41. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  42. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  43. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  44. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  45. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  46. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  47. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  48. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  49. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  50. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  51. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  52. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  53. 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
  54. };
  55. static GLubyte p50[] = {
  56. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  57. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  58. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  59. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  60. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  61. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  62. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  63. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  64. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  65. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  66. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  67. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  68. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  69. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  70. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  71. 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
  72. };
  73. static GLubyte p75[] = {
  74. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  75. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  76. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  77. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  78. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  79. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  80. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  81. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  82. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  83. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  84. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  85. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  86. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  87. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  88. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  89. 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff,
  90. };
  91. static GLubyte *stippletab[4] = {NULL, p25, p50, p75};
  92. static void
  93. gamma_ramp(GLfloat yoffs, GLfloat r, GLfloat g, GLfloat b)
  94. {
  95. GLint d;
  96. glColor3f(0.0, 0.0, 0.0); /* solid black, no stipple */
  97. glRectf(-1.0, yoffs, -0.6, yoffs + 0.5);
  98. for(d = 1; d < 4; d++) { /* increasing density from 25% to 75% */
  99. GLfloat xcoord = (-1.0 + d*0.4);
  100. GLfloat t = d * 0.25;
  101. glColor3f(r*t, g*t, b*t); /* draw outer rect */
  102. glRectf(xcoord, yoffs, xcoord+0.4, yoffs + 0.5);
  103. glColor3f(0.0, 0.0, 0.0); /* "clear" inner rect */
  104. glRectf(xcoord + 0.1, yoffs + 0.125, xcoord + 0.3, yoffs + 0.375);
  105. glColor3f(r, g, b); /* draw stippled inner rect */
  106. glEnable(GL_POLYGON_STIPPLE);
  107. glPolygonStipple(stippletab[d]);
  108. glRectf(xcoord + 0.1, yoffs + 0.125, xcoord + 0.3, yoffs + 0.375);
  109. glDisable(GL_POLYGON_STIPPLE);
  110. }
  111. glColor3f(r, g, b); /* solid color, no stipple */
  112. glRectf(0.6, yoffs, 1.0, yoffs + 0.5);
  113. }
  114. static void
  115. display(void)
  116. {
  117. gamma_ramp( 0.5, 1.0, 1.0, 1.0); /* white ramp */
  118. gamma_ramp( 0.0, 1.0, 0.0, 0.0); /* red ramp */
  119. gamma_ramp(-0.5, 0.0, 1.0, 0.0); /* green ramp */
  120. gamma_ramp(-1.0, 0.0, 0.0, 1.0); /* blue ramp */
  121. glFlush();
  122. }
  123. int
  124. main(int argc, char **argv)
  125. {
  126. glutInit(&argc, argv);
  127. glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
  128. glutInitWindowPosition(50, 50);
  129. glutInitWindowSize(500, 400);
  130. glutCreateWindow("gamma test patterns");
  131. glutReshapeFunc(Reshape);
  132. glutDisplayFunc(display);
  133. glutKeyboardFunc(key_esc);
  134. glutMainLoop();
  135. return 0; /* ANSI C requires main to return int. */
  136. }