Fix drawing instance with empty buffers (https://github.com/enso-org/ide/pull/292)

This code was developed as a fix for occuring "crashes" on Windows, 
which were in fact a "contextLost" events of WebGl.


Original commit: 92b95df814
This commit is contained in:
Adam Obuchowicz 2020-03-25 15:29:36 +01:00 committed by GitHub
parent 1b573988a7
commit 4af19c5745
2 changed files with 6 additions and 3 deletions

View File

@ -270,12 +270,14 @@ impl {
let first = 0;
let count = self.surface.point_scope().size() as i32;
let instance_count = self.surface.instance_scope().size() as i32;
let instance_count = std::cmp::max(instance_count,1);
self.stats.inc_draw_call_count();
if instance_count > 0 {
self.context.draw_arrays_instanced(mode,first,count,instance_count);
} else {
self.context.draw_arrays(mode,first,count);
}
});
})
}
}}

View File

@ -90,6 +90,7 @@ impl<T:Storable> {
stats.inc_buffer_count();
let mut_dirty = MutDirty::new(logger.sub("mut_dirty"),Callback(on_mut));
let resize_dirty = ResizeDirty::new(logger.sub("resize_dirty"),Callback(on_resize));
resize_dirty.set();
let on_resize_fn = on_resize_fn(resize_dirty.clone_ref());
let on_mut_fn = on_mut_fn(mut_dirty.clone_ref());
let buffer = ObservableVec::new(on_mut_fn,on_resize_fn);