직렬화 함수 작성 끝

This commit is contained in:
2025-06-09 03:47:48 +09:00
parent 5ba62b5312
commit 50c9bd68fc
47 changed files with 324 additions and 201 deletions

View File

@@ -0,0 +1,26 @@
#include "vulkan_engine/utilities.h"
#include <fstream>
namespace veng {
bool streq(gsl::czstring left, gsl::czstring right) {
return std::strcmp(left, right) == 0;
}
std::vector<std::uint8_t> ReadFile(std::filesystem::path shader_path) {
if (!std::filesystem::exists(shader_path)) return {};
if (!std::filesystem::is_regular_file(shader_path)) return {};
std::ifstream file(shader_path, std::ios::binary);
if (!file.is_open()) return {};
std::uintmax_t file_size = std::filesystem::file_size(shader_path);
if (file_size > std::numeric_limits<std::uint32_t>::max()) return {}; // 방어
std::uint32_t size = static_cast<std::uint32_t>(file_size);
std::vector<std::uint8_t> buffer(size);
file.read(reinterpret_cast<char*>(buffer.data()), size);
return buffer;
}
} // namespace veng