generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…bouncing-balls Feature/#166 indicators remove bouncing balls
- Loading branch information
Showing
10 changed files
with
339 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export const fragmentShader = `#version 300 es | ||
precision mediump float; | ||
in vec4 v_colour; | ||
out vec4 o_colour; | ||
void main() { | ||
o_colour = v_colour; | ||
} | ||
`; | ||
export const vertexShader = `#version 300 es | ||
precision mediump float; | ||
uniform vec4 u_colour; | ||
uniform float u_sample; | ||
uniform int u_channel; | ||
uniform float u_offset; | ||
uniform float u_scale; | ||
in vec2 inputVertex; | ||
out vec4 v_colour; | ||
void main() { | ||
float index = float(u_channel); | ||
float y = (u_sample * u_scale / 5.0) + u_offset; | ||
float x = (inputVertex.x / 5.0); | ||
x = x - 1.0 + index / 5.0; | ||
gl_Position = vec4(x, y, 1, 1); | ||
v_colour = u_colour; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
export function createShaderProgram(gl, vsSource, fsSource) { | ||
const vertexShader = loadShader(gl, gl.VERTEX_SHADER, vsSource); | ||
const fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fsSource); | ||
|
||
// Create the shader program | ||
const shaderProgram = gl.createProgram(); | ||
gl.attachShader(shaderProgram, vertexShader); | ||
gl.attachShader(shaderProgram, fragmentShader); | ||
gl.linkProgram(shaderProgram); | ||
|
||
// If creating the shader program failed, alert | ||
if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { | ||
alert( | ||
`Unable to initialize the shader program: ${gl.getProgramInfoLog( | ||
shaderProgram | ||
)}` | ||
); | ||
return null; | ||
} | ||
return shaderProgram; | ||
} | ||
|
||
function loadShader(gl, type, source) { | ||
const shader = gl.createShader(type); | ||
|
||
gl.shaderSource(shader, source); | ||
gl.compileShader(shader); | ||
|
||
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { | ||
alert( | ||
`An error occurred compiling the shaders: ${gl.getShaderInfoLog(shader)}` | ||
); | ||
gl.deleteShader(shader); | ||
return null; | ||
} | ||
return shader; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.