refactor arg parsing

This commit is contained in:
Lexxy Fox 2023-11-01 16:55:02 -05:00
parent 31614c4799
commit 086060b9f5

View File

@ -310,6 +310,8 @@ static void reshape(int width, int height) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
} }
static GLboolean print_glinfo = GL_FALSE;
static void init_scene(void) { static void init_scene(void) {
glLightfv(GL_LIGHT0, GL_POSITION, (const GLfloat[]){5.0, 5.0, 10.0, 0.0}); glLightfv(GL_LIGHT0, GL_POSITION, (const GLfloat[]){5.0, 5.0, 10.0, 0.0});
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
@ -345,6 +347,14 @@ static void init_scene(void) {
glEndList(); glEndList();
glEnable(GL_NORMALIZE); glEnable(GL_NORMALIZE);
if (print_glinfo) {
printf("GL_VENDOR = %s\n", (char *)glGetString(GL_VENDOR));
printf("GL_RENDERER = %s\n", (char *)glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *)glGetString(GL_VERSION));
printf("GL_EXTENSIONS = %s\n", (char *)glGetString(GL_EXTENSIONS));
fflush(stdout);
}
} }
static void visible(int vis) { static void visible(int vis) {
@ -355,24 +365,24 @@ static void visible(int vis) {
static char *window_title = "Gears"; static char *window_title = "Gears";
static void parse_args(int argc, char *argv[]) { static void parse_args(int argc, char *argv[]) {
#ifdef USE_ARGP
#else
for (GLint i = 1; i < argc; i++) for (GLint i = 1; i < argc; i++)
if (strcmp(argv[i], "-info") == 0) { if (strcmp(argv[i], "-exit") == 0) {
printf("GL_VENDOR = %s\n", (char *)glGetString(GL_VENDOR));
printf("GL_RENDERER = %s\n", (char *)glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *)glGetString(GL_VERSION));
printf("GL_EXTENSIONS = %s\n", (char *)glGetString(GL_EXTENSIONS));
fflush(stdout);
} else if (strcmp(argv[i], "-exit") == 0) {
autoexit = 30; autoexit = 30;
printf("Auto Exit after %i seconds.\n", autoexit); printf("Auto Exit after %i seconds.\n", autoexit);
fflush(stdout); fflush(stdout);
} else if (strcmp(argv[i], "-noanim") == 0) } else if (strcmp(argv[i], "-info") == 0)
print_glinfo = GL_TRUE;
else if (strcmp(argv[i], "-noanim") == 0)
Animate = GL_FALSE; Animate = GL_FALSE;
#endif
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
parse_args(argc, argv);
glutInit(&argc, argv); glutInit(&argc, argv);
parse_args(argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
win = glutCreateWindow(window_title); win = glutCreateWindow(window_title);
init_scene(); init_scene();