Created
May 5, 2014 02:06
-
-
Save TheSeamau5/6ec6e24b63bb49a98f99 to your computer and use it in GitHub Desktop.
Hello Triangle in WebGL in Elm
This file contains hidden or 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
import MJS (..) | |
import Graphics.WebGL (..) | |
main = webgl (400, 400) scene | |
type Point = {point : V3} | |
toPoint vector = { point = vector } | |
triangle : V3 -> V3 -> V3 -> Triangle Point | |
triangle p1 p2 p3 = (toPoint p1, toPoint p2, toPoint p3) | |
basicTriangle : Triangle Point | |
basicTriangle = triangle (v3 0 0 0) (v3 0 1 0) (v3 1 0 0) | |
scene : [Model] | |
scene = [model vertexShader fragmentShader [basicTriangle] {}] | |
vertexShader = [glShader| | |
attribute vec3 point; | |
void main (){ | |
gl_Position = vec4(point, 1.0); | |
} | |
|] | |
fragmentShader = [glShader| | |
void main (){ | |
gl_FragColor = vec4(0.0,0.0,1.0,1.0); | |
} | |
|] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment