¡Solo uso la matriz para dibujar un cuadrado! Solo la matriz se actualiza en cada renderizado. Cómo eliminar Vertex Position de mis códigos
bloquear así https://webgl2fundamentals.org/webgl/lessons/webgl-drawing-without-data.html
#version 300 es in vec4 a_position; in vec2 a_texcoord; uniform mat4 u_matrix; out vec2 v_texcoord; void main() ngl_Position = u_matrix * a_position; v_texcoord = a_texcoord; }y elimina esto
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0]), gl.STATIC_DRAW);Perdón por usar Google Traductor
Aquí está su sombreador de vértice cuadrado. No es necesario utilizar una matriz.
#version 300 es void main() { float xs[6] = float[](0.0, 0.0, 1.0, 0.0, 1.0, 1.0); float ys[6] = float[](0.0, 1.0, 0.0, 1.0, 1.0, 0.0); float x = xs[gl_VertexID]; float y = ys[gl_VertexID]; gl_Position = vec4(x, y, 0, 1); }Y para rendirte solo haz esto. No necesita hacer ningún bufferData ni ningún uniforme.
gl.drawArrays(gl.TRIANGLES, 0, 6);