Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@hscmap/gl-wrapper
Advanced tools
Simple wrapper classes of WebGL objects in TypeScript.
npm instasll --save @hscmap/gl-wrapper
git clone https://github.com/michitaro/gl-wrapper.git
cd gl-wrapper
npm install
npm run example
import { canvasPool, Program, AttribList, Texture } from '@hscmap/gl-wrapper'
window.addEventListener('load', async () => {
const { canvas, gl } = canvasPool.pull({ alpha: false })
const mp = document.querySelector('#mount-point')!
mp.appendChild(canvas)
resizeCanvasContext(canvas)
const img = await loadImage(require<"file-loader">("file-loader!./texture/scene.jpg"))
gl.clear(gl.COLOR_BUFFER_BIT)
drawRGBTriangle(gl)
drawTexture(gl, img)
})
function resizeCanvasContext(canvas: HTMLCanvasElement) {
canvas.style.width = '100%'
canvas.style.height = '100%'
const gl = canvas.getContext('webgl')!
const r = devicePixelRatio
const w = r * canvas.clientWidth
const h = r * canvas.clientHeight
canvas.width = w
canvas.height = h
gl.viewport(0, 0, w, h)
}
async function loadImage(url: string) {
return new Promise<HTMLImageElement>(resolve => {
const img = new Image()
img.onload = () => resolve(img)
img.src = url
})
}
function drawRGBTriangle(gl: WebGLRenderingContext) {
const program = Program.new(gl,
require<"raw-loader">('raw-loader!./rgb_triangle/vert.glsl'),
require<"raw-loader">('raw-loader!./rgb_triangle/frag.glsl'))
const attribList = new AttribList(gl, {
members: [
{ name: 'a_coord', nComponents: 2 },
{ name: 'a_color', nComponents: 4 },
],
array: new Float32Array([
/* a_coord */ -1, -1, /* a_color */ +1, +0, +0, +1,
/* a_coord */ +1, -1, /* a_color */ +0, +1, +0, +1,
/* a_coord */ +0, +1, /* a_color */ +0, +0, +1, +1,
])
})
program.enableAttribList(attribList, () => {
gl.drawArrays(gl.TRIANGLES, 0, attribList.vertexCount)
})
attribList.release()
program.release()
}
function drawTexture(gl: WebGLRenderingContext, img: HTMLImageElement) {
const program = Program.new(gl,
require<'raw-loader'>('raw-loader!./texture/vert.glsl'),
require<'raw-loader'>('raw-loader!./texture/frag.glsl'))
const attribList = new AttribList(gl, {
members: [{ name: 'a_coord', nComponents: 2 }],
array: new Float32Array([
0, 0,
1, 0,
0, 1,
1, 1,
])
})
const texture = new Texture(gl)
texture.setImage(img)
program.uniform1i({ u_texture0: 0 })
program.enableAttribList(attribList, () => {
texture.bind(() => {
gl.drawArrays(gl.TRIANGLE_STRIP, 0, attribList.vertexCount)
})
})
texture.release()
attribList.release()
program.release()
}
FAQs
Simple wrapper classes of WebGL objects in TypeScript. * [Working Demo](https://michitaro.github.io/gl-wrapper/)
The npm package @hscmap/gl-wrapper receives a total of 1 weekly downloads. As such, @hscmap/gl-wrapper popularity was classified as not popular.
We found that @hscmap/gl-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.