-
Notifications
You must be signed in to change notification settings - Fork 3
/
webgl.html
110 lines (93 loc) · 4.16 KB
/
webgl.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<html>
<head>
<title>ENIGMA HTML5 interface--Hey, the event system works!</title>
<script type="text/javascript" src="Graphics/WebGL/glMatrix.js"></script>
<script type="text/javascript" src="Main/system.js"></script>
<script type="text/javascript" src="Main/events.js"></script>
<script type="text/javascript" src="Main/object.js"></script>
<script type="text/javascript" src="Parser/parse_basics.js"></script>
<script type="text/javascript" src="Parser/parse_system.js"></script>
<script type="text/javascript" src="Parser/parser.js"></script>
<script type="text/javascript" src="Universal/math.js"></script>
<script type="text/javascript" src="Universal/strings.js"></script>
<script type="text/javascript" src="Universal/object_planar.js"></script>
<script type="text/javascript" src="Universal/loading.js"></script>
<script type="text/javascript" src="Universal/rooms.js"></script>
<script type="text/javascript" src="Universal/input.js"></script>
<script type="text/javascript" src="Graphics/WebGL/main.js"></script>
<script type="text/javascript" src="Graphics/WebGL/depth.js"></script>
<script type="text/javascript" src="Graphics/WebGL/drawing.js"></script>
<script type="text/javascript" src="Platform/dialog.js"></script>
<script type="text/javascript" src="ide_edit/objects.js"></script>
</head>
<body onload="enigma.system.init(document.getElementById('enigma_canvas'))">
<script type="text/javascript">
function syntaxcheck() {
enigma.parser.parse_edl(document.getElementById("code").value);
document.getElementById("output").innerHTML = enigma.parser.err + "<br/>" + enigma.parser.code_out;
}
</script>
<div id="output">Press syntax check button.</div>
<textarea id="code" cols="89" rows="7">
sin(1); draw_diamond(0,1,2,3);
</textarea><br/>
<button type="button" onclick="syntaxcheck(); void(0)">Syntax check</button>
<br/><br/>WebGL Canvas:<br/>
<script id="shader-fs" type="x-shader/x-fragment">
/*************************************************************\
Copyright (C) 2011 Josh Ventura
This file is a part of the ENIGMA Development Environment.
ENIGMA is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, version 3 of
the license or any later version.
This application and its source code is distributed AS-IS,
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have recieved a copy of the GNU General Public License
along with this code. If not, see <http://www.gnu.org/licenses/>
\*************************************************************/
#ifdef GL_ES
precision highp float;
#endif
varying vec4 vColor;
void main(void) {
gl_FragColor = vColor;
}
</script>
<script id="shader-vs" type="x-shader/x-vertex">
/*************************************************************\
Copyright (C) 2011 Josh Ventura
This file is a part of the ENIGMA Development Environment.
ENIGMA is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, version 3 of
the license or any later version.
This application and its source code is distributed AS-IS,
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
You should have recieved a copy of the GNU General Public License
along with this code. If not, see <http://www.gnu.org/licenses/>
\*************************************************************/
attribute vec3 vertex;
attribute vec4 color;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
uniform vec4 uColor;
uniform bool useUniformColor;
varying vec4 vColor;
void main(void) {
gl_Position = uPMatrix * uMVMatrix * vec4(vertex, 1.0);
if (useUniformColor)
vColor = uColor;
else
vColor = color;
}
</script>
<center>
<canvas id="enigma_canvas" width="640" height="480"></canvas>
</center>
</body>
</html>