mirror of https://github.com/BOINC/boinc.git
Core to app graphics interface
svn path=/trunk/boinc/; revision=413
This commit is contained in:
parent
211bf65240
commit
cae16bcc2d
|
@ -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,
|
||||
"<graphics_xsize>%d</graphics_xsize>\n"
|
||||
"<graphics_ysize>%d</graphics_ysize>\n"
|
||||
"<graphics_refresh_period>%f</graphics_refresh_period>\n",
|
||||
"<graphics_info>\n"
|
||||
" <graphics_xsize>%d</graphics_xsize>\n"
|
||||
" <graphics_ysize>%d</graphics_ysize>\n"
|
||||
" <graphics_mode>%d</graphics_mode>\n"
|
||||
" <graphics_refresh_period>%f</graphics_refresh_period>\n"
|
||||
"</graphics_info>\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, "<graphics_info>")) return 0;
|
||||
if (match_tag(buf, "</graphics_info>")) return 0;
|
||||
else if (parse_int(buf, "<graphics_xsize>", gi.xsize)) continue;
|
||||
else if (parse_int(buf, "<graphics_ysize>", gi.ysize)) continue;
|
||||
else if (parse_int(buf, "<graphics_mode>", gi.graphics_mode)) continue;
|
||||
else if (parse_double(buf, "<graphics_refresh_period>", gi.refresh_period)) continue;
|
||||
else fprintf(stderr, "parse_core_file: unrecognized %s", buf);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#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);
|
||||
|
|
|
@ -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 \
|
||||
|
|
22
client/app.C
22
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) {
|
||||
|
|
Loading…
Reference in New Issue