All files / engine/Source/Renderer RenderbufferFormat.js

28.57% Statements 2/7
71.42% Branches 10/14
50% Functions 1/2
28.57% Lines 2/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43          1x                         135x                                                
import WebGLConstants from "../Core/WebGLConstants.js";
 
/**
 * @private
 */
const RenderbufferFormat = {
  RGBA4: WebGLConstants.RGBA4,
  RGBA8: WebGLConstants.RGBA8,
  RGBA16F: WebGLConstants.RGBA16F,
  RGBA32F: WebGLConstants.RGBA32F,
  RGB5_A1: WebGLConstants.RGB5_A1,
  RGB565: WebGLConstants.RGB565,
  DEPTH_COMPONENT16: WebGLConstants.DEPTH_COMPONENT16,
  STENCIL_INDEX8: WebGLConstants.STENCIL_INDEX8,
  DEPTH_STENCIL: WebGLConstants.DEPTH_STENCIL,
  DEPTH24_STENCIL8: WebGLConstants.DEPTH24_STENCIL8,
 
  validate: function (renderbufferFormat) {
    return (
      renderbufferFormat === RenderbufferFormat.RGBA4 ||
      renderbufferFormat === RenderbufferFormat.RGBA8 ||
      renderbufferFormat === RenderbufferFormat.RGBA16F ||
      renderbufferFormat === RenderbufferFormat.RGBA32F ||
      renderbufferFormat === RenderbufferFormat.RGB5_A1 ||
      renderbufferFormat === RenderbufferFormat.RGB565 ||
      renderbufferFormat === RenderbufferFormat.DEPTH_COMPONENT16 ||
      renderbufferFormat === RenderbufferFormat.STENCIL_INDEX8 ||
      renderbufferFormat === RenderbufferFormat.DEPTH_STENCIL ||
      renderbufferFormat === RenderbufferFormat.DEPTH24_STENCIL8
    );
  },
 
  getColorFormat: function (datatype) {
    if (datatype === WebGLConstants.FLOAT) {
      return RenderbufferFormat.RGBA32F;
    } else if (datatype === WebGLConstants.HALF_FLOAT_OES) {
      return RenderbufferFormat.RGBA16F;
    }
    return RenderbufferFormat.RGBA8;
  },
};
export default Object.freeze(RenderbufferFormat);