added command line parameter to set spin speed
This commit is contained in:
parent
c32f4bdf09
commit
e970b2f661
24
glxgears.c
24
glxgears.c
@ -242,6 +242,8 @@ static void draw(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static GLfloat rotation_speed = 70.0;
|
||||
|
||||
static void idle(void) {
|
||||
static double t0 = -1.;
|
||||
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||
@ -250,8 +252,8 @@ static void idle(void) {
|
||||
dt = t - t0;
|
||||
t0 = t;
|
||||
|
||||
angle += 70.0 * dt; /* 70 degrees per second */
|
||||
angle = fmod(angle, 360.0); /* prevents eventual overflow */
|
||||
angle += rotation_speed * dt; /* 70 degrees per second */
|
||||
angle = fmod(angle, 360.0); /* prevents eventual overflow */
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
@ -377,11 +379,17 @@ static void visible(int vis) {
|
||||
static char *window_title = "Gears";
|
||||
|
||||
#ifdef USE_ARGP
|
||||
|
||||
static const struct argp_option options[] = {
|
||||
{"info", 256, 0, 0, "Display OpenGL renderer information"},
|
||||
{"exit", 257, 0, 0, "Automatically exit after 30 seconds"},
|
||||
{"noanim", 258, 0, 0, "Don't start animation"},
|
||||
{"title", 259, "title", 0, "Set window title (defaults to \"Gears\")"},
|
||||
{"spin",
|
||||
259,
|
||||
"speed",
|
||||
0,
|
||||
"Set rotational speed in RPM (defaults to 11.666666667)"},
|
||||
{"title", 260, "title", 0, "Set window title (defaults to \"Gears\")"},
|
||||
{0}};
|
||||
|
||||
static error_t parse_opt(int key, char *val, struct argp_state *) {
|
||||
@ -396,6 +404,9 @@ static error_t parse_opt(int key, char *val, struct argp_state *) {
|
||||
Animate = GL_FALSE;
|
||||
break;
|
||||
case 259:
|
||||
rotation_speed = atof(val) * 6;
|
||||
break;
|
||||
case 260:
|
||||
window_title = val;
|
||||
break;
|
||||
}
|
||||
@ -403,7 +414,12 @@ static error_t parse_opt(int key, char *val, struct argp_state *) {
|
||||
}
|
||||
|
||||
static const struct argp argp = {
|
||||
options, parse_opt, 0, "Universal rights are universal."};
|
||||
options,
|
||||
parse_opt,
|
||||
0,
|
||||
"The glxgears program is a port of the `gears` demo to GLX. It displays a "
|
||||
"set of rotating gears and prints out the frame rate at regular intervals. "
|
||||
"It has become quite popular as basic benchmarking tool."};
|
||||
#else
|
||||
static void parse_args(int argc, char *argv[]) {
|
||||
for (GLint i = 1; i < argc; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user