From 8ba4ca3ffbe5dd33031f4681c6999f67b8e9e410 Mon Sep 17 00:00:00 2001 From: /jedi/ Date: Tue, 27 Sep 2016 20:38:36 +0200 Subject: [PATCH] cmd options --- README.md | 7 +++++- game/main.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++---- game/options.hpp | 21 +++++++++++++++++ 3 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 game/options.hpp diff --git a/README.md b/README.md index 1b13b96..d418f56 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ Klassische Kepler Kriege -=== +======================== Game based on NewtonWars (https://github.com/Draradech/NewtonWars), rewritten in C++ with some more fancy OpenGL shitz. + +dependencies +------------ + +libepoxy-dev diff --git a/game/main.cpp b/game/main.cpp index a63380e..1459bd4 100644 --- a/game/main.cpp +++ b/game/main.cpp @@ -1,12 +1,62 @@ #include "opengl.h" #include +#include //#include "triangle_window.h" #include "game_window.h" +#include "options.hpp" -int main(int argc, const char *argv[]) { - GameWindow window(500, 500); - window.set_maxfps(60.0); - window.loop(); - window.stop(); + +using namespace std; + +int main(int argc, char *argv[]) { + + char c; + + static struct option long_options[] = + { + /* These options set a flag. */ +// {"verbose", no_argument, &verbose_flag, 1}, +// {"brief", no_argument, &verbose_flag, 0}, + /* These options don’t set a flag. + We distinguish them by their indices. */ +// {"add", no_argument, 0, 'a'}, +// {"append", no_argument, 0, 'b'}, +// {"delete", required_argument, 0, 'd'}, +// {"create", required_argument, 0, 'c'}, + {"fps", no_argument, 0, 'f'}, + {0, 0, 0, 0} + }; + + int option_index = 0; + + while(1){ + c = getopt_long (argc, argv, "abc:d:f", + long_options, &option_index); + if (c == -1) + break; + + switch (c) + { + case 'f': + SET_FLAG(SHOW_FPS,true); + break; + /*case 'c': + cvalue = optarg; + break; + */ + + case '?': + /* getopt_long already printed an error message. */ + break; + + default: + abort(); + } + } + + GameWindow window(500, 500); + window.set_maxfps(60.0); + window.loop(); + window.stop(); } diff --git a/game/options.hpp b/game/options.hpp new file mode 100644 index 0000000..779e32e --- /dev/null +++ b/game/options.hpp @@ -0,0 +1,21 @@ + +#define TEST_FLAG1 0 +#define SHOW_FPS 1 +#define TEST_FLAG2 2 +//... + + + + +#define SET_FLAG(x,y) optionsFlags&=(~((1)<