lullaby/systems/gltf_asset/gltf_asset.cc
// TinyGLTF follows a successful call to FileExists with a call to
// ReadWholeFile. To avoid forcing clients to provide both functions, we bundle
// the two into this function by using the AssetLoader's LoadFileFn, then cache
// the result and data to be used in ReadWholeFile.
TinyGLTF follows a successful call to FileExists with a call to
ReadWholeFile. To avoid forcing clients to provide both functions, we bundle
the two into this function by using the AssetLoader's LoadFileFn, then cache
the result and data to be used in ReadWholeFile.
TinyGLTF follows a successful call to FileExists with a call to ReadWholeFile . To avoid forcing clients to provide both functions we bundle the two into this function by using the AssetLoader ' s LoadFileFn then cache the result and data to be used in ReadWholeFile .
bool FileExists(const std::string& filepath, void* user_data) {
  LoadFileContext* context = reinterpret_cast<LoadFileContext*>(user_data);
  auto* asset_loader = context->registry->Get<AssetLoader>();
  if (asset_loader) {
    auto load_file_fn = asset_loader->GetLoadFunction();
    std::string data;
    const bool res = load_file_fn(filepath.c_str(), &data);
    if (res) {
      const size_t num_bytes = data.length();
      context->data.resize(num_bytes);
      memcpy(context->data.data(), data.data(), num_bytes);
      context->success = true;
      return true;
    }
  }
  LOG(DFATAL) << "No AssetLoader present.";
  return false;
}
bool FileExists ( const std :: string & filepath , void * user_data ) { LoadFileContext * context = reinterpret_cast < LoadFileContext * > ( user_data ) ; auto * asset_loader = context -> registry -> Get < AssetLoader > ( ) ; if ( asset_loader ) { auto load_file_fn = asset_loader -> GetLoadFunction ( ) ; std :: string data ; const bool res = load_file_fn ( filepath . c_str ( ) , & data ) ; if ( res ) { const size_t num_bytes = data . length ( ) ; context -> data . resize ( num_bytes ) ; memcpy ( context -> data . data ( ) , data . data ( ) , num_bytes ) ; context -> success = true ; return true ; } } LOG ( DFATAL ) << " " ; return false ; }
TinyGLTF follows a successful call to FileExists with a call to
ReadWholeFile.
TinyGLTF follows a successful call to FileExists with a call to ReadWholeFile .