projects
/
gltest.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
aa8d6f6
)
add command-line option for swap interval
author
Ralf Jung
<post@ralfj.de>
Sun, 31 Mar 2013 13:44:43 +0000
(15:44 +0200)
committer
Ralf Jung
<post@ralfj.de>
Sun, 31 Mar 2013 13:44:43 +0000
(15:44 +0200)
Makefile
patch
|
blob
|
history
gltest.cpp
patch
|
blob
|
history
diff --git
a/Makefile
b/Makefile
index 307458092c8e632d223c55324dad6759d12b2e85..c07c0fc69e65c63a5b44dce415322a878c30bdc0 100644
(file)
--- a/
Makefile
+++ b/
Makefile
@@
-6,10
+6,10
@@
COMMON_HDR = glwindow.h
all: glxtest egltest eglinfo
glxtest: $(COMMON_SRC) $(COMMON_HDR) glxbackend.cpp glxbackend.h
all: glxtest egltest eglinfo
glxtest: $(COMMON_SRC) $(COMMON_HDR) glxbackend.cpp glxbackend.h
- g++ $(FLAGS) -DUSE_GLX $(COMMON_SRC) glxbackend.cpp -lGL -lX11 -o glxtest
+ g++ $(FLAGS) -DUSE_GLX $(COMMON_SRC) glxbackend.cpp -lGL -lX11 -
lboost_program_options -
o glxtest
egltest: $(COMMON_SRC) $(COMMON_HDR) eglbackend.cpp eglbackend.h
egltest: $(COMMON_SRC) $(COMMON_HDR) eglbackend.cpp eglbackend.h
- g++ $(FLAGS) -DUSE_EGL $(COMMON_SRC) eglbackend.cpp -lEGL -lGL -lX11 -o egltest
+ g++ $(FLAGS) -DUSE_EGL $(COMMON_SRC) eglbackend.cpp -lEGL -lGL -lX11 -
lboost_program_options -
o egltest
eglinfo: eglinfo.c
gcc $(FLAGS) eglinfo.c -lEGL -lGL -lX11 -o eglinfo
eglinfo: eglinfo.c
gcc $(FLAGS) eglinfo.c -lEGL -lGL -lX11 -o eglinfo
diff --git
a/gltest.cpp
b/gltest.cpp
index 2b6105c3d9b3b3da56600cb7be960de0a819eafb..8d296a3991965e965e0c3ac1e7e0c03eba4a6c53 100644
(file)
--- a/
gltest.cpp
+++ b/
gltest.cpp
@@
-7,6
+7,9
@@
#include <unistd.h>
#include <assert.h>
#include <GL/gl.h>
#include <unistd.h>
#include <assert.h>
#include <GL/gl.h>
+#include <boost/program_options.hpp>
+
+namespace po = boost::program_options;
// include proper GL connector
#include "glwindow.h"
// include proper GL connector
#include "glwindow.h"
@@
-53,10
+56,13
@@
public:
TearTestWindow() : GLWindow(XOpenDisplay(0), createGLBackend()), boxPos(0), boxDirection(1)
{}
TearTestWindow() : GLWindow(XOpenDisplay(0), createGLBackend()), boxPos(0), boxDirection(1)
{}
+ void setSwapInterval(int i) {
+ getBackend()->setSwapInterval(i);
+ }
+
protected:
virtual void initGL()
{
protected:
virtual void initGL()
{
- getBackend()->setSwapInterval(1);
// initialize GL proper
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glDisable(GL_DEPTH_TEST);
// 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)
{
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<int>(), "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);
TearTestWindow w;
w.open(800, 600);
+ if (vm.count("swap-interval"))
+ w.setSwapInterval(vm["swap-interval"].as<int>());
w.exec();
}
w.exec();
}