Expand Minimize

getShaderSource method

Returns source code string associated with a shader object.

IE11

 

Syntax

var retVal = WebGLRenderingContext.getShaderSource(shader);

Parameters

shader [in]

Type: WebGLShader

The shader object to query.

Return value

Type: String

The shader source code string. Returns null if an error occurred.

Remarks

WebGL ErrorDescription
gl.INVALID_VALUEIf shader is not valid.
gl.INVALID_OPERATIONIf shader is not a shader object.

 

Examples

This example retrieves the shader source code and displays it in <div> elements on the HTML page. For more info on this example, see Get started with WebGL.


var vertexshader = getShader(gl, "2d-vertex-shader");
var fragmentshader = getShader(gl, "2d-fragment-shader");
        
this.pictureprogram = loadProgram(gl, vertexshader, fragmentshader);
gl.useProgram(this.pictureprogram);

// Put the shader source into the <divs>. 
document.getElementById("vertexshadersource").innerText = gl.getShaderSource(vertexshader);
document.getElementById("fragmentshadersource").innerText = gl.getShaderSource(fragmentshader);



See also

WebGLRenderingContext

 

 

Show:
© 2014 Microsoft