From 58adfcfcd0420a9c2fc6be80c441f9713fe6022c Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 14 Dec 2017 16:52:58 -0500 Subject: [PATCH] gr-sim: add starfield demo --- gr-sim/Makefile | 12 ++++++++-- gr-sim/starfield.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 gr-sim/starfield.c diff --git a/gr-sim/Makefile b/gr-sim/Makefile index 466becbe..5c93bd86 100644 --- a/gr-sim/Makefile +++ b/gr-sim/Makefile @@ -5,7 +5,7 @@ LFLAGS = -lm SDL_LIBS= `sdl-config --libs` SDL_INCLUDE= `sdl-config --cflags` -all: fixed_point rainbow sparkle kaleido tfv mode7_demo text tfv_multiply +all: fixed_point rainbow sparkle starfield kaleido tfv mode7_demo text tfv_multiply @@ -144,10 +144,18 @@ sparkle.o: sparkle.c $(CC) $(CFLAGS) -c sparkle.c +starfield: starfield.o gr-sim.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o starfield starfield.o gr-sim.o + +starfield.o: starfield.c + $(CC) $(CFLAGS) -c starfield.c + + gr-sim.o: gr-sim.c gr-sim.h apple2_font.h $(CC) $(CFLAGS) $(SDL_INCLUDE) -c gr-sim.c clean: - rm -f *~ *.o gr-sim rainbow sparkle kaleido tfv text mode7_demo fixed_point tfv_multiply + rm -f *~ *.o gr-sim rainbow sparkle starfield kaleido \ + tfv text mode7_demo fixed_point tfv_multiply diff --git a/gr-sim/starfield.c b/gr-sim/starfield.c new file mode 100644 index 00000000..76d35710 --- /dev/null +++ b/gr-sim/starfield.c @@ -0,0 +1,60 @@ +#include +#include +#include + +#include "gr-sim.h" + +#define NUMSTARS 64 + +struct star_type { + double x; + double y; + double z; +}; + +static struct star_type stars[NUMSTARS]; + +int main(int argc, char **argv) { + + int ch,i; + + int spreadx=40; + int spready=40; + int spreadz=5; + + grsim_init(); + + for(i=0;i