2
0

WebGLShader.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <p class="desc">A lower level function to compile either a vertex or fragment shader.</p>
  12. <h2>Code Example</h2>
  13. <code>
  14. const gl = renderer.getContext();
  15. const glVertexShader = new THREE.WebGLShader( gl, gl.VERTEX_SHADER, vertexSourceCode );
  16. const glFragmentShader = new THREE.WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentSourceCode );
  17. const program = gl.createProgram();
  18. gl.attachShader( program, glVertexShader );
  19. gl.attachShader( program, glFragmentShader );
  20. gl.linkProgram( program );
  21. </code>
  22. <h2>Function</h2>
  23. <h3>[page:WebGLShader objects]([page:WebGLContext gl], [page:WebGLEnum type], [page:String source])</h3>
  24. <p>
  25. gl -- The current WebGL context
  26. type -- The WebGL type, either gl.VERTEX_SHADER or gl.FRAGMENT_SHADER
  27. source -- The source code for the shader
  28. </p>
  29. <p>
  30. This will compile an individual shader, but won't link it to be a complete [page:WebGLProgram]. Note: this
  31. is a function so the new operator should not be used.
  32. </p>
  33. <h2>Source</h2>
  34. <p>
  35. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  36. </p>
  37. </body>
  38. </html>