Jeff Saremi
Jeff Saremi

Reputation: 3014

How to get the Vertex shader from program

Can I use the Webgl api to get the vertex shader (only) from a program (WebGlProgram)? There is a gl.getAttachedShaders() which gives me an array of them. Is there a way to determine which is which?

thanks

Upvotes: 1

Views: 159

Answers (1)

Rabbid76
Rabbid76

Reputation: 210918

See WebGL Specification; 5.13.9 Programs and Shaders

any getShaderParameter(WebGLShader shader, GLenum pname)

Return the value for the passed pname given the passed shader. The type returned is the natural type for the requested pname, as given in the following table:

SHADER_TYPE     unsigned long
DELETE_STATUS   boolean
COMPILE_STATUS  boolean

Use gl.getShaderParameter(shader, gl.SHADER_TYPE), to determine if the shader object shader, which is returned by gl.getAttachedShaders, is a vertex or fragment shader. The possible return values are gl.VERTEX_SHADER and gl.FRAGMENT_SHADER.

Upvotes: 2

Related Questions