Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webgl-state-diagram #331

Open
letochagone opened this issue Jan 27, 2021 · 3 comments
Open

webgl-state-diagram #331

letochagone opened this issue Jan 27, 2021 · 3 comments

Comments

@letochagone
Copy link

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

@greggman
Copy link
Member

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.

@letochagone
Copy link
Author

letochagone commented Jan 28, 2021

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

@greggman
Copy link
Member

greggman commented Jan 28, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants