webgl-fundamentals icon indicating copy to clipboard operation
webgl-fundamentals copied to clipboard

webgl-state-diagram

Open letochagone opened this issue 3 years ago • 3 comments

i download webgl-state-diagram.html and add some samples . So i added a sample with a vertexAttrib4fv. And i watch step by step, but the step gl.vertexAttrib4fv(posLoc1,[0.5,0.5,0.,1.]); does not appear in the vertex Array window. if i put that code ( two stable attribute) : const posLoc1 = gl.getAttribLocation(program1Attrib, 'position1); gl.disableVertexAttribArray(posLoc1); gl.vertexAttrib4fv(posLoc1,[0.3,0.2,0.,1.]); const posLoc2 = gl.getAttribLocation(program1Attrib, 'position2'); gl.disableVertexAttribArray(posLoc2); gl.vertexAttrib4fv(posLoc2,[0.5,0.5,0.,1.]); And i watch step by step, in the vertex Array window, there is only posLoc1

letochagone avatar Jan 27 '21 18:01 letochagone

The state diagram is not designed as a debugging tool. It is only designed to show the things that appear in the samples. The samples do not use gl.vertexAttrib4fv so no support for gl.vertexAttrib4fv exists in the state diagram code.

greggman avatar Jan 28 '21 00:01 greggman

i did add a code for my understanding :

`const posLoc1 = gl.getAttribLocation(program1Attrib, 'position'); gl.disableVertexAttribArray(posLoc1); gl.vertexAttrib4fv(posLoc1,[0.5,0.5,0.,1.]);

const sizeLoc = gl.getAttribLocation(program1Attrib, 'size'); gl.disableVertexAttribArray(sizeLoc); gl.vertexAttrib1fv(sizeLoc,[20.]); const size2Loc = gl.getAttribLocation(program1Attrib, 'size2'); gl.disableVertexAttribArray(size2Loc); gl.vertexAttrib1fv(size2Loc,[2.]);

const size3Loc = gl.getAttribLocation(program1Attrib, 'size3'); gl.disableVertexAttribArray(size3Loc); gl.vertexAttrib1fv(size3Loc,[1.]);` the window whose name is << vertex array[defaut] >> in webgl_state_diagram is

attributes

enabled | value | size | ... | buffer

false | 0.5 , 0.5 ,0 , 1 | 4 | ... | null false | 20 , 0 ,0 , 1 | 4 | ... | null false | 2 , 0 ,0 ,1 | 4 | ... | null false | 0,0,0,1 | 4 | ... | null

the window whose name is program[program4constantAttributes] attribute info

name | type | size | location|

position| FLOAT_VEC4 | 4 | 0 | size | FLOAT | 4 | 1 | size2 |FLOAT | 4 | 2 | size3 | FLOAT | 4 | 3 |

the code is : const vsUses1Attribute = ` attribute vec4 position; attribute float size; attribute float size2; attribute float size3; varying vec4 v_color;

void main() { gl_Position = position; gl_PointSize = sizesize2size3; v_color = vec4(0,1,1,1); } ; const fs = precision mediump float; varying vec4 v_color;

void main() { gl_FragColor = v_color; } `;

so the last attribute (attribute float size3;) does not appear in the window << vertex array[defaut] >>

and i thought it was a bug

letochagone avatar Jan 28 '21 02:01 letochagone

vertexAttrib4fv (and all the other vertexAttrib??? are not implemented

The reason it sometime works is the code queries all the attribute data so if you do this

gl.vertexAttrib4f(loc, 1, 2 3, 4);   // <!--- State Diagram does **NOT** implement
gl.vertexAttribPointer(loc, ...);    // State Diagram does implement this which then *queries* all the values 

See here

It's not a bug, the code only implements what's needed for the examples.

If you want to fix it you can add code for all the vertexAttrib functions (vertexAttrib1f, vertexAttrib1fv, vertexAttrib2f, etc ....) similar to this

greggman avatar Jan 28 '21 03:01 greggman