From 84ce7bf1368f6ff7409b0fac862f7d3b1c3a755c Mon Sep 17 00:00:00 2001 From: EugeneBrace Date: Mon, 29 Nov 2021 12:03:52 +0100 Subject: [PATCH] Memory management --- drop_billiard.c | 4 ++-- particle_billiard.c | 15 +++++++++------ sub_part_billiard.c | 17 ++++++++++------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/drop_billiard.c b/drop_billiard.c index 6aff75c..f0180f5 100644 --- a/drop_billiard.c +++ b/drop_billiard.c @@ -8,8 +8,8 @@ /* line to nils.berglund@univ-orleans.fr - Thanks! */ /* */ /* compile with */ -/* gcc -o drop_billiard drop_billiard.c */ -/* -O3 -L/usr/X11R6/lib -ltiff -lm -lGL -lGLU -lX11 -lXmu -lglut */ +/* gcc -o drop_billiard drop_billiard.c -L/usr/X11R6/lib -ltiff -lm -lGL -lGLU -lX11 -lXmu -lglut */ +/* gcc -o drop_billiard drop_billiard.c -O3 -L/usr/X11R6/lib -ltiff -lm -lGL -lGLU -lX11 -lXmu -lglut */ /* */ /* */ /* To make a video, set MOVIE to 1 and create subfolder tif_drop */ diff --git a/particle_billiard.c b/particle_billiard.c index a4cb77a..711dfad 100644 --- a/particle_billiard.c +++ b/particle_billiard.c @@ -30,10 +30,13 @@ #include #include /* Sam Leffler's libtiff library. */ -#define MOVIE 0 /* set to 1 to generate movie */ +#define MOVIE 1 /* set to 1 to generate movie */ -#define WINWIDTH 1280 /* window width */ -#define WINHEIGHT 720 /* window height */ +// #define WINWIDTH 1280 /* window width */ +// #define WINHEIGHT 720 /* window height */ + +#define WINWIDTH 1920 /* window width */ +#define WINHEIGHT 1080 /* window height */ #define XMIN -2.0 #define XMAX 2.0 /* x interval */ @@ -87,10 +90,10 @@ #define PRINT_PARTICLE_NUMBER 0 /* set to 1 to print number of particles */ #define TEST_ACTIVE 1 /* set to 1 to test whether particle is in billiard */ -#define NSTEPS 1000 /* number of frames of movie */ -#define TIME 1500 /* time between movie frames, for fluidity of real-time simulation */ +#define NSTEPS 5000 /* number of frames of movie */ +#define TIME 400 /* time between movie frames, for fluidity of real-time simulation */ // #define DPHI 0.00001 /* integration step */ -#define DPHI 0.000005 /* integration step */ +#define DPHI 0.00005 /* integration step */ #define NVID 150 /* number of iterations between images displayed on screen */ /* Decreasing TIME accelerates the animation and the movie */ diff --git a/sub_part_billiard.c b/sub_part_billiard.c index dc1ce36..076878b 100644 --- a/sub_part_billiard.c +++ b/sub_part_billiard.c @@ -109,7 +109,8 @@ int writetiff(char *filename, char *description, int x, int y, int width, int he TIFFSetField(file, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(file, TIFFTAG_IMAGEDESCRIPTION, description); p = image; - for (i = height - 1; i >= 0; i--) +// for (i = height - 1; i >= 0; i--) + for (i = height - 1; i >= 0; i--) // _eux { // if (TIFFWriteScanline(file, p, height - i - 1, 0) < 0) if (TIFFWriteScanline(file, p, i, 0) < 0) @@ -120,6 +121,7 @@ int writetiff(char *filename, char *description, int x, int y, int width, int he } p += width * sizeof(GLubyte) * 3; } + free(image); /* _Michale_eux*/ TIFFClose(file); return 0; } @@ -190,13 +192,14 @@ void save_frame() strcat(n2, ".tif"); printf(" saving frame %s \n",n2); - // mod by eux - chose one of the following according to the comment beside. - writetiff(n2, "Billiard in an ellipse", 0, 0, WINWIDTH, WINHEIGHT-40, COMPRESSION_LZW); /* to use with 1080p in drop_billiard.c- probably the best because it's - generating 1080p image, lighter, and then cropping those 40 pixels to - avoid the strange band*/ - // writetiff(n2, "Billiard in an ellipse", 0, 0, WINWIDTH, WINHEIGHT-50, COMPRESSION_LZW); //works for 1080p -> "-50px" band!!! - // writetiff(n2, "Billiard in an ellipse", 0, 0, 1920, 1080-40, COMPRESSION_LZW); //another perfect 1080p from 1440p in setup + // mod by _eux - chose one of the following according to the comment beside. + // writetiff(n2, "Billiard in an ellipse", 0, 0, WINWIDTH, WINHEIGHT-40, COMPRESSION_LZW); /* to use with 1080p in drop_billiard.c- probably the best because it's + // generating 1080p image, lighter, and then cropping those 40 pixels to + // avoid the strange band*/ + // writetiff(n2, "Billiard in an ellipse", 0, 0, WINWIDTH, WINHEIGHT-50, COMPRESSION_LZW); // works for 1080p -> "-50px" band!!! + // writetiff(n2, "Billiard in an ellipse", 0, 0, 1920, 1080-40, COMPRESSION_LZW); //another perfect 1080p from 1440p in setup // writetiff(n2, "Billiard in an ellipse", -WINWIDTH/8+320, -WINHEIGHT/8+180, WINWIDTH-640, WINHEIGHT-400, COMPRESSION_LZW); // perfect 1040p from 1440p in setup + writetiff(n2, "Billiard in an ellipse", 0, 0, WINWIDTH, WINHEIGHT-40, COMPRESSION_LZW); // _Michael_eux } void write_text_fixedwidth( double x, double y, char *st)