
3. WebGL for OpenGL Developers 37
< script id= "fs" type= "x- shader /x- fragment ">
void main (void )
{
gl_FragColor = vec4 (1.0);
}
</script >
Listing 3.3. Storing a fragment shader in an HTML script tag.
a shader this way as compared to using JavaScript strings, it is not as productive
as having separate files for each shader.
• Store each shader in a separate file, creating the b est scenario for shader author-
ing. Shaders can be transferred to the client individually on an as-needed basis
using XMLHttpRequest [Salga 11]. This has the downside of requiring an
HTTP request per shader; however, this is unlikely to be significant compared
to other HTTP requests ...