MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / createFBO

Function createFBO

src/content/Animations/SplashCursor/SplashCursor.jsx:590–621  ·  view source on GitHub ↗
(w, h, internalFormat, format, type, param)

Source from the content-addressed store, hash-verified

588 }
589
590 function createFBO(w, h, internalFormat, format, type, param) {
591 gl.activeTexture(gl.TEXTURE0);
592 let texture = gl.createTexture();
593 gl.bindTexture(gl.TEXTURE_2D, texture);
594 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, param);
595 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, param);
596 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
597 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
598 gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, w, h, 0, format, type, null);
599
600 let fbo = gl.createFramebuffer();
601 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
602 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
603 gl.viewport(0, 0, w, h);
604 gl.clear(gl.COLOR_BUFFER_BIT);
605
606 let texelSizeX = 1.0 / w;
607 let texelSizeY = 1.0 / h;
608 return {
609 texture,
610 fbo,
611 width: w,
612 height: h,
613 texelSizeX,
614 texelSizeY,
615 attach(id) {
616 gl.activeTexture(gl.TEXTURE0 + id);
617 gl.bindTexture(gl.TEXTURE_2D, texture);
618 return id;
619 }
620 };
621 }
622
623 function createDoubleFBO(w, h, internalFormat, format, type, param) {
624 let fbo1 = createFBO(w, h, internalFormat, format, type, param);

Callers 4

initFramebuffersFunction · 0.70
createDoubleFBOFunction · 0.70
resizeFBOFunction · 0.70
resizeDoubleFBOFunction · 0.70

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected