57 lines
1.4 KiB
HTML
57 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<title>WebGL Example</title>
|
|
|
|
<script id="vertex-shader" type="x-shader/x-vertex">#version 300 es
|
|
in vec4 vPosition;
|
|
in vec4 vColor;
|
|
out vec4 vfColor;
|
|
|
|
uniform mat4 viewMatrix;
|
|
|
|
void main()
|
|
{
|
|
float widthFactor = 1.0;
|
|
float heightFactor = 1.0;
|
|
float depthFactor = 1.0;
|
|
float yOffset = -0.2;
|
|
|
|
mat4 transformationMatrix = mat4 (
|
|
1.0*widthFactor, 0.0, 0.0, 0.0,
|
|
0.0, 1.0*heightFactor, 0.0, 0.0+yOffset,
|
|
0.0, 0.0, 1.0*depthFactor, 0.0,
|
|
0.0, 0.0, 0.0, 1.0
|
|
);
|
|
|
|
vfColor = vColor;
|
|
gl_Position = viewMatrix * vPosition * transformationMatrix;
|
|
}
|
|
</script>
|
|
<script id="fragment-shader" type="x-shader/x-fragment">#version 300 es
|
|
precision mediump float;
|
|
|
|
in vec4 vfColor;
|
|
out vec4 fColor;
|
|
|
|
void main()
|
|
{
|
|
fColor = vfColor;
|
|
}
|
|
</script>
|
|
<script type="text/javascript" src="common/initShaders.js"></script>
|
|
<script type="text/javascript" src="common/Object3D.js"></script>
|
|
<script type="text/javascript" src="common/gl-matrix.js"></script>
|
|
</head>
|
|
<body>
|
|
<h1>Lorem Ipsum</h1>
|
|
|
|
<canvas id="gl-canvas" width="512" height="512">
|
|
If you see this, your browser doesn't support WebGL.
|
|
</canvas>
|
|
|
|
<script src="main.js" type="text/javascript"></script>
|
|
</body>
|
|
</html>
|