From: John Tsiombikas Date: Sun, 1 Sep 2019 14:38:54 +0000 (+0300) Subject: done with the basic effect X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=censuslogo;a=commitdiff_plain;h=ba970dd01d42881977bcb41a346d82910f6cda5f done with the basic effect --- diff --git a/Makefile b/Makefile index ffa81be..f27fe85 100644 --- a/Makefile +++ b/Makefile @@ -5,15 +5,16 @@ bin = censuslogo sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') -CFLAGS = -pedantic -Wall -g +CFLAGS = -pedantic -Wall -g -DNOLOAD LDFLAGS = $(LDFLAGS_$(sys)) -lm LDFLAGS_Linux = -lGL -lGLU -lglut -LDFLAGS_mingw = -lmingw32 -mconsole -lopengl32 -lglu32 -lfreeglut +LDFLAGS_mingw = -lmingw32 -mconsole -lfreeglut_static -lopengl32 -lglu32 -lgdi32 -lwinmm ifeq ($(sys), mingw) obj = $(src:.c=.w32.o) bin = censuslogo.exe + CFLAGS += -DFREEGLUT_STATIC endif $(bin): $(obj) diff --git a/src/logo.c b/src/logo.c index 069c4d7..c0e0239 100644 --- a/src/logo.c +++ b/src/logo.c @@ -5,6 +5,7 @@ #include #include "cgmath/cgmath.h" #include "logo.h" +#include "logodata.h" struct cpnode { cgm_vec2 p; @@ -20,6 +21,14 @@ struct cpnode { static cgm_vec2 *cp; static int numcp; +#ifdef NOLOAD +int init_logo(const char *fname) +{ + cp = logocp; + numcp = LOGO_NUM_CP; + return 0; +} +#else /* !def NOLOAD */ int init_logo(const char *fname) { FILE *fp; @@ -91,6 +100,7 @@ int init_logo(const char *fname) return 0; } +#endif /* NOLOAD */ static void eval_seg(float *res, int a, int b, float t) { diff --git a/src/logodata.h b/src/logodata.h new file mode 100644 index 0000000..c7938d4 --- /dev/null +++ b/src/logodata.h @@ -0,0 +1,28 @@ +#ifdef NOLOAD + +static cgm_vec2 logocp[] = { + {0.770551, -0.12}, {0.770551, -0.12}, {0.770551, -0.12}, {0.464919, -0.423409}, + {0.157055, -0.7461}, {0.000942409, -0.760054}, {-0.156914, -0.742611}, {-0.460417, -0.424282}, + {-0.736884, -0.163513}, {-0.761304, -0.000423729}, {-0.734268, 0.167898}, + {-0.442102, 0.441749}, {-0.17959, 0.726937}, {7.04117e-05, 0.762695}, {0.184963, 0.724321}, + {0.403869, 0.483612}, {0.758539, 0.124617}, {0.758539, 0.124617}, {0.758539, 0.124617}, + {0.586597, 0.120587}, {0.586597, 0.120587}, {0.586597, 0.120587}, {0.3118, 0.392285}, + {0.102777, 0.620188}, {0.000962065, 0.630302}, {-0.0947842, 0.622211}, {-0.353704, 0.344412}, + {-0.616669, 0.104372}, {-0.630828, -0.000814512}, {-0.611275, -0.11544}, + {-0.361121, -0.341995}, {-0.0974812, -0.61912}, {0.000287853, -0.634628}, + {0.0987312, -0.622491}, {0.320566, -0.385148}, {0.578731, -0.12}, {0.578731, -0.12}, + {0.578731, -0.12}, {0.410366, -0.12}, {0.410366, -0.12}, {0.410366, -0.12}, + {0.221153, -0.305467}, {0.0576008, -0.481569}, {-0.00106066, -0.497751}, + {-0.0603964, -0.477523}, {-0.270768, -0.252317}, {-0.479118, -0.0567789}, + {-0.491929, 0.000533998}, {-0.479792, 0.0558241}, {-0.27414, 0.245968}, + {-0.0543279, 0.476568}, {0.000287883, 0.493425}, {0.0522066, 0.47994}, {0.195152, 0.330252}, + {0.397571, 0.12191}, {0.397571, 0.12191}, {0.397571, 0.12191}, {0.228891, 0.12}, + {0.228891, 0.12}, {0.228891, 0.12}, {0.133119, 0.210906}, {0.0366984, 0.310024}, + {0.000287898, 0.329578}, {-0.032077, 0.314069}, {-0.177045, 0.161684}, {-0.31055, 0.0369445}, + {-0.327407, -0.000140294}, {-0.308528, -0.0399222}, {-0.172999, -0.170056}, + {-0.0334256, -0.312327}, {0.000287853, -0.325812}, {0.0353499, -0.315024}, + {0.108845, -0.236809}, {0.227761, -0.12}, {0.227761, -0.12}, {0.227761, -0.12} +}; +#define LOGO_NUM_CP (sizeof logocp / sizeof *logocp) + +#endif diff --git a/src/main.c b/src/main.c index 23b9878..ad6c66e 100644 --- a/src/main.c +++ b/src/main.c @@ -103,8 +103,8 @@ static void draw_line(float x0, float y0, float x1, float y1, float rad) rx = rad * dy / len; ry = -rad * dx / len; - draw_disc(x0, y0, rad, 8); - draw_disc(x1, y1, rad, 8); + draw_disc(x0, y0, rad, 12); + draw_disc(x1, y1, rad, 12); glBegin(GL_QUADS); glVertex2f(x0 + rx, y0 + ry); @@ -114,7 +114,7 @@ static void draw_line(float x0, float y0, float x1, float y1, float rad) glEnd(); } -#define LOOPTIME 1.3f +#define LOOPTIME 1.45f void display(void) { @@ -129,7 +129,7 @@ void display(void) glLineWidth(5.0); anim = fmod(t / 6.0f, LOOPTIME); - alpha = 1.0f - ((anim - (LOOPTIME - 0.2)) / 0.2f); + alpha = 1.0f - ((anim - (LOOPTIME - 0.075)) / 0.06f); if(alpha < 0.0f) alpha = 0.0f; if(alpha > 1.0f) alpha = 1.0f; @@ -146,18 +146,18 @@ void display(void) if(anim > 0.0f) { eval_logo(a, 0); - draw_disc(a[0], a[1], 0.05, 18); + draw_disc(a[0], a[1], 0.05, 22); } if(anim >= 1.0f) { eval_logo(b, 1); - draw_disc(b[0], b[1], 0.05, 18); + draw_disc(b[0], b[1], 0.05, 22); } glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.8, 0, 0, 2.0 * (anim - 1.0f) / (LOOPTIME - 1.0f)); - draw_disc(0, 0, 0.14, 24); + draw_disc(0, 0, 0.14, 30); if(alpha < 1.0f) { glBegin(GL_QUADS);