@@ -90,12 +90,16 @@ class PenSkin extends Skin {
90
90
this . a_position_glbuffer = gl . createBuffer ( ) ;
91
91
this . a_position_loc = gl . getAttribLocation ( this . _lineShader . program , 'a_position' ) ;
92
92
93
- this . attribute_glbuffer = gl . createBuffer ( ) ;
94
- this . attribute_index = 0 ;
95
93
this . a_lineColor_loc = gl . getAttribLocation ( this . _lineShader . program , 'a_lineColor' ) ;
96
94
this . a_lineThicknessAndLength_loc = gl . getAttribLocation ( this . _lineShader . program , 'a_lineThicknessAndLength' ) ;
97
95
this . a_penPoints_loc = gl . getAttribLocation ( this . _lineShader . program , 'a_penPoints' ) ;
98
96
97
+ this . attribute_glbuffer = gl . createBuffer ( ) ;
98
+ this . attribute_index = 0 ;
99
+ this . attribute_data = new Float32Array ( PEN_ATTRIBUTE_BUFFER_SIZE ) ;
100
+ gl . bindBuffer ( gl . ARRAY_BUFFER , this . attribute_glbuffer ) ;
101
+ gl . bufferData ( gl . ARRAY_BUFFER , this . attribute_data . length * 4 , gl . STREAM_DRAW ) ;
102
+
99
103
if ( gl . drawArraysInstanced ) {
100
104
// WebGL2 has native instanced rendering
101
105
this . instancedRendering = true ;
@@ -107,7 +111,7 @@ class PenSkin extends Skin {
107
111
const instancedArraysExtension = gl . getExtension ( 'ANGLE_instanced_arrays' ) ;
108
112
if ( instancedArraysExtension ) {
109
113
this . instancedRendering = true ;
110
- this . glDrawArraysInstanced = instancedArraysExtension . drawElementsInstancedANGLE . bind (
114
+ this . glDrawArraysInstanced = instancedArraysExtension . drawArraysInstancedANGLE . bind (
111
115
instancedArraysExtension
112
116
) ;
113
117
this . glVertexAttribDivisor = instancedArraysExtension . vertexAttribDivisorANGLE . bind (
@@ -125,14 +129,8 @@ class PenSkin extends Skin {
125
129
1 , 0 ,
126
130
0 , 0 ,
127
131
1 , 1 ,
128
- 1 , 1 ,
129
- 0 , 0 ,
130
132
0 , 1
131
133
] ) , gl . STATIC_DRAW ) ;
132
-
133
- this . attribute_data = new Float32Array ( PEN_ATTRIBUTE_BUFFER_SIZE ) ;
134
- gl . bindBuffer ( gl . ARRAY_BUFFER , this . attribute_glbuffer ) ;
135
- gl . bufferData ( gl . ARRAY_BUFFER , this . attribute_data . length * 4 , gl . STREAM_DRAW ) ;
136
134
} else {
137
135
const positionBuffer = new Float32Array ( PEN_ATTRIBUTE_BUFFER_SIZE / PEN_ATTRIBUTE_STRIDE * 2 ) ;
138
136
for ( let i = 0 ; i < positionBuffer . length ; i += 12 ) {
@@ -151,10 +149,6 @@ class PenSkin extends Skin {
151
149
}
152
150
gl . bindBuffer ( gl . ARRAY_BUFFER , this . a_position_glbuffer ) ;
153
151
gl . bufferData ( gl . ARRAY_BUFFER , positionBuffer , gl . STATIC_DRAW ) ;
154
-
155
- this . attribute_data = new Float32Array ( PEN_ATTRIBUTE_BUFFER_SIZE ) ;
156
- gl . bindBuffer ( gl . ARRAY_BUFFER , this . attribute_glbuffer ) ;
157
- gl . bufferData ( gl . ARRAY_BUFFER , this . attribute_data . length * 4 , gl . STREAM_DRAW ) ;
158
152
}
159
153
160
154
this . onNativeSizeChanged = this . onNativeSizeChanged . bind ( this ) ;
@@ -444,8 +438,8 @@ class PenSkin extends Skin {
444
438
this . glVertexAttribDivisor ( this . a_penPoints_loc , 1 ) ;
445
439
446
440
this . glDrawArraysInstanced (
447
- gl . TRIANGLES ,
448
- 0 , 6 ,
441
+ gl . TRIANGLE_STRIP ,
442
+ 0 , 4 ,
449
443
this . attribute_index / PEN_ATTRIBUTE_STRIDE
450
444
) ;
451
445
0 commit comments