#pragma once #include #include #include #include #include #if !defined(__APPLE__) #include #endif #include #include #include #include bool endsWith(const char* s, const char* part); std::string readShaderFile(const char* fileName); VkShaderStageFlagBits vkShaderStageFromFileName(const char* fileName); lvk::Holder loadShaderModule(const std::unique_ptr& ctx, const char* fileName); lvk::Holder loadTexture( const std::unique_ptr& ctx, const char* fileName, lvk::TextureType textureType = lvk::TextureType_2D, bool sRGB = false); template inline void mergeVectors(std::vector& v1, const std::vector& v2) { v1.insert(v1.end(), v2.begin(), v2.end()); } // From https://stackoverflow.com/a/64152990/1182653 // Delete a list of items from std::vector with indices in 'selection' // e.g., eraseSelected({1, 2, 3, 4, 5}, {1, 3}) -> {1, 3, 5} // ^ ^ 2 and 4 get deleted template inline void eraseSelected(std::vector& v, const std::vector& selection) { // cut off the elements moved to the end of the vector by std::stable_partition v.resize(std::distance( v.begin(), // std::stable_partition moves any element whose index is in 'selection' to the end std::stable_partition(v.begin(), v.end(), [&selection, &v](const T& item) { return !std::binary_search( selection.begin(), selection.end(), // std::distance(std::find(v.begin(), v.end(), item), v.begin()) - if you don't like the pointer arithmetic below static_cast(static_cast(&item) - &v[0])); }))); } void saveStringList(FILE* f, const std::vector& lines); void loadStringList(FILE* f, std::vector& lines); int addUnique(std::vector& files, const std::string& file); std::string replaceAll(const std::string& str, const std::string& oldSubStr, const std::string& newSubStr); std::string lowercaseString(const std::string& s); // convert 8-bit ASCII string to upper case