code format
This commit is contained in:
parent
e970b2f661
commit
a32edb4eec
@ -13,6 +13,7 @@ ReflowComments: true
|
|||||||
RemoveBracesLLVM: true
|
RemoveBracesLLVM: true
|
||||||
SortIncludes: CaseInsensitive
|
SortIncludes: CaseInsensitive
|
||||||
TabWidth: 2
|
TabWidth: 2
|
||||||
|
ContinuationIndentWidth: 2
|
||||||
UseTab: AlignWithSpaces
|
UseTab: AlignWithSpaces
|
||||||
|
|
||||||
# ex:se ft=yaml
|
# ex:se ft=yaml
|
||||||
|
4
Makefile
4
Makefile
@ -1,5 +1,5 @@
|
|||||||
# Options (e.g. `CFLAGS=-DUSE_ARGP make`)
|
# Options (e.g. `CFLAGS=-DHAVE_ARGP make`)
|
||||||
# USE_ARGP: use `argp` for argument parsing.
|
# HAVE_ARGP: use `argp` for argument parsing.
|
||||||
|
|
||||||
VERSION ?= 9.0.1
|
VERSION ?= 9.0.1
|
||||||
|
|
||||||
|
73
glxgears.c
73
glxgears.c
@ -12,7 +12,7 @@
|
|||||||
* Other modifications by Lexxy Fox.
|
* Other modifications by Lexxy Fox.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_ARGP
|
#ifdef HAVE_ARGP
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
#endif
|
#endif
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
@ -51,11 +51,11 @@ static GLfloat viewDist = 40.0;
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
static void gear(
|
static void gear(
|
||||||
GLfloat inner_radius,
|
GLfloat inner_radius,
|
||||||
GLfloat outer_radius,
|
GLfloat outer_radius,
|
||||||
GLfloat width,
|
GLfloat width,
|
||||||
GLint teeth,
|
GLint teeth,
|
||||||
GLfloat tooth_depth
|
GLfloat tooth_depth
|
||||||
) {
|
) {
|
||||||
GLint i;
|
GLint i;
|
||||||
GLfloat r0, r1, r2;
|
GLfloat r0, r1, r2;
|
||||||
@ -81,7 +81,7 @@ static void gear(
|
|||||||
if (i < teeth) {
|
if (i < teeth) {
|
||||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||||
glVertex3f(
|
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);
|
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||||
if (i < teeth) {
|
if (i < teeth) {
|
||||||
glVertex3f(
|
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);
|
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||||
}
|
}
|
||||||
@ -124,10 +124,10 @@ static void gear(
|
|||||||
angle = i * 2.0 * M_PI / teeth;
|
angle = i * 2.0 * M_PI / teeth;
|
||||||
|
|
||||||
glVertex3f(
|
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(
|
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(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -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);
|
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);
|
||||||
glVertex3f(
|
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);
|
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
|
||||||
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
|
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
|
||||||
glNormal3f(v, -u, 0.0);
|
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);
|
||||||
glVertex3f(
|
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);
|
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||||
}
|
}
|
||||||
@ -337,9 +337,9 @@ static void init_scene(void) {
|
|||||||
gear1 = glGenLists(1);
|
gear1 = glGenLists(1);
|
||||||
glNewList(gear1, GL_COMPILE);
|
glNewList(gear1, GL_COMPILE);
|
||||||
glMaterialfv(
|
glMaterialfv(
|
||||||
GL_FRONT,
|
GL_FRONT,
|
||||||
GL_AMBIENT_AND_DIFFUSE,
|
GL_AMBIENT_AND_DIFFUSE,
|
||||||
(const GLfloat[]){245.0 / 255, 169.0 / 255, 184.0 / 255, 1}
|
(const GLfloat[]){245.0 / 255, 169.0 / 255, 184.0 / 255, 1}
|
||||||
);
|
);
|
||||||
gear(1.0, 4.0, 1.0, 20, 0.7);
|
gear(1.0, 4.0, 1.0, 20, 0.7);
|
||||||
glEndList();
|
glEndList();
|
||||||
@ -353,9 +353,9 @@ static void init_scene(void) {
|
|||||||
gear3 = glGenLists(1);
|
gear3 = glGenLists(1);
|
||||||
glNewList(gear3, GL_COMPILE);
|
glNewList(gear3, GL_COMPILE);
|
||||||
glMaterialfv(
|
glMaterialfv(
|
||||||
GL_FRONT,
|
GL_FRONT,
|
||||||
GL_AMBIENT_AND_DIFFUSE,
|
GL_AMBIENT_AND_DIFFUSE,
|
||||||
(const GLfloat[]){91.0 / 255, 206.0 / 255, 250.0 / 255, 1}
|
(const GLfloat[]){91.0 / 255, 206.0 / 255, 250.0 / 255, 1}
|
||||||
);
|
);
|
||||||
gear(1.3, 2.0, 0.5, 10, 0.7);
|
gear(1.3, 2.0, 0.5, 10, 0.7);
|
||||||
glEndList();
|
glEndList();
|
||||||
@ -378,19 +378,18 @@ static void visible(int vis) {
|
|||||||
|
|
||||||
static char *window_title = "Gears";
|
static char *window_title = "Gears";
|
||||||
|
|
||||||
#ifdef USE_ARGP
|
#ifdef HAVE_ARGP
|
||||||
|
|
||||||
static const struct argp_option options[] = {
|
static const struct argp_option options[] = {
|
||||||
{"info", 256, 0, 0, "Display OpenGL renderer information"},
|
{"info", 256, 0, 0, "Display OpenGL renderer information"},
|
||||||
{"exit", 257, 0, 0, "Automatically exit after 30 seconds"},
|
{"exit", 257, 0, 0, "Automatically exit after 30 seconds"},
|
||||||
{"noanim", 258, 0, 0, "Don't start animation"},
|
{"noanim", 258, 0, 0, "Don't start animation"},
|
||||||
{"spin",
|
{"spin",
|
||||||
259,
|
259,
|
||||||
"speed",
|
"speed",
|
||||||
0,
|
0,
|
||||||
"Set rotational speed in RPM (defaults to 11.666666667)"},
|
"Set rotational speed in RPM (defaults to 11.666666667)"},
|
||||||
{"title", 260, "title", 0, "Set window title (defaults to \"Gears\")"},
|
{"title", 260, "title", 0, "Set window title (defaults to \"Gears\")"},
|
||||||
{0}};
|
{0}};
|
||||||
|
|
||||||
static error_t parse_opt(int key, char *val, struct argp_state *) {
|
static error_t parse_opt(int key, char *val, struct argp_state *) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@ -414,12 +413,12 @@ static error_t parse_opt(int key, char *val, struct argp_state *) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct argp argp = {
|
static const struct argp argp = {
|
||||||
options,
|
options,
|
||||||
parse_opt,
|
parse_opt,
|
||||||
0,
|
0,
|
||||||
"The glxgears program is a port of the `gears` demo to GLX. It displays a "
|
"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. "
|
"set of rotating gears and prints out the frame rate at regular intervals. "
|
||||||
"It has become quite popular as basic benchmarking tool."};
|
"It has become quite popular as basic benchmarking tool."};
|
||||||
#else
|
#else
|
||||||
static void parse_args(int argc, char *argv[]) {
|
static void parse_args(int argc, char *argv[]) {
|
||||||
for (GLint i = 1; i < argc; i++)
|
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[]) {
|
int main(int argc, char *argv[]) {
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
#ifdef USE_ARGP
|
#ifdef HAVE_ARGP
|
||||||
argp_parse(&argp, argc, argv, ARGP_LONG_ONLY, 0, 0);
|
argp_parse(&argp, argc, argv, ARGP_LONG_ONLY, 0, 0);
|
||||||
#else
|
#else
|
||||||
parse_args(argc, argv);
|
parse_args(argc, argv);
|
||||||
|
Loading…
Reference in New Issue
Block a user