文件名称:WebGL助手库TWGL.zip
文件大小:18.49MB
文件格式:ZIP
更新时间:2022-08-08 07:19:03
开源项目
TWGL.js 是一个微型的 WebGL 助手库,实现对 WebGL API 的简单封装,使用起来更方便。示例代码: [removed][removed] [removed] var gl = twgl.getWebGLContext(document.getElementById("c")); var programInfo = twgl.createProgramInfo(gl, ["vs", "fs"]); var arrays = { position: [-1, -1, 0, 1, -1, 0, -1, 1, 0, -1, 1, 0, 1, -1, 0, 1, 1, 0], }; var bufferInfo = twgl.createBufferInfoFromArrays(gl, arrays); var start = Date.now() * 0.001; function render() { twgl.resizeCanvasToDisplaySize(gl.canvas); gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); var uniforms = { time: Date.now() * 0.001 - start, resolution: [gl.canvas.width, gl.canvas.height], }; gl.useProgram(programInfo.program); twgl.setBuffersAndAttributes(gl, programInfo, bufferInfo); twgl.setUniforms(programInfo, uniforms); twgl.drawBufferInfo(gl, gl.TRIANGLES, bufferInfo); requestAnimationFrame(render); } render(); [removed] 标签:TWGL