Going further into the vulkan tutorial. :( Wish I didn't need it
This commit is contained in:
parent
191aa7350d
commit
3a4030ad89
7 changed files with 65 additions and 18 deletions
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/bash
|
||||
glslc shaders/shader.vert -o shaders/shader.vert.spv
|
||||
glslc shaders/shader.frag -o shaders/shader.vert.spv
|
||||
glslc shaders/shader.frag -o shaders/shader.frag.spv
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -4,7 +4,7 @@
|
|||
namespace yave {
|
||||
|
||||
void Application::run() {
|
||||
yaveVulkanInstance VI = yaveVulkanInstance();
|
||||
YaveVulkanInstance VI = YaveVulkanInstance();
|
||||
|
||||
while (!yaveWindow.shouldClose()) {
|
||||
glfwPollEvents();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "yave_window.hpp"
|
||||
#include "yave_graphics_pipeline.hpp"
|
||||
|
||||
namespace yave {
|
||||
class Application {
|
||||
|
|
@ -12,6 +13,7 @@ class Application {
|
|||
|
||||
private:
|
||||
YaveWindow yaveWindow{WIDTH, HEIGHT, "Hello Vulkan!"};
|
||||
YaveGrPipeline yavePipeline{"shaders/shader.vert.spv","shaders/shader.frag.spv"};
|
||||
|
||||
};
|
||||
} // namespace yave
|
||||
|
|
|
|||
34
src/yave_graphics_pipeline.cpp
Normal file
34
src/yave_graphics_pipeline.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include "yave_graphics_pipeline.hpp"
|
||||
#include <cstddef>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
namespace yave {
|
||||
YaveGrPipeline::YaveGrPipeline(const std::string &vertFilepath,
|
||||
const std::string &fragFilepath) {
|
||||
createGraphicsPipeline(vertFilepath, fragFilepath);
|
||||
}
|
||||
|
||||
std::vector<char> YaveGrPipeline::readFile(const std::string &filepath) {
|
||||
std::ifstream file{filepath, std::ios::ate | std::ios::binary};
|
||||
if (!file.is_open()) {
|
||||
throw std::runtime_error("failed to open file: " + filepath);
|
||||
}
|
||||
|
||||
size_t fileSize = static_cast<size_t>(file.tellg());
|
||||
std::vector<char> buffer(fileSize);
|
||||
|
||||
file.seekg(0);
|
||||
file.read(buffer.data(), fileSize);
|
||||
file.close();
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void YaveGrPipeline::createGraphicsPipeline(const std::string &vertFilepath,
|
||||
const std::string &fragFilepath) {
|
||||
auto vertCode = readFile(vertFilepath);
|
||||
auto fragCode = readFile(fragFilepath);
|
||||
}
|
||||
|
||||
} // namespace yave
|
||||
|
|
@ -1,15 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace yave {
|
||||
|
||||
class YaveGrPipeline {
|
||||
public:
|
||||
YaveGrPipeline(const std::string& vertFilepath, const std::string& fragFilepath);
|
||||
YaveGrPipeline(const std::string &vertFilepath,
|
||||
const std::string &fragFilepath);
|
||||
|
||||
private:
|
||||
static std::vector<char> readFile(const std::string &filepath);
|
||||
|
||||
void createGraphicsPipeline(const std::string &vertFilepath,
|
||||
const std::string &fragFilepath);
|
||||
};
|
||||
|
||||
} // namespace yave
|
||||
|
|
|
|||
|
|
@ -18,11 +18,17 @@ class YaveWindow {
|
|||
std::string windowName;
|
||||
|
||||
public:
|
||||
// Delete Copy constructors
|
||||
// This class should match one to one with glfw window instances
|
||||
YaveWindow(const YaveWindow &) = delete;
|
||||
YaveWindow &operator=(const YaveWindow &) = delete;
|
||||
|
||||
// Initialiser and destructor
|
||||
YaveWindow(int w, int h, std::string name);
|
||||
~YaveWindow();
|
||||
|
||||
// Tell apllicaton that the user has attempted to close the window
|
||||
bool shouldClose() { return glfwWindowShouldClose(window); }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace yave
|
||||
|
|
|
|||
Loading…
Reference in a new issue