WebGL Textures & Vertices

Beginner's Guide

Page Forty One

WebGL API shaderSource(WebGLShader, String)

Call the WebGL API method shaderSource(WebGLShader,String) to assign a String of shader source code to an empty WebGLShader. The first parameter to shaderSource(WebGLShader, String) is our empty WebGLShader object named shader. The second parameter to shaderSource(WebGLShader, String) is our String of shader source code named sCode. The following listing demonstrates assigning shader source code to a WebGLShader.

gl.shaderSource
(
 shader,
 sCode
);

Listing 38: WebGL API shaderSource(WebGLShader,String)

WebGL API compileShader(WebGLShader)

Method getShader() compiles the shader with the WebGL API method compileShader(WebGLShader). The only parameter is our WebGLShader reference.

gl.compileShader
(
 shader
);

Listing 39: WebGL API compileShader(WebGLShader)

WebGL Beginner's Guide Introduction WebGL Beginner's Guide
Copyright © 2015 Seven Thunder Software. All Rights Reserved.