tsp
This commit is contained in:
19
projects/tsp/canvas.js
Normal file
19
projects/tsp/canvas.js
Normal file
@@ -0,0 +1,19 @@
|
||||
export function setupCanvas(gl, canvas) {
|
||||
canvas.width = canvas.clientWidth * window.devicePixelRatio;
|
||||
canvas.height = canvas.clientHeight * window.devicePixelRatio;
|
||||
gl.viewport(0, 0, canvas.width, canvas.height);
|
||||
|
||||
return {
|
||||
canvas,
|
||||
gl,
|
||||
aspectRatio: canvas.width / canvas.height
|
||||
};
|
||||
}
|
||||
|
||||
export function resizeCanvas(gl, canvas, program) {
|
||||
canvas.width = canvas.clientWidth * window.devicePixelRatio;
|
||||
canvas.height = canvas.clientHeight * window.devicePixelRatio;
|
||||
gl.viewport(0, 0, canvas.width, canvas.height);
|
||||
gl.useProgram(program);
|
||||
gl.uniform2f(gl.getUniformLocation(program, "u_resolution"), canvas.width, canvas.height);
|
||||
}
|
||||
Reference in New Issue
Block a user