Implement simple Vulkan+GLFW window, Update makefile accordingly

This commit is contained in:
2024-10-04 03:36:56 -05:00
parent d58e592f9e
commit 55b146258c
2 changed files with 65 additions and 10 deletions

View File

@@ -1,6 +1,57 @@
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <cstdlib>
#include <iostream>
#include <stdexcept>
// Define a base class structure to handle public and private methods
class TriangleTestApplication {
const uint32_t WIDTH = 800;
const uint32_t HEIGHT = 600;
// Public facing function, Initializes our private functions and GLFW
public:
void run() {
initWindow();
initVulkan();
mainLoop();
cleanup();
}
private:
GLFWwindow *window;
// Initialize GLFW Window. First, Initialize GLFW lib, disable resizing for
// now, and create window.
void initWindow() {
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
// Settings for the window are set, create window reference.
window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr);
}
void initVulkan() {}
void mainLoop() {
// Update window whilst open
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
}
}
void cleanup() {
// Cleanup window when destroyed.
glfwDestroyWindow(window);
glfwTerminate();
}
};
int main() {
std::printf("Hello, World!\n");
return 0;
TriangleTestApplication app;
try {
app.run();
} catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}