From a32edb4eec0725f71b8e732ca03742f2c59a0916 Mon Sep 17 00:00:00 2001 From: Lexxy Fox Date: Thu, 2 Nov 2023 11:56:11 -0500 Subject: [PATCH] code format --- .clang-format | 1 + Makefile | 6 ++--- glxgears.c | 73 +++++++++++++++++++++++++-------------------------- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.clang-format b/.clang-format index 07121bf..5f2764e 100644 --- a/.clang-format +++ b/.clang-format @@ -13,6 +13,7 @@ ReflowComments: true RemoveBracesLLVM: true SortIncludes: CaseInsensitive TabWidth: 2 +ContinuationIndentWidth: 2 UseTab: AlignWithSpaces # ex:se ft=yaml diff --git a/Makefile b/Makefile index adef96d..5847399 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -# Options (e.g. `CFLAGS=-DUSE_ARGP make`) -# USE_ARGP: use `argp` for argument parsing. +# Options (e.g. `CFLAGS=-DHAVE_ARGP make`) +# HAVE_ARGP: use `argp` for argument parsing. VERSION ?= 9.0.1 @@ -94,4 +94,4 @@ uninstall: # https://www.gnu.org/prep/standards/html_node/Directory-Variables.html # https://www.gnu.org/prep/standards/html_node/Standard-Targets.html # https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html -# https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html \ No newline at end of file +# https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html diff --git a/glxgears.c b/glxgears.c index 5f5fe9a..fdd1f90 100644 --- a/glxgears.c +++ b/glxgears.c @@ -12,7 +12,7 @@ * Other modifications by Lexxy Fox. */ -#ifdef USE_ARGP +#ifdef HAVE_ARGP #include #endif #include @@ -51,11 +51,11 @@ static GLfloat viewDist = 40.0; **/ static void gear( - GLfloat inner_radius, - GLfloat outer_radius, - GLfloat width, - GLint teeth, - GLfloat tooth_depth + GLfloat inner_radius, + GLfloat outer_radius, + GLfloat width, + GLint teeth, + GLfloat tooth_depth ) { GLint i; GLfloat r0, r1, r2; @@ -81,7 +81,7 @@ static void gear( if (i < teeth) { glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); glVertex3f( - r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5 + r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5 ); } } @@ -110,7 +110,7 @@ static void gear( glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); if (i < teeth) { glVertex3f( - r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5 + r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5 ); glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); } @@ -124,10 +124,10 @@ static void gear( angle = i * 2.0 * M_PI / teeth; glVertex3f( - r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5 + r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5 ); glVertex3f( - r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5 + r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5 ); glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); @@ -152,14 +152,14 @@ static void gear( glNormal3f(cos(angle), sin(angle), 0.0); glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); glVertex3f( - r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5 + r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5 ); u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); glNormal3f(v, -u, 0.0); glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); glVertex3f( - r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5 + r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5 ); glNormal3f(cos(angle), sin(angle), 0.0); } @@ -337,9 +337,9 @@ static void init_scene(void) { gear1 = glGenLists(1); glNewList(gear1, GL_COMPILE); glMaterialfv( - GL_FRONT, - GL_AMBIENT_AND_DIFFUSE, - (const GLfloat[]){245.0 / 255, 169.0 / 255, 184.0 / 255, 1} + GL_FRONT, + GL_AMBIENT_AND_DIFFUSE, + (const GLfloat[]){245.0 / 255, 169.0 / 255, 184.0 / 255, 1} ); gear(1.0, 4.0, 1.0, 20, 0.7); glEndList(); @@ -353,9 +353,9 @@ static void init_scene(void) { gear3 = glGenLists(1); glNewList(gear3, GL_COMPILE); glMaterialfv( - GL_FRONT, - GL_AMBIENT_AND_DIFFUSE, - (const GLfloat[]){91.0 / 255, 206.0 / 255, 250.0 / 255, 1} + GL_FRONT, + GL_AMBIENT_AND_DIFFUSE, + (const GLfloat[]){91.0 / 255, 206.0 / 255, 250.0 / 255, 1} ); gear(1.3, 2.0, 0.5, 10, 0.7); glEndList(); @@ -378,19 +378,18 @@ static void visible(int vis) { static char *window_title = "Gears"; -#ifdef USE_ARGP - +#ifdef HAVE_ARGP static const struct argp_option options[] = { - {"info", 256, 0, 0, "Display OpenGL renderer information"}, - {"exit", 257, 0, 0, "Automatically exit after 30 seconds"}, - {"noanim", 258, 0, 0, "Don't start animation"}, - {"spin", - 259, - "speed", - 0, - "Set rotational speed in RPM (defaults to 11.666666667)"}, - {"title", 260, "title", 0, "Set window title (defaults to \"Gears\")"}, - {0}}; + {"info", 256, 0, 0, "Display OpenGL renderer information"}, + {"exit", 257, 0, 0, "Automatically exit after 30 seconds"}, + {"noanim", 258, 0, 0, "Don't start animation"}, + {"spin", + 259, + "speed", + 0, + "Set rotational speed in RPM (defaults to 11.666666667)"}, + {"title", 260, "title", 0, "Set window title (defaults to \"Gears\")"}, + {0}}; static error_t parse_opt(int key, char *val, struct argp_state *) { switch (key) { @@ -414,12 +413,12 @@ static error_t parse_opt(int key, char *val, struct argp_state *) { } static const struct argp argp = { - 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."}; + 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 static void parse_args(int argc, char *argv[]) { for (GLint i = 1; i < argc; i++) @@ -436,7 +435,7 @@ static void parse_args(int argc, char *argv[]) { int main(int argc, char *argv[]) { glutInit(&argc, argv); -#ifdef USE_ARGP +#ifdef HAVE_ARGP argp_parse(&argp, argc, argv, ARGP_LONG_ONLY, 0, 0); #else parse_args(argc, argv);