X-Git-Url: https://git.ralfj.de/gltest.git/blobdiff_plain/aa8d6f63cc3b8ce1d8c7473ab59bbc2b2f92010c..46e0af78b821979029c3db50e353192384583f23:/gltest.cpp diff --git a/gltest.cpp b/gltest.cpp index 2b6105c..8d296a3 100644 --- a/gltest.cpp +++ b/gltest.cpp @@ -7,6 +7,9 @@ #include #include #include +#include + +namespace po = boost::program_options; // include proper GL connector #include "glwindow.h" @@ -53,10 +56,13 @@ public: TearTestWindow() : GLWindow(XOpenDisplay(0), createGLBackend()), boxPos(0), boxDirection(1) {} + void setSwapInterval(int i) { + getBackend()->setSwapInterval(i); + } + protected: virtual void initGL() { - getBackend()->setSwapInterval(1); // initialize GL proper glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glDisable(GL_DEPTH_TEST); @@ -179,7 +185,25 @@ private: int main(int argc, char ** argv) { + // program options handling + po::options_description desc("Allowed options"); + desc.add_options() + ("help,h", "produce help message") + ("swap-interval,i", po::value(), "set swap interval") + ; + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return 1; + } + + // actual program TearTestWindow w; w.open(800, 600); + if (vm.count("swap-interval")) + w.setSwapInterval(vm["swap-interval"].as()); w.exec(); }