refactored arg parsing into separate function

This commit is contained in:
Lexxy Fox 2023-11-01 13:10:31 -05:00
parent 5cd3159c40
commit 64ee02b9c9

View File

@ -312,7 +312,7 @@ static void reshape(int width, int height) {
glMatrixMode(GL_MODELVIEW);
}
static void init(int argc, char *argv[]) {
static void init_scene(void) {
glLightfv(GL_LIGHT0, GL_POSITION, (const GLfloat[]){5.0, 5.0, 10.0, 0.0});
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
@ -347,7 +347,14 @@ static void init(int argc, char *argv[]) {
glEndList();
glEnable(GL_NORMALIZE);
}
static void visible(int vis) {
Visible = vis;
update_idle_func();
}
void parse_args(int argc, char *argv[]) {
for (GLint i = 1; i < argc; i++) {
if (strcmp(argv[i], "-info") == 0) {
printf("GL_VENDOR = %s\n", (char *)glGetString(GL_VENDOR));
@ -365,17 +372,12 @@ static void init(int argc, char *argv[]) {
}
}
static void visible(int vis) {
Visible = vis;
update_idle_func();
}
int main(int argc, char *argv[]) {
glutInitWindowSize(300, 300);
parse_args(argc, argv);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
win = glutCreateWindow("Gears");
init(argc, argv);
init_scene();
glutDisplayFunc(draw);
glutReshapeFunc(reshape);