diff --git a/Makefile b/Makefile index a3dfc8b..b6aacb4 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,36 @@ -CC=gcc -CXX=g++ -CPPFLAGS=-g - +CPPFLAGS=-g +LDFLAGS=-lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi SRC=$(shell find . -name *.cpp) OBJ=$(SRC:%.cpp=%.o) -BIN= build/placeholderengine + +BIN=build/placeholderengine .PHONY: all all: $(BIN) +.PHONY: run +run: $(BIN) + ./$(BIN) .PHONY: dep dep: - sudo pacman -S $(CC) + sudo pacman -S gcc glfw glm shaderc libxi libxxf86vm .PHONY: info info: @echo "make: Build executable" @echo "make dep: Make all required dependencies" @echo "make debug: Make with Debug hooked in" @echo "make clean: Clean all files" + @echo "make run: Run the executable after building" $(BIN): $(OBJ) mkdir -p build - $(CXX) $(CPPFLAGS) -o $(BIN) $(OBJ) + g++ $(CPPFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS) %.o: %.cpp - g++ -c $< -o $@ + g++ -c $< -o $@ $(LDFLAGS) .PHONY: clean clean: rm -rf build + find . -name "*.o" -type f -delete diff --git a/src/main.cpp b/src/main.cpp index da7d7e0..fc311fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,57 @@ +#define GLFW_INCLUDE_VULKAN +#include + +#include #include +#include + +// 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; }