-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
colintrinity
committed
Dec 20, 2017
1 parent
b93f54c
commit 7e097f6
Showing
5 changed files
with
89 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
export default class Quad { | ||
constructor() { | ||
this.vertexData = new Float32Array([ | ||
-1.0, 1.0, -1.0, | ||
-1.0, -1.0, -1.0, | ||
1.0, -1.0, -1.0, | ||
1.0, -1.0, -1.0, | ||
1.0, 1.0, -1.0, | ||
-1.0, 1.0, -1.0, | ||
|
||
-1.0, -1.0, 1.0, | ||
-1.0, -1.0, -1.0, | ||
-1.0, 1.0, -1.0, | ||
-1.0, 1.0, -1.0, | ||
-1.0, 1.0, 1.0, | ||
-1.0, -1.0, 1.0, | ||
|
||
1.0, -1.0, -1.0, | ||
1.0, -1.0, 1.0, | ||
1.0, 1.0, 1.0, | ||
1.0, 1.0, 1.0, | ||
1.0, 1.0, -1.0, | ||
1.0, -1.0, -1.0, | ||
|
||
-1.0, -1.0, 1.0, | ||
-1.0, 1.0, 1.0, | ||
1.0, 1.0, 1.0, | ||
1.0, 1.0, 1.0, | ||
1.0, -1.0, 1.0, | ||
-1.0, -1.0, 1.0, | ||
|
||
-1.0, 1.0, -1.0, | ||
1.0, 1.0, -1.0, | ||
1.0, 1.0, 1.0, | ||
1.0, 1.0, 1.0, | ||
-1.0, 1.0, 1.0, | ||
-1.0, 1.0, -1.0, | ||
|
||
-1.0, -1.0, -1.0, | ||
-1.0, -1.0, 1.0, | ||
1.0, -1.0, -1.0, | ||
1.0, -1.0, -1.0, | ||
-1.0, -1.0, 1.0, | ||
1.0, -1.0, 1.0 | ||
]); | ||
this.vertexArray = gl.createVertexArray(); | ||
this.vertexBuffer = gl.createBuffer(); | ||
gl.bindVertexArray(this.vertexArray); | ||
|
||
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); | ||
gl.bufferData(gl.ARRAY_BUFFER, this.vertexData, gl.STATIC_DRAW); | ||
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); | ||
gl.enableVertexAttribArray(0); | ||
|
||
gl.bindVertexArray(null); | ||
} | ||
|
||
draw() { | ||
gl.bindVertexArray(this.vertexArray); | ||
gl.drawArrays(gl.TRIANGLES, 0, 36); | ||
gl.bindVertexArray(null); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#version 300 es | ||
precision highp float; | ||
precision highp int; | ||
|
||
|
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 |
---|---|---|
@@ -1,16 +1,15 @@ | ||
#version 300 es | ||
precision highp float; | ||
precision highp int; | ||
|
||
uniform mat4 u_MVP; | ||
uniform mat4 uMVP; | ||
|
||
layout(location = 0) in vec3 position; | ||
|
||
out vec3 texcoord; | ||
|
||
void main() | ||
{ | ||
vec4 pos = u_MVP * vec4(position, 1.0); | ||
vec4 pos = uMVP * vec4(position, 1.0); | ||
gl_Position = pos.xyww; | ||
texcoord = position; | ||
} |
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