Source: Core/PixelFormat.js

  1. /*global define*/
  2. define([
  3. '../Renderer/WebGLConstants',
  4. './freezeObject'
  5. ], function(
  6. WebGLConstants,
  7. freezeObject) {
  8. 'use strict';
  9. /**
  10. * The format of a pixel, i.e., the number of components it has and what they represent.
  11. *
  12. * @exports PixelFormat
  13. */
  14. var PixelFormat = {
  15. /**
  16. * A pixel format containing a depth value.
  17. *
  18. * @type {Number}
  19. * @constant
  20. */
  21. DEPTH_COMPONENT : WebGLConstants.DEPTH_COMPONENT,
  22. /**
  23. * A pixel format containing a depth and stencil value, most often used with {@link PixelDatatype.UNSIGNED_INT_24_8}.
  24. *
  25. * @type {Number}
  26. * @constant
  27. */
  28. DEPTH_STENCIL : WebGLConstants.DEPTH_STENCIL,
  29. /**
  30. * A pixel format containing an alpha channel.
  31. *
  32. * @type {Number}
  33. * @constant
  34. */
  35. ALPHA : WebGLConstants.ALPHA,
  36. /**
  37. * A pixel format containing red, green, and blue channels.
  38. *
  39. * @type {Number}
  40. * @constant
  41. */
  42. RGB : WebGLConstants.RGB,
  43. /**
  44. * A pixel format containing red, green, blue, and alpha channels.
  45. *
  46. * @type {Number}
  47. * @constant
  48. */
  49. RGBA : WebGLConstants.RGBA,
  50. /**
  51. * A pixel format containing a luminance (intensity) channel.
  52. *
  53. * @type {Number}
  54. * @constant
  55. */
  56. LUMINANCE : WebGLConstants.LUMINANCE,
  57. /**
  58. * A pixel format containing luminance (intensity) and alpha channels.
  59. *
  60. * @type {Number}
  61. * @constant
  62. */
  63. LUMINANCE_ALPHA : WebGLConstants.LUMINANCE_ALPHA,
  64. /**
  65. * @private
  66. */
  67. validate : function(pixelFormat) {
  68. return pixelFormat === PixelFormat.DEPTH_COMPONENT ||
  69. pixelFormat === PixelFormat.DEPTH_STENCIL ||
  70. pixelFormat === PixelFormat.ALPHA ||
  71. pixelFormat === PixelFormat.RGB ||
  72. pixelFormat === PixelFormat.RGBA ||
  73. pixelFormat === PixelFormat.LUMINANCE ||
  74. pixelFormat === PixelFormat.LUMINANCE_ALPHA;
  75. },
  76. /**
  77. * @private
  78. */
  79. isColorFormat : function(pixelFormat) {
  80. return pixelFormat === PixelFormat.ALPHA ||
  81. pixelFormat === PixelFormat.RGB ||
  82. pixelFormat === PixelFormat.RGBA ||
  83. pixelFormat === PixelFormat.LUMINANCE ||
  84. pixelFormat === PixelFormat.LUMINANCE_ALPHA;
  85. },
  86. /**
  87. * @private
  88. */
  89. isDepthFormat : function(pixelFormat) {
  90. return pixelFormat === PixelFormat.DEPTH_COMPONENT ||
  91. pixelFormat === PixelFormat.DEPTH_STENCIL;
  92. }
  93. };
  94. return freezeObject(PixelFormat);
  95. });