Skip to content

Commit

Permalink
Tested on iOS safari
Browse files Browse the repository at this point in the history
  • Loading branch information
huww98 committed Aug 4, 2020
1 parent 30028a1 commit 24f9a99
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
6 changes: 6 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!--
<script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.3.4/vconsole.min.js"></script>
<script>
var vConsole = new VConsole();
</script>
-->
<title>TimeChart Demo</title>
<style>
#chart {
Expand Down
41 changes: 21 additions & 20 deletions src/lineChartRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,38 @@ void main() {
gl_Position = vec4(pos2d, 0, 1);
}`;

if (gl instanceof WebGL2RenderingContext) {
return `#version 300 es
layout (location = ${VertexAttribLocations.DATA_POINT}) in vec2 aDataPoint;
layout (location = ${VertexAttribLocations.DIR}) in vec2 aDir;
${body}`;
} else {
if (gl instanceof WebGLRenderingContext) {
return `
attribute vec2 aDataPoint;
attribute vec2 aDir;
${body}`;
} else {
return `#version 300 es
layout (location = ${VertexAttribLocations.DATA_POINT}) in vec2 aDataPoint;
layout (location = ${VertexAttribLocations.DIR}) in vec2 aDir;
${body}`;
}
}

function fsSource(gl: WebGL2RenderingContext | WebGLRenderingContext) {
const body = `
`;
if (gl instanceof WebGL2RenderingContext) {
return `#version 300 es
if (gl instanceof WebGLRenderingContext) {
return `
precision lowp float;
uniform vec4 uColor;
out vec4 outColor;
void main() {
outColor = uColor;
gl_FragColor = uColor;
}`;
} else {
return `
return `#version 300 es
precision lowp float;
uniform vec4 uColor;
out vec4 outColor;
void main() {
gl_FragColor = uColor;
outColor = uColor;
}`;

}
}

Expand Down Expand Up @@ -162,15 +163,15 @@ class SeriesSegmentVertexArray {
gl.enableVertexAttribArray(VertexAttribLocations.DIR);
gl.vertexAttribPointer(VertexAttribLocations.DIR, 2, gl.FLOAT, false, BYTES_PER_POINT, 2 * Float32Array.BYTES_PER_ELEMENT);
}
if (gl instanceof WebGL2RenderingContext) {
this.vao = new WebGL2VAO(gl);
} else {
// const vaoExt = gl.getExtension('OES_vertex_array_object');
// if (vaoExt) {
// this.vao = new OESVAO(vaoExt);
// } else {
if (gl instanceof WebGLRenderingContext) {
const vaoExt = gl.getExtension('OES_vertex_array_object');
if (vaoExt) {
this.vao = new OESVAO(vaoExt);
} else {
this.vao = new WebGL1BufferInfo(bindFunc);
// }
}
} else {
this.vao = new WebGL2VAO(gl);
}
bindFunc();

Expand Down

0 comments on commit 24f9a99

Please sign in to comment.