Skip to Content
WebGL Programming Guide: Interactive 3D Graphics Programming with WebGL
book

WebGL Programming Guide: Interactive 3D Graphics Programming with WebGL

by Kouichi Matsuda, Rodger Lea
July 2013
Intermediate to advanced
600 pages
15h 15m
English
Addison-Wesley Professional
Content preview from WebGL Programming Guide: Interactive 3D Graphics Programming with WebGL

Appendix F. Load Shader Programs from Files

All the sample programs in this book embed the shader programs in the JavaScript program, which increases the readability of the sample programs but makes it hard to construct and maintain the shader programs.

As an alternative, you can load the shader programs from files by using the same methods described in the section “Load and Display 3D Models” in Chapter 10, “Advanced Techniques.” To see how that’s done, let’s modify ColoredTriangle from Chapter 5, “Using Colors and Texture Images,” to add support for loading shaders from a file. The new program is called LoadShaderFromFiles, which is shown in Listing F.1.

Listing F.1 LoadShaderFromFiles

  1 // LoadShaderFromFiles.js ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Real-Time 3D Graphics with WebGL 2 - Second Edition

Real-Time 3D Graphics with WebGL 2 - Second Edition

Farhad Ghayour, Diego Cantor

Publisher Resources

ISBN: 9780133364903Purchase bookOther