Implement simple Vulkan+GLFW window, Update makefile accordingly
This commit is contained in:
parent
d58e592f9e
commit
55b146258c
20
Makefile
20
Makefile
@ -1,32 +1,36 @@
|
|||||||
CC=gcc
|
CPPFLAGS=-g
|
||||||
CXX=g++
|
LDFLAGS=-lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
|
||||||
CPPFLAGS=-g
|
|
||||||
|
|
||||||
SRC=$(shell find . -name *.cpp)
|
SRC=$(shell find . -name *.cpp)
|
||||||
OBJ=$(SRC:%.cpp=%.o)
|
OBJ=$(SRC:%.cpp=%.o)
|
||||||
BIN= build/placeholderengine
|
|
||||||
|
BIN=build/placeholderengine
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(BIN)
|
all: $(BIN)
|
||||||
|
|
||||||
|
.PHONY: run
|
||||||
|
run: $(BIN)
|
||||||
|
./$(BIN)
|
||||||
.PHONY: dep
|
.PHONY: dep
|
||||||
dep:
|
dep:
|
||||||
sudo pacman -S $(CC)
|
sudo pacman -S gcc glfw glm shaderc libxi libxxf86vm
|
||||||
.PHONY: info
|
.PHONY: info
|
||||||
info:
|
info:
|
||||||
@echo "make: Build executable"
|
@echo "make: Build executable"
|
||||||
@echo "make dep: Make all required dependencies"
|
@echo "make dep: Make all required dependencies"
|
||||||
@echo "make debug: Make with Debug hooked in"
|
@echo "make debug: Make with Debug hooked in"
|
||||||
@echo "make clean: Clean all files"
|
@echo "make clean: Clean all files"
|
||||||
|
@echo "make run: Run the executable after building"
|
||||||
|
|
||||||
$(BIN): $(OBJ)
|
$(BIN): $(OBJ)
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
$(CXX) $(CPPFLAGS) -o $(BIN) $(OBJ)
|
g++ $(CPPFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS)
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
g++ -c $< -o $@
|
g++ -c $< -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
|
find . -name "*.o" -type f -delete
|
||||||
|
55
src/main.cpp
55
src/main.cpp
@ -1,6 +1,57 @@
|
|||||||
|
#define GLFW_INCLUDE_VULKAN
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#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() {
|
int main() {
|
||||||
std::printf("Hello, World!\n");
|
TriangleTestApplication app;
|
||||||
return 0;
|
|
||||||
|
try {
|
||||||
|
app.run();
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user