feat: Initialize shader background vertex buffer with full-screen quad data and bind to all programs, replacing previous 4-vertex buffer setup.

This commit is contained in:
code002lover 2025-12-06 20:27:47 +01:00
parent d2a8edb004
commit 12592e3726

View File

@ -927,6 +927,61 @@ export function ShaderBackground() {
)
return;
const posBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, posBuffer);
gl.bufferData(
gl.ARRAY_BUFFER,
new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]),
gl.STATIC_DRAW
);
{
gl.useProgram(buffer_1_program);
const posAttrLocation = gl.getAttribLocation(
buffer_1_program,
"a_position"
);
gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(posAttrLocation);
}
{
gl.useProgram(buffer_2_program);
const posAttrLocation = gl.getAttribLocation(
buffer_2_program,
"a_position"
);
gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(posAttrLocation);
}
{
gl.useProgram(buffer_3_program);
const posAttrLocation = gl.getAttribLocation(
buffer_3_program,
"a_position"
);
gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(posAttrLocation);
}
{
gl.useProgram(buffer_4_program);
const posAttrLocation = gl.getAttribLocation(
buffer_4_program,
"a_position"
);
gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(posAttrLocation);
}
{
gl.useProgram(finalProgram);
const posAttrLocation = gl.getAttribLocation(finalProgram, "a_position");
gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(posAttrLocation);
}
function setResolution(
program: WebGLProgram,
canvas: HTMLCanvasElement,
@ -1034,14 +1089,6 @@ export function ShaderBackground() {
console.log("Framebuffer is unknown");
}
const posBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, posBuffer);
gl.bufferData(
gl.ARRAY_BUFFER,
new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]),
gl.STATIC_DRAW
);
const ichannel0_location_buffer_1 = gl.getUniformLocation(
buffer_1_program as WebGLProgram,
"iChannel0"