|
|
|
@ -21,7 +21,10 @@
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#define GLFW_INCLUDE_VULKAN
|
|
|
|
|
extern "C" {
|
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "./lib/cli.hpp"
|
|
|
|
|
|
|
|
|
@ -29,24 +32,27 @@
|
|
|
|
|
#define EXIT_RUNTIME 1
|
|
|
|
|
#define EXIT_USAGE 2
|
|
|
|
|
|
|
|
|
|
uint32_t windowWidth = 1366;
|
|
|
|
|
uint32_t windowHeight = 768;
|
|
|
|
|
|
|
|
|
|
//TODO: check the TODO above glfwInit() in void main()
|
|
|
|
|
// #### Callbacks ##############################################################
|
|
|
|
|
void cursorPositionCallback(GLFWwindow* window, double x, double y) {
|
|
|
|
|
void cursorPositionCallback([[maybe_unused]] GLFWwindow* window, [[maybe_unused]] double x, [[maybe_unused]] double y) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void keyCallback(GLFWwindow* window, int32_t key, int32_t scancode, int32_t action, int32_t mods) {
|
|
|
|
|
void keyCallback([[maybe_unused]] GLFWwindow* window, [[maybe_unused]] int32_t key, [[maybe_unused]] int32_t scancode, [[maybe_unused]] int32_t action, [[maybe_unused]] int32_t mods) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void textInputCallback(GLFWwindow* window, uint32_t codepoint) {
|
|
|
|
|
void textInputCallback([[maybe_unused]] GLFWwindow* window, [[maybe_unused]] uint32_t codepoint) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cursorEnterLeaveCallback(GLFWwindow* window, int32_t entered) {
|
|
|
|
|
void cursorEnterLeaveCallback([[maybe_unused]] GLFWwindow* window, [[maybe_unused]] int32_t entered) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mouseButtonCallback(GLFWwindow* window, int32_t button, int32_t action, int32_t mods) {
|
|
|
|
|
void mouseButtonCallback([[maybe_unused]] GLFWwindow* window, [[maybe_unused]] int32_t button, [[maybe_unused]] int32_t action, [[maybe_unused]] int32_t mods) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void scrollCallback(GLFWwindow* window, double x, double y) {
|
|
|
|
|
void scrollCallback([[maybe_unused]] GLFWwindow* window, [[maybe_unused]] double x, [[maybe_unused]] double y) {
|
|
|
|
|
}
|
|
|
|
|
// #### End Callbacks ##########################################################
|
|
|
|
|
|
|
|
|
@ -55,6 +61,8 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
flags.push_back(CLI::Flag('h', "help", "print help and exit"));
|
|
|
|
|
flags.push_back(CLI::Flag('l', "license", "print license information and exit"));
|
|
|
|
|
std::vector<CLI::Option> options;
|
|
|
|
|
options.push_back(CLI::Option('x', "window-width", "PIXELS", "window width on startup"));
|
|
|
|
|
options.push_back(CLI::Option('y', "window-height", "PIXELS", "window height on startup"));
|
|
|
|
|
std::vector<CLI::Argument> arguments;
|
|
|
|
|
CLI::ArgumentsParser cliParser = CLI::ArgumentsParser(argc, argv, flags, options, arguments, "FOSS-VG Client");
|
|
|
|
|
|
|
|
|
@ -88,6 +96,14 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
return EXIT_USAGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cliParser.getOption("window-width").errorCode != ErrorCodes::NOT_PRESENT) {
|
|
|
|
|
windowWidth = std::stoi(cliParser.getOption("window-width").value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cliParser.getOption("window-height").errorCode != ErrorCodes::NOT_PRESENT) {
|
|
|
|
|
windowHeight = std::stoi(cliParser.getOption("window-height").value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Find a better place for this
|
|
|
|
|
// Ideally, the window management and rendering portion of FOSS-VG should
|
|
|
|
@ -99,9 +115,11 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
return EXIT_RUNTIME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO: allow to set startup window size using CLI options
|
|
|
|
|
uint32_t windowWidth = 1366;
|
|
|
|
|
uint32_t windowHeight = 768;
|
|
|
|
|
// do not create OpenGL context
|
|
|
|
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
|
|
|
|
|
|
|
|
|
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
|
|
|
|
|
|
|
|
|
//TODO: add a version macro
|
|
|
|
|
// (for example Git commit hash passed on the compiler command line)
|
|
|
|
|
std::string windowTitle = "FOSS-VG";
|
|
|
|
@ -113,9 +131,6 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
return EXIT_RUNTIME;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// What dis do? It was in a tutorial.
|
|
|
|
|
glfwMakeContextCurrent(window);
|
|
|
|
|
|
|
|
|
|
glfwSetCursorPosCallback(window, cursorPositionCallback);
|
|
|
|
|
glfwSetKeyCallback(window, keyCallback);
|
|
|
|
|
glfwSetCharCallback(window, textInputCallback);
|
|
|
|
@ -124,12 +139,10 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
glfwSetScrollCallback(window, scrollCallback);
|
|
|
|
|
|
|
|
|
|
while (!glfwWindowShouldClose(window)) {
|
|
|
|
|
|
|
|
|
|
glfwSwapBuffers(window);
|
|
|
|
|
|
|
|
|
|
glfwPollEvents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glfwDestroyWindow(window);
|
|
|
|
|
glfwTerminate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|