/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
src/rendering/renderers/gl/shader/program/getUniformData.ts
39 строк
1 KB
Mat Groves
add docs for GlProgram and GpuProgram
26 окт 2023, 19:19
26 окт 2023, 19:19
700d85a
Код
Авторство
О чём код?
import { defaultValue } from './defaultValue'; import { mapType } from './mapType'; import type { GlUniformData } from '../GlProgram'; /** * returns the uniform data from the program * @private * @param program - the webgl program * @param gl - the WebGL context * @returns {object} the uniform data for this program */ export function getUniformData(program: WebGLProgram, gl: WebGLRenderingContextBase): {[key: string]: GlUniformData} { const uniforms: {[key: string]: GlUniformData} = {}; const totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); for (let i = 0; i < totalUniforms; i++) { const uniformData = gl.getActiveUniform(program, i); const name = uniformData.name.replace(/\[.*?\]$/, ''); const isArray = !!(uniformData.name.match(/\[.*?\]$/)); const type = mapType(gl, uniformData.type); uniforms[name] = { name, index: i, type, size: uniformData.size, isArray, value: defaultValue(type, uniformData.size), }; } return uniforms; }