minor refactoring

This commit is contained in:
Lexxy Fox 2023-11-01 12:35:19 -05:00
parent c1d7cd803f
commit e3a48c7aba

View File

@ -12,6 +12,7 @@
* Other modifications by Lexxy Fox.
*/
#include <GL/gl.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
@ -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));