파일 분리, 셰이더 로드까지 수강.
This commit is contained in:
@@ -1,9 +1,28 @@
|
||||
#include "utilities.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user