added command line parameter to set spin speed
This commit is contained in:
parent
c32f4bdf09
commit
e970b2f661
22
glxgears.c
22
glxgears.c
@ -242,6 +242,8 @@ static void draw(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLfloat rotation_speed = 70.0;
|
||||||
|
|
||||||
static void idle(void) {
|
static void idle(void) {
|
||||||
static double t0 = -1.;
|
static double t0 = -1.;
|
||||||
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
|
||||||
@ -250,7 +252,7 @@ static void idle(void) {
|
|||||||
dt = t - t0;
|
dt = t - t0;
|
||||||
t0 = t;
|
t0 = t;
|
||||||
|
|
||||||
angle += 70.0 * dt; /* 70 degrees per second */
|
angle += rotation_speed * dt; /* 70 degrees per second */
|
||||||
angle = fmod(angle, 360.0); /* prevents eventual overflow */
|
angle = fmod(angle, 360.0); /* prevents eventual overflow */
|
||||||
|
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
@ -377,11 +379,17 @@ static void visible(int vis) {
|
|||||||
static char *window_title = "Gears";
|
static char *window_title = "Gears";
|
||||||
|
|
||||||
#ifdef USE_ARGP
|
#ifdef USE_ARGP
|
||||||
|
|
||||||
static const struct argp_option options[] = {
|
static const struct argp_option options[] = {
|
||||||
{"info", 256, 0, 0, "Display OpenGL renderer information"},
|
{"info", 256, 0, 0, "Display OpenGL renderer information"},
|
||||||
{"exit", 257, 0, 0, "Automatically exit after 30 seconds"},
|
{"exit", 257, 0, 0, "Automatically exit after 30 seconds"},
|
||||||
{"noanim", 258, 0, 0, "Don't start animation"},
|
{"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}};
|
{0}};
|
||||||
|
|
||||||
static error_t parse_opt(int key, char *val, struct argp_state *) {
|
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;
|
Animate = GL_FALSE;
|
||||||
break;
|
break;
|
||||||
case 259:
|
case 259:
|
||||||
|
rotation_speed = atof(val) * 6;
|
||||||
|
break;
|
||||||
|
case 260:
|
||||||
window_title = val;
|
window_title = val;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -403,7 +414,12 @@ static error_t parse_opt(int key, char *val, struct argp_state *) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct argp argp = {
|
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
|
#else
|
||||||
static void parse_args(int argc, char *argv[]) {
|
static void parse_args(int argc, char *argv[]) {
|
||||||
for (GLint i = 1; i < argc; i++)
|
for (GLint i = 1; i < argc; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user