code format
This commit is contained in:
parent
e970b2f661
commit
a32edb4eec
@ -13,6 +13,7 @@ ReflowComments: true
|
||||
RemoveBracesLLVM: true
|
||||
SortIncludes: CaseInsensitive
|
||||
TabWidth: 2
|
||||
ContinuationIndentWidth: 2
|
||||
UseTab: AlignWithSpaces
|
||||
|
||||
# ex:se ft=yaml
|
||||
|
4
Makefile
4
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
|
||||
|
||||
|
73
glxgears.c
73
glxgears.c
@ -12,7 +12,7 @@
|
||||
* Other modifications by Lexxy Fox.
|
||||
*/
|
||||
|
||||
#ifdef USE_ARGP
|
||||
#ifdef HAVE_ARGP
|
||||
#include <argp.h>
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user