This commit is contained in:
John Gatward
2026-03-18 15:24:08 +00:00
parent 213cf5f535
commit 3cb8d5a14e
17 changed files with 1525 additions and 331 deletions

20
projects/tsp/shaders.js Normal file
View File

@@ -0,0 +1,20 @@
// shaders.js
export function loadShader(gl, type, source) {
const shader = gl.createShader(type);
gl.shaderSource(shader, source);
gl.compileShader(shader);
return shader;
}
export function createShaderProgram(gl, vertexCode, fragCode) {
const vertexShader = loadShader(gl, gl.VERTEX_SHADER, vertexCode);
const fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fragCode);
const program = gl.createProgram();
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
return program;
}