ImageHandle ImageCreate(Allocator* alloc, uint32 width, uint32 height, PixelFormat format) { Image* image = Allocate(alloc, Image); image->create(width, height, format); return HandleCast<Image>( ResourceHandleCreate(image) ); }
ResourceHandle ResourceManager::loadResource(ResourceLoadOptions& options) { if( !archive ) return ResourceHandle(HandleInvalid); Path fileExt = PathGetFileExtension(options.name); // If the file has no extension, search for one with the same // name but with known resource loadable file extensions. if(fileExt.empty() && !findResource(options)) { LogError("Could not find matching file for '%s'", options.name.c_str()); return ResourceHandle(HandleInvalid); } // Check if the resource is already loaded. ResourceHandle handle = getResource(options.name); if( handle ) return handle; if( !validateResource(options.name) ) return ResourceHandle(HandleInvalid); Resource* resource = prepareResource(options); if( !resource ) return ResourceHandle(HandleInvalid); handle = ResourceHandleCreate(resource); if(handle == HandleInvalid) return ResourceHandle(HandleInvalid); // Register the decoded resource in the map. Path base = PathGetFile(options.name); auto key = MurmurHash64(base.c_str(), base.size(), 0); resources.set(key, handle); decodeResource(options); return handle; }
Flood::ResourceHandle<T> Flood::ResourceHandle<T>::Create(T resource) { auto handle = ResourceHandleCreate(resource->NativePtr); return Flood::ResourceHandle<T>(handle.getId()); }