Ejemplo n.º 1
0
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) );
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
Flood::ResourceHandle<T> Flood::ResourceHandle<T>::Create(T resource)
{
    auto handle = ResourceHandleCreate(resource->NativePtr);
    return Flood::ResourceHandle<T>(handle.getId());
}