From fc0cfd2c7c9f5efddddb21fc94a15cc42685ca1d Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Tue, 27 Aug 2019 17:14:29 +0300 Subject: [PATCH] initial commit --- .gitignore | 4 ++ Makefile | 23 ++++++++++++ src/logo.h | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 253 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 src/logo.h create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d90c263 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.o +*.d +*.swp +censuslogo diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a1dc85b --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +src = $(wildcard src/*.c) +obj = $(src:.c=.o) +dep = $(obj:.o=.d) +bin = censuslogo + +CFLAGS = -pedantic -Wall -g +LDFLAGS = -lGL -lGLU -lglut -lm + +$(bin): $(obj) + $(CC) -o $@ $(obj) $(LDFLAGS) + +-include $(dep) + +%.d: %.c + @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ + +.PHONY: clean +clean: + rm -f $(obj) $(bin) + +.PHONY: cleandep +cleandep: + rm -f $(dep) diff --git a/src/logo.h b/src/logo.h new file mode 100644 index 0000000..c483f0c --- /dev/null +++ b/src/logo.h @@ -0,0 +1,106 @@ +#ifndef LOGO_H_ +#define LOGO_H_ + +#define LOGO_W 90 +#define LOGO_H 85 + +static const float logocp[][2] = { + {85, 48}, + {68.5, 64.5}, + {68.5, 64.5}, + {52, 81}, + + {52, 81}, + {43, 89}, + {43, 89}, + {34, 81}, + + {34, 81}, + {18.5, 66}, + {18.5, 66}, + {3, 51}, + + {3, 51}, + {-5, 41.5}, + {-5, 41.5}, + {4, 32}, + + {4, 32}, + {19, 17}, + {19, 17}, + {33, 3}, + + {33, 3}, + {42, -5}, + {42, -5}, + {52, 3}, + + {52, 3}, + {68, 19}, + {68, 19}, + {85, 35}, + + {85, 35}, + {75, 35}, + {85, 35}, + {75, 35}, + + {75, 35}, + {62, 22}, + {62, 22}, + {49, 10}, + + {49, 10}, + {42, 4}, + {42, 4}, + {36, 10}, + + {36, 10}, + {23, 22}, + {23, 22}, + {11, 35}, + + {11, 35}, + {5, 42}, + {5, 42}, + {11, 49}, + + {11, 49}, + {23, 61}, + {23, 61}, + {36, 74}, + + {36, 74}, + {42, 79}, + {42, 79}, + {49, 74}, + + {49, 74}, + {62, 61}, + {62, 61}, + {75, 48}, + + {75, 48}, + {65, 48}, + {75, 48}, + {65, 48}, + + {65, 48}, + {55.5, 57.5}, + {55.5, 57.5}, + {46, 67}, + + {46, 67}, + {42.5, 70}, + {42.5, 70}, + {39, 67}, + + {39, 67}, + {28, 56}, + {28, 56}, + {17, 45}, +}; + +#define LOGOCP_SIZE (sizeof logocp / sizeof *logocp) + +#endif /* LOGO_H_ */ diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..06477c1 --- /dev/null +++ b/src/main.c @@ -0,0 +1,120 @@ +#include +#include +#include +#include +#include "logo.h" + +#define BEZ_SEG 16 + +int init(void); +void display(void); +void reshape(int x, int y); +void keyb(unsigned char key, int x, int y); + +void draw_bezier(float *cp, int sub); + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitWindowSize(800, 600); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); + glutCreateWindow("census"); + + glutDisplayFunc(display); + glutReshapeFunc(reshape); + glutKeyboardFunc(keyb); + + if(init() == -1) { + return 1; + } + + glutMainLoop(); + return 0; +} + +int init(void) +{ + glEnable(GL_LINE_SMOOTH); + return 0; +} + +void display(void) +{ + int i, nseg; + + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glLineWidth(2.0); + + glColor3f(1, 1, 1); + nseg = LOGOCP_SIZE / 4; + for(i=0; i