File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ type Textures = [gl::types::GLuint; 2];
126
126
struct Resources {
127
127
ctx : gl:: Gl ,
128
128
vertex_buffer : gl:: types:: GLuint ,
129
+ index_buffer : gl:: types:: GLuint ,
129
130
vert_ranges_len : usize ,
130
131
vert_ranges : Ranges ,
131
132
textures : Textures ,
@@ -227,11 +228,20 @@ impl Resources {
227
228
buffer
228
229
} ;
229
230
231
+ let index_buffer = unsafe {
232
+ let mut buffer = 0 ;
233
+
234
+ ctx. GenBuffers ( 1 , & mut buffer as _ ) ;
235
+
236
+ buffer
237
+ } ;
238
+
230
239
let mut result = Resources {
231
240
ctx,
232
241
vert_ranges : [ ( 0 , 0 ) ; 16 ] ,
233
242
vert_ranges_len : 0 ,
234
243
vertex_buffer,
244
+ index_buffer,
235
245
colour_shader,
236
246
texture_shader,
237
247
textures,
@@ -263,18 +273,17 @@ impl Resources {
263
273
( 0 ..verts. len ( ) ) . map ( |x| x as gl:: types:: GLushort ) . collect ( ) ;
264
274
265
275
unsafe {
266
- let mut buffer = 0 ;
267
-
268
- self . ctx . GenBuffers ( 1 , & mut buffer as _ ) ;
269
- self . ctx . BindBuffer ( gl :: ELEMENT_ARRAY_BUFFER , buffer ) ;
276
+ self . ctx . BindBuffer (
277
+ gl :: ELEMENT_ARRAY_BUFFER ,
278
+ self . index_buffer ,
279
+ ) ;
270
280
self . ctx . BufferData (
271
281
gl:: ELEMENT_ARRAY_BUFFER ,
272
282
( indices. len ( ) * std:: mem:: size_of :: < gl:: types:: GLushort > ( ) ) as _ ,
273
283
std:: mem:: transmute ( indices. as_ptr ( ) ) ,
274
284
gl:: DYNAMIC_DRAW ,
275
285
) ;
276
286
277
- buffer
278
287
} ;
279
288
280
289
self . vert_ranges = vert_ranges;
You can’t perform that action at this time.
0 commit comments