Spit out error messages in readFile

This commit is contained in:
Darren VanBuren 2019-02-11 14:07:16 -08:00
parent 868c4a0975
commit 88035e14e5
2 changed files with 6 additions and 3 deletions

View file

@ -18,5 +18,5 @@
"cppStandard": "c++17"
}
],
"version": 3
"version": 4
}

View file

@ -68,7 +68,7 @@ private:
VkDevice device;
VkSurfaceKHR surface;
VkQueue presentQueue;
VkSwapchainKHR swapChain;
VkSwapchainKHR swapChain = VK_NULL_HANDLE;
std::vector<VkImage> swapChainImages;
VkFormat swapChainImageFormat;
VkExtent2D swapChainExtent;
@ -592,7 +592,9 @@ private:
}
void createGraphicsPipeline() {
std::cerr << "Loading vertex shader." << std::endl;
auto vertShaderCode = readFile("shaders/vert.spv");
std::cerr << "Loading fragment shader." << std::endl;
auto fragShaderCode = readFile("shaders/frag.spv");
VkShaderModule vertShaderModule;
@ -736,9 +738,10 @@ private:
static std::vector<char> readFile(const std::string& filename) {
// Start reading at end of the file, as binary.
std::ifstream file(filename, std::ios::ate | std::ios::binary);
std::ifstream file(filename, std::ios::ate | std::ios::binary);
if(!file.is_open()) {
std::cerr << "Error code: " << strerror(errno) << std::endl;
throw std::runtime_error("failed to open file!");
}