void _gfx_render_objects_clear( GFX_RenderObjects* cont) { gfx_vector_clear(&cont->objects); gfx_deque_clear(&cont->empties); gfx_vector_clear(&cont->saved); }
void _gfx_lod_map_clear( GFX_LodMap* map) { map->map.levels = 0; gfx_vector_clear(&map->data); gfx_vector_clear(&map->levels); }
void gfx_mesh_free( GFXMesh* mesh) { if(mesh) { GFX_Mesh* internal = (GFX_Mesh*)mesh; /* Remove all buckets */ size_t size = _gfx_mesh_bucket_size(mesh, UINT_MAX); size_t total = gfx_vector_get_size(&internal->buckets); while(total) { total -= size; _gfx_mesh_erase_bucket( internal, gfx_vector_at(&internal->buckets, total), size ); } /* Free all layouts */ GFXVectorIterator it; for( it = internal->layouts.begin; it != internal->layouts.end; it = gfx_vector_next(&internal->layouts, it)) { gfx_vertex_layout_free(*(GFXVertexLayout**)it); } /* Clear all shared buffers */ for( it = internal->buffers.begin; it != internal->buffers.end; it = gfx_vector_next(&internal->buffers, it)) { gfx_shared_buffer_clear((GFXSharedBuffer*)it, 1); } /* Free everything */ gfx_vector_clear(&internal->layouts); gfx_vector_clear(&internal->buckets); gfx_vector_clear(&internal->buffers); _gfx_lod_map_clear((GFX_LodMap*)internal); free(mesh); } }
void _gfx_platform_terminate(void) { /* Free all mode references */ GFX_X11_Monitor* mon; for( mon = _gfx_x11.monitors.begin; mon != _gfx_x11.monitors.end; mon = gfx_vector_next(&_gfx_x11.monitors, mon)) { free(mon->modes); } /* Close connection (destroys all resources) */ if(_gfx_x11.display) XCloseDisplay(_gfx_x11.display); gfx_vector_clear(&_gfx_x11.monitors); gfx_vector_clear(&_gfx_x11.modes); gfx_vector_clear(&_gfx_x11.windows); }
void gfx_thread_pool_free( GFXThreadPool* pool) { if(pool) { GFX_Pool* internal = (GFX_Pool*)pool; /* Tell threads to terminate */ _gfx_platform_mutex_lock(&internal->mutex); internal->status = GFX_INT_POOL_TERMINATE; _gfx_platform_cond_broadcast(&internal->assign); _gfx_platform_mutex_unlock(&internal->mutex); /* Join all dead threads */ GFX_ThreadList* node = internal->threads; for( node = internal->deads; node; node = (GFX_ThreadList*)node->node.next) { _gfx_thread_list_join(node); } /* And join all alive threads */ for( node = internal->threads; node; node = (GFX_ThreadList*)node->node.next) { _gfx_thread_list_join(node); } /* Clear all the things */ gfx_vector_clear(&internal->tasks); gfx_list_free((GFXList*)internal->threads); gfx_list_free((GFXList*)internal->deads); _gfx_platform_mutex_clear(&internal->mutex); _gfx_platform_cond_clear(&internal->assign); _gfx_platform_cond_clear(&internal->flush); free(pool); } }