Initial commit for vulkan tutorial
Following along the first 9 chapters of the Vulkan HelloTriangle tutorial.
This commit is contained in:
57
00_base_code.cpp
Normal file
57
00_base_code.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#if defined(__INTELLISENSE__) || !defined(USE_CPP20_MODULES)
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
#else
|
||||
import vulkan_hpp;
|
||||
#endif
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib>
|
||||
|
||||
constexpr uint32_t WIDTH = 800;
|
||||
constexpr uint32_t HEIGHT = 600;
|
||||
|
||||
class HelloTriangleApplication {
|
||||
public:
|
||||
void run() {
|
||||
initWindow();
|
||||
initVulkan();
|
||||
mainLoop();
|
||||
cleanup();
|
||||
}
|
||||
private:
|
||||
void initWindow() {
|
||||
glfwInit();
|
||||
// Don't create an OpenGL context
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||
window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr);
|
||||
}
|
||||
void initVulkan() {}
|
||||
void mainLoop() {
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
glfwPollEvents();
|
||||
}
|
||||
}
|
||||
void cleanup() {
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
GLFWwindow *window;
|
||||
};
|
||||
|
||||
int main() {
|
||||
HelloTriangleApplication app;
|
||||
|
||||
try {
|
||||
app.run();
|
||||
} catch (const std::exception &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user