Function loadFromFile

Synopsis

#include <Source/Falcor/Utils/AsyncTextureLoader.h>

std::future< Texture::SharedPtr > loadFromFile(const std::string &filename, bool generateMipLevels, bool loadAsSrgb, Resource::BindFlags bindFlags=Resource::BindFlags::ShaderResource)

Description

Request loading a texture.

Parameters

[ in ] filename - Filename of the image. Can also include a full path or relative path from a data directory.

[ in ] generateMipLevels - Whether the mip-chain should be generated.

[ in ] loadAsSrgb - Load the texture using sRGB format. Only valid for 3 or 4 component textures.

[ in ] bindFlags - The bind flags to create the texture with.

Returns
A future to a new texture, or nullptr if the texture failed to load.

Source

Lines 50-56 in Source/Falcor/Utils/AsyncTextureLoader.cpp. Line 56 in Source/Falcor/Utils/AsyncTextureLoader.h.

std::future<Texture::SharedPtr> AsyncTextureLoader::loadFromFile(const std::string& filename, bool generateMipLevels, bool loadAsSrgb, Resource::BindFlags bindFlags)
{
    std::lock_guard<std::mutex> lock(mMutex);
    mRequestQueue.push(Request{filename, generateMipLevels, loadAsSrgb, bindFlags});
    mCondition.notify_one();
    return mRequestQueue.back().promise.get_future();
}





Add Discussion as Guest

Log in