Skip to content

Commit

Permalink
Use createShader and remove use of {} for indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JetStarBlues committed Jun 8, 2021
1 parent 0d9fe8f commit 1e1e62e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 118 deletions.
41 changes: 0 additions & 41 deletions docs/yuidoc-p5-theme/assets/shader-basicGradient.frag

This file was deleted.

67 changes: 0 additions & 67 deletions docs/yuidoc-p5-theme/assets/shader-mvp.vert

This file was deleted.

55 changes: 45 additions & 10 deletions src/webgl/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,24 280,62 @@ p5.prototype.shader = function(s) {
* // This variable will hold our shader object
* let shaderProgram;
*
* function preload() {
* shaderProgram = loadShader(
* 'assets/shader-mvp.vert',
* 'assets/shader-basicGradient.frag'
* );
* }
* // This variable will hold our vertex shader source code
* let vertSrc = `
*
* attribute vec3 aPosition;
* attribute vec2 aTexCoord;
*
* uniform mat4 uProjectionMatrix;
* uniform mat4 uModelViewMatrix;
*
* varying vec2 vTexCoord;
*
* void main() {
*
* vTexCoord = aTexCoord;
*
* vec4 position = vec4(aPosition, 1.0);
*
* gl_Position = uProjectionMatrix * uModelViewMatrix * position;
* }
* `;
*
* // This variable will hold our fragment shader source code
* let fragSrc = `
*
* precision mediump float;
*
* varying vec2 vTexCoord;
*
* void main() {
*
* vec2 uv = vTexCoord;
*
* vec3 color = vec3(
* uv.x,
* uv.y,
* min(uv.x uv.y, 1.0)
* );
*
* gl_FragColor = vec4(color, 1.0);
* }
* `;
*
* function setup() {
* // Shaders require WEBGL mode to work
* createCanvas(100, 100, WEBGL);
*
* // Create our shader
* shaderProgram = createShader(vertSrc, fragSrc);
* }
*
* // prettier-ignore
* function draw() {
* // Clear the scene
* background(200);
*
* // Draw a box using our shader
* {
* // shader() sets the active shader with our shader
* shader(shaderProgram);
* push();
Expand All @@ -306,10 344,8 @@ p5.prototype.shader = function(s) {
* rotateY(millis() * 0.0005);
* box(width / 4);
* pop();
* }
*
* // Draw a box using the default fill shader
* {
* // resetShader() restores the default fill shader
* resetShader();
* fill(255, 0, 0);
Expand All @@ -319,7 355,6 @@ p5.prototype.shader = function(s) {
* rotateY(millis() * 0.0005);
* box(width / 4);
* pop();
* }
* }
* </code>
* </div>
Expand Down

0 comments on commit 1e1e62e

Please sign in to comment.