MCPcopy Index your code
hub / github.com/plotly/plotly.js / createFBO

Function createFBO

stackgl_modules/index.js:15316–15404  ·  view source on GitHub ↗
(gl, width, height, options)

Source from the content-addressed store, hash-verified

15314}
15315
15316function createFBO(gl, width, height, options) {
15317
15318 //Update frame buffer error code values
15319 if(!FRAMEBUFFER_UNSUPPORTED) {
15320 FRAMEBUFFER_UNSUPPORTED = gl.FRAMEBUFFER_UNSUPPORTED
15321 FRAMEBUFFER_INCOMPLETE_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT
15322 FRAMEBUFFER_INCOMPLETE_DIMENSIONS = gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS
15323 FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
15324 }
15325
15326 //Lazily initialize color attachment arrays
15327 var WEBGL_draw_buffers = gl.getExtension('WEBGL_draw_buffers')
15328 if(!colorAttachmentArrays && WEBGL_draw_buffers) {
15329 lazyInitColorAttachments(gl, WEBGL_draw_buffers)
15330 }
15331
15332 //Special case: Can accept an array as argument
15333 if(Array.isArray(width)) {
15334 options = height
15335 height = width[1]|0
15336 width = width[0]|0
15337 }
15338
15339 if(typeof width !== 'number') {
15340 throw new Error('gl-fbo: Missing shape parameter')
15341 }
15342
15343 //Validate width/height properties
15344 var maxFBOSize = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE)
15345 if(width < 0 || width > maxFBOSize || height < 0 || height > maxFBOSize) {
15346 throw new Error('gl-fbo: Parameters are too large for FBO')
15347 }
15348
15349 //Handle each option type
15350 options = options || {}
15351
15352 //Figure out number of color buffers to use
15353 var numColors = 1
15354 if('color' in options) {
15355 numColors = Math.max(options.color|0, 0)
15356 if(numColors < 0) {
15357 throw new Error('gl-fbo: Must specify a nonnegative number of colors')
15358 }
15359 if(numColors > 1) {
15360 //Check if multiple render targets supported
15361 if(!WEBGL_draw_buffers) {
15362 throw new Error('gl-fbo: Multiple draw buffer extension not supported')
15363 } else if(numColors > gl.getParameter(WEBGL_draw_buffers.MAX_COLOR_ATTACHMENTS_WEBGL)) {
15364 throw new Error('gl-fbo: Context does not support ' + numColors + ' draw buffers')
15365 }
15366 }
15367 }
15368
15369 //Determine whether to use floating point textures
15370 var colorType = gl.UNSIGNED_BYTE
15371 var OES_texture_float = gl.getExtension('OES_texture_float')
15372 if(options.float && numColors > 0) {
15373 if(!OES_texture_float) {

Callers 2

createSceneFunction · 0.85
createSelectBufferFunction · 0.85

Calls 1

lazyInitColorAttachmentsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…