138 lines
4.9 KiB
C++
138 lines
4.9 KiB
C++
// Copyright 2022, FOSS-VG Developers and Contributers
|
|
//
|
|
// Author(s):
|
|
// BodgeMaster
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify it
|
|
// under the terms of the GNU Affero General Public License as published
|
|
// by the Free Software Foundation, version 3.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied
|
|
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
// See the GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// version 3 along with this program.
|
|
// If not, see https://www.gnu.org/licenses/agpl-3.0.en.html
|
|
|
|
#include <iostream>
|
|
#include <vector>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#include "./lib/cli.hpp"
|
|
|
|
#define EXIT_SUCCESS 0
|
|
#define EXIT_RUNTIME 1
|
|
#define EXIT_USAGE 2
|
|
|
|
//TODO: check the TODO above glfwInit() in void main()
|
|
// #### Callbacks ##############################################################
|
|
void cursorPositionCallback(GLFWwindow* window, double x, double y) {
|
|
}
|
|
|
|
void keyCallback(GLFWwindow* window, int32_t key, int32_t scancode, int32_t action, int32_t mods) {
|
|
}
|
|
|
|
void textInputCallback(GLFWwindow* window, uint32_t codepoint) {
|
|
}
|
|
|
|
void cursorEnterLeaveCallback(GLFWwindow* window, int32_t entered) {
|
|
}
|
|
|
|
void mouseButtonCallback(GLFWwindow* window, int32_t button, int32_t action, int32_t mods) {
|
|
}
|
|
|
|
void scrollCallback(GLFWwindow* window, double x, double y) {
|
|
}
|
|
// #### End Callbacks ##########################################################
|
|
|
|
int main(int argc, char* argv[]) {
|
|
std::vector<CLI::Flag> flags;
|
|
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;
|
|
std::vector<CLI::Argument> arguments;
|
|
CLI::ArgumentsParser cliParser = CLI::ArgumentsParser(argc, argv, flags, options, arguments, "FOSS-VG Client");
|
|
|
|
if (cliParser.getFlag("help").value) {
|
|
std::cout << cliParser.getUsage() << std::endl;
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|
|
if (cliParser.getFlag("license").value){
|
|
std::cout
|
|
<< "Copyright 2022, FOSS-VG Developers and Contributers\n"
|
|
<< "\n"
|
|
<< "This program is free software: you can redistribute it and/or modify it\n"
|
|
<< "under the terms of the GNU Affero General Public License as published\n"
|
|
<< "by the Free Software Foundation, version 3.\n"
|
|
<< "\n"
|
|
<< "This program is distributed in the hope that it will be useful,\n"
|
|
<< "but WITHOUT ANY WARRANTY; without even the implied\n"
|
|
<< "warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
|
|
<< "See the GNU Affero General Public License for more details.\n"
|
|
<< "\n"
|
|
<< "You should have received a copy of the GNU Affero General Public License\n"
|
|
<< "version 3 along with this program.\n"
|
|
<< "If not, see https://www.gnu.org/licenses/agpl-3.0.en.html"
|
|
<< std::endl;
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|
|
if (cliParser.wrongUsage) {
|
|
std::cout << cliParser.getUsage() << std::endl;
|
|
return EXIT_USAGE;
|
|
}
|
|
|
|
|
|
// TODO: Find a better place for this
|
|
// Ideally, the window management and rendering portion of FOSS-VG should
|
|
// live in a library so it can be easily reloaded/restarted for things like
|
|
// switching from/to fullscreen. For now, I am going to put it here because
|
|
// I want to get it going before making it pretty.
|
|
{
|
|
if (!glfwInit()) {
|
|
return EXIT_RUNTIME;
|
|
}
|
|
|
|
//TODO: allow to set startup window size using CLI options
|
|
uint32_t windowWidth = 1366;
|
|
uint32_t windowHeight = 768;
|
|
//TODO: add a version macro
|
|
// (for example Git commit hash passed on the compiler command line)
|
|
std::string windowTitle = "FOSS-VG";
|
|
|
|
// Apparently, this also allows to set things like whether the window is full-screen
|
|
GLFWwindow* window = glfwCreateWindow(windowWidth, windowHeight, windowTitle.c_str(), nullptr, nullptr);
|
|
|
|
if (window == nullptr) {
|
|
return EXIT_RUNTIME;
|
|
}
|
|
|
|
// What dis do? It was in a tutorial.
|
|
glfwMakeContextCurrent(window);
|
|
|
|
glfwSetCursorPosCallback(window, cursorPositionCallback);
|
|
glfwSetKeyCallback(window, keyCallback);
|
|
glfwSetCharCallback(window, textInputCallback);
|
|
glfwSetCursorEnterCallback(window, cursorEnterLeaveCallback);
|
|
glfwSetMouseButtonCallback(window, mouseButtonCallback);
|
|
glfwSetScrollCallback(window, scrollCallback);
|
|
|
|
while (!glfwWindowShouldClose(window)) {
|
|
|
|
glfwSwapBuffers(window);
|
|
|
|
glfwPollEvents();
|
|
}
|
|
|
|
glfwTerminate();
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|