Demos update

-added functionality to detect host CPU threads count
-fixed some memory leaks
-now textures free memory corectly
-added support for up to 32 threads
This commit is contained in:
Mergul 2020-05-13 15:34:24 +02:00
parent dd491302af
commit 3647fa4b86
6 changed files with 98 additions and 16 deletions

View file

@ -90,6 +90,16 @@ struct Snake
MapElement[map_size * map_size] map;
~this() @nogc nothrow
{
if(snake_destroy_particle_frames)Mallocator.dispose(snake_destroy_particle_frames);
if(smoke_frames)Mallocator.dispose(smoke_frames);
if(apple_tmpl)launcher.manager.freeTemplate(apple_tmpl);
if(snake_tmpl)launcher.manager.freeTemplate(snake_tmpl);
if(snake_destroy_particle)launcher.manager.freeTemplate(snake_destroy_particle);
texture.destory();
}
MapElement element(ivec2 pos)
{
uint index = pos.x + pos.y * map_size;
@ -805,9 +815,9 @@ void snakeStart()
snake.addApple();
}
launcher.gui_manager.addTemplate(snake.snake_tmpl, "Snake");
launcher.gui_manager.addTemplate(snake.apple_tmpl, "Apple");
launcher.gui_manager.addTemplate(snake.snake_destroy_particle, "Particle");
launcher.gui_manager.addTemplate(launcher.manager.allocateTemplate(snake.snake_tmpl), "Snake");
launcher.gui_manager.addTemplate(launcher.manager.allocateTemplate(snake.apple_tmpl), "Apple");
launcher.gui_manager.addTemplate(launcher.manager.allocateTemplate(snake.snake_destroy_particle), "Particle");
MoveSystem* move_system = launcher.manager.getSystem!MoveSystem();
move_system.setTemplates();