From e3a48c7aba37197ac5920b30fc33f6dc6b6ea838 Mon Sep 17 00:00:00 2001 From: Lexxy Fox Date: Wed, 1 Nov 2023 12:35:19 -0500 Subject: [PATCH] minor refactoring --- glxgears.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/glxgears.c b/glxgears.c index 471c97e..e71da16 100644 --- a/glxgears.c +++ b/glxgears.c @@ -12,6 +12,7 @@ * Other modifications by Lexxy Fox. */ +#include #include #include #include @@ -309,13 +310,7 @@ static void reshape(int width, int height) { } static void init(int argc, char *argv[]) { - static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0}; - static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0}; - static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0}; - static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0}; - GLint i; - - glLightfv(GL_LIGHT0, GL_POSITION, pos); + glLightfv(GL_LIGHT0, GL_POSITION, (GLfloat[]){5.0, 5.0, 10.0, 0.0}); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); @@ -324,25 +319,31 @@ static void init(int argc, char *argv[]) { /* make the gears */ gear1 = glGenLists(1); glNewList(gear1, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + glMaterialfv( + GL_FRONT, GL_AMBIENT_AND_DIFFUSE, (GLfloat[]){0.8, 0.1, 0.0, 1.0} + ); gear(1.0, 4.0, 1.0, 20, 0.7); glEndList(); gear2 = glGenLists(1); glNewList(gear2, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + glMaterialfv( + GL_FRONT, GL_AMBIENT_AND_DIFFUSE, (GLfloat[]){0.0, 0.8, 0.2, 1.0} + ); gear(0.5, 2.0, 2.0, 10, 0.7); glEndList(); gear3 = glGenLists(1); glNewList(gear3, GL_COMPILE); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + glMaterialfv( + GL_FRONT, GL_AMBIENT_AND_DIFFUSE, (GLfloat[]){0.2, 0.2, 1.0, 1.0} + ); gear(1.3, 2.0, 0.5, 10, 0.7); glEndList(); glEnable(GL_NORMALIZE); - for (i = 1; i < argc; i++) { + for (GLint i = 1; i < argc; i++) { if (strcmp(argv[i], "-info") == 0) { printf("GL_VENDOR = %s\n", (char *)glGetString(GL_VENDOR)); printf("GL_RENDERER = %s\n", (char *)glGetString(GL_RENDERER));