From cae16bcc2dec4c67ad8dca748406f123a7163e19 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Wed, 11 Sep 2002 21:41:42 +0000 Subject: [PATCH] Core to app graphics interface svn path=/trunk/boinc/; revision=413 --- api/graphics_api.C | 17 ++++++++++++----- api/graphics_api.h | 8 ++++++++ client/Makefile.in | 3 ++- client/app.C | 22 ++++++++++++++++++---- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/api/graphics_api.C b/api/graphics_api.C index 807195107a..7496b127a3 100755 --- a/api/graphics_api.C +++ b/api/graphics_api.C @@ -2,23 +2,30 @@ #include "parse.h" -void write_graphics_file(FILE* f, GRAPHICS_INFO& gi) { +int write_graphics_file(FILE* f, GRAPHICS_INFO& gi) { fprintf(f, - "%d\n" - "%d\n" - "%f\n", + "\n" + " %d\n" + " %d\n" + " %d\n" + " %f\n" + "\n", gi.xsize, gi.ysize, + gi.graphics_mode, gi.refresh_period ); + + return 0; } int parse_graphics_file(FILE* f, GRAPHICS_INFO& gi) { char buf[256]; while (fgets(buf, 256, f)) { - if (match_tag(buf, "")) return 0; + if (match_tag(buf, "")) return 0; else if (parse_int(buf, "", gi.xsize)) continue; else if (parse_int(buf, "", gi.ysize)) continue; + else if (parse_int(buf, "", gi.graphics_mode)) continue; else if (parse_double(buf, "", gi.refresh_period)) continue; else fprintf(stderr, "parse_core_file: unrecognized %s", buf); } diff --git a/api/graphics_api.h b/api/graphics_api.h index 85766c505b..b8d143daa2 100755 --- a/api/graphics_api.h +++ b/api/graphics_api.h @@ -1,10 +1,18 @@ #include +#define MODE_NO_GRAPHICS -1 +#define MODE_WINDOW 0 +#define MODE_FULLSCREEN 1 + struct GRAPHICS_INFO { int xsize; int ysize; + int graphics_mode; double refresh_period; }; struct APP_OUT_GRAPHICS { }; + +int write_graphics_file(FILE* f, GRAPHICS_INFO& gi); +int parse_graphics_file(FILE* f, GRAPHICS_INFO& gi); diff --git a/client/Makefile.in b/client/Makefile.in index 1d126a0faa..c534bede98 100644 --- a/client/Makefile.in +++ b/client/Makefile.in @@ -53,7 +53,8 @@ OBJS = \ ../lib/crypt.o \ ../lib/util.o \ ../RSAEuro/source/rsaeuro.a \ - ../api/boinc_api.o + ../api/boinc_api.o \ + ../api/graphics_api.o TEST_NET_XFER_OBJS = \ http.o \ diff --git a/client/app.C b/client/app.C index a1636f9e1d..546b782d16 100644 --- a/client/app.C +++ b/client/app.C @@ -68,6 +68,7 @@ #include "app.h" #include "boinc_api.h" +#include "graphics_api.h" // take a string containing some space separated words. // return an array of pointers to the null-terminated words. @@ -137,9 +138,10 @@ int ACTIVE_TASK::start(bool first_time) { FILE_REF file_ref; FILE_INFO* fip; int retval; - char init_data_path[256], fd_init_path[256]; + char init_data_path[256], graphics_data_path[256], fd_init_path[256]; FILE *f; APP_INIT_DATA aid; + GRAPHICS_INFO gi; if (first_time) { checkpoint_cpu_time = 0; @@ -148,9 +150,10 @@ int ACTIVE_TASK::start(bool first_time) { starting_cpu_time = checkpoint_cpu_time; fraction_done = 0; - //app_prefs.graphics.xsize = 640; - //app_prefs.graphics.ysize = 480; - //app_prefs.graphics.refresh_period = 5; + gi.xsize = 640; + gi.ysize = 480; + gi.graphics_mode = MODE_WINDOW; + gi.refresh_period = 0.1; memset(&aid, 0, sizeof(aid)); @@ -170,6 +173,17 @@ int ACTIVE_TASK::start(bool first_time) { retval = write_init_data_file(f, aid); fclose(f); + sprintf(graphics_data_path, "%s%s%s", slot_dir, PATH_SEPARATOR, GRAPHICS_DATA_FILE); + f = fopen(graphics_data_path, "w"); + if (!f) { + if (log_flags.task_debug) { + printf("Failed to open core to app graphics prefs file %s.\n", graphics_data_path); + } + return ERR_FOPEN; + } + retval = write_graphics_file(f, gi); + fclose(f); + sprintf(fd_init_path, "%s%s%s", slot_dir, PATH_SEPARATOR, FD_INIT_FILE); f = fopen(fd_init_path, "w"); if (!f) {