@@ -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
throw new Error ( 'bad' ) ;
101
105
// WebGL2 has native instanced rendering
@@ -126,14 +130,8 @@ class PenSkin extends Skin {
126
130
1 , 0 ,
127
131
0 , 0 ,
128
132
1 , 1 ,
129
- 1 , 1 ,
130
- 0 , 0 ,
131
133
0 , 1
132
134
] ) , gl . STATIC_DRAW ) ;
133
-
134
- this . attribute_data = new Float32Array ( PEN_ATTRIBUTE_BUFFER_SIZE ) ;
135
- gl . bindBuffer ( gl . ARRAY_BUFFER , this . attribute_glbuffer ) ;
136
- gl . bufferData ( gl . ARRAY_BUFFER , this . attribute_data . length * 4 , gl . STREAM_DRAW ) ;
137
135
} else {
138
136
const positionBuffer = new Float32Array ( PEN_ATTRIBUTE_BUFFER_SIZE / PEN_ATTRIBUTE_STRIDE * 2 ) ;
139
137
for ( let i = 0 ; i < positionBuffer . length ; i += 12 ) {
@@ -152,10 +150,6 @@ class PenSkin extends Skin {
152
150
}
153
151
gl . bindBuffer ( gl . ARRAY_BUFFER , this . a_position_glbuffer ) ;
154
152
gl . bufferData ( gl . ARRAY_BUFFER , positionBuffer , gl . STATIC_DRAW ) ;
155
-
156
- this . attribute_data = new Float32Array ( PEN_ATTRIBUTE_BUFFER_SIZE ) ;
157
- gl . bindBuffer ( gl . ARRAY_BUFFER , this . attribute_glbuffer ) ;
158
- gl . bufferData ( gl . ARRAY_BUFFER , this . attribute_data . length * 4 , gl . STREAM_DRAW ) ;
159
153
}
160
154
161
155
this . onNativeSizeChanged = this . onNativeSizeChanged . bind ( this ) ;
@@ -445,8 +439,8 @@ class PenSkin extends Skin {
445
439
this . glVertexAttribDivisor ( this . a_penPoints_loc , 1 ) ;
446
440
447
441
this . glDrawArraysInstanced (
448
- gl . TRIANGLES ,
449
- 0 , 6 ,
442
+ gl . TRIANGLE_STRIP ,
443
+ 0 , 4 ,
450
444
this . attribute_index / PEN_ATTRIBUTE_STRIDE
451
445
) ;
452
446
0 commit comments