MCPcopy
hub / github.com/PavelDoGreat/WebGL-Fluid-Simulation / createFBO

Function createFBO

script.js:1045–1077  ·  view source on GitHub ↗
(w, h, internalFormat, format, type, param)

Source from the content-addressed store, hash-verified

1043}
1044
1045function createFBO (w, h, internalFormat, format, type, param) {
1046 gl.activeTexture(gl.TEXTURE0);
1047 let texture = gl.createTexture();
1048 gl.bindTexture(gl.TEXTURE_2D, texture);
1049 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, param);
1050 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, param);
1051 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
1052 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
1053 gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, w, h, 0, format, type, null);
1054
1055 let fbo = gl.createFramebuffer();
1056 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
1057 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
1058 gl.viewport(0, 0, w, h);
1059 gl.clear(gl.COLOR_BUFFER_BIT);
1060
1061 let texelSizeX = 1.0 / w;
1062 let texelSizeY = 1.0 / h;
1063
1064 return {
1065 texture,
1066 fbo,
1067 width: w,
1068 height: h,
1069 texelSizeX,
1070 texelSizeY,
1071 attach (id) {
1072 gl.activeTexture(gl.TEXTURE0 + id);
1073 gl.bindTexture(gl.TEXTURE_2D, texture);
1074 return id;
1075 }
1076 };
1077}
1078
1079function createDoubleFBO (w, h, internalFormat, format, type, param) {
1080 let fbo1 = createFBO(w, h, internalFormat, format, type, param);

Callers 7

captureScreenshotFunction · 0.85
initFramebuffersFunction · 0.85
initBloomFramebuffersFunction · 0.85
initSunraysFramebuffersFunction · 0.85
createDoubleFBOFunction · 0.85
resizeFBOFunction · 0.85
resizeDoubleFBOFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected