diff --git a/checkin_notes b/checkin_notes index d5fa982d38..1edcbad1c1 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1277,3 +1277,8 @@ David 5 Feb 2009 cs_scheduler.cpp cs_statefile.cpp +David 5 Feb 2009 + - screensaver: flesh out new SS a bit + + clientscr/ + ss_app.cpp diff --git a/client/sim.h b/client/sim.h index fa7a1e589a..117ae7fa80 100644 --- a/client/sim.h +++ b/client/sim.h @@ -307,3 +307,5 @@ extern bool work_fetch_old; #define CPU_PESSIMISM_FACTOR 0.9 // assume actual CPU utilization will be this multiple // of what we've actually measured recently + +#define WORK_FETCH_PERIOD 60 \ No newline at end of file diff --git a/clientscr/screensaver_opengl.h b/clientscr/screensaver_opengl.h deleted file mode 100644 index 8b3927c861..0000000000 --- a/clientscr/screensaver_opengl.h +++ /dev/null @@ -1,29 +0,0 @@ -// This file is part of BOINC. -// http://boinc.berkeley.edu -// Copyright (C) 2008 University of California -// -// BOINC is free software; you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// BOINC is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with BOINC. If not, see . - -#include "boinc_api.h" - -struct UC_SHMEM { - double update_time; - double fraction_done; - double cpu_time; - BOINC_STATUS status; - int countdown; - // graphics app sets this to 5 repeatedly, - // main program decrements it once/sec. - // If it's zero, don't bother updating shmem -}; diff --git a/clientscr/ss_app.cpp b/clientscr/ss_app.cpp index 489a25b146..3140d64005 100644 --- a/clientscr/ss_app.cpp +++ b/clientscr/ss_app.cpp @@ -28,33 +28,53 @@ #else #include #endif +#include +#include #include "diagnostics.h" -#include "parse.h" -#include "util.h" #include "gutil.h" #include "boinc_gl.h" -#include "app_ipc.h" -#include "boinc_api.h" #include "graphics2.h" #include "txf_util.h" -#include "screensaver_opengl.h" +#include "network.h" +#include "gui_rpc_client.h" +#include "app_ipc.h" #ifdef __APPLE__ #include "mac_app_icon.h" #endif +using std::string; +using std::vector; + float white[4] = {1., 1., 1., 1.}; TEXTURE_DESC logo; int width, height; // window dimensions -APP_INIT_DATA uc_aid; bool mouse_down = false; int mouse_x, mouse_y; double pitch_angle, roll_angle, viewpoint_distance=10; float color[4] = {.7, .2, .5, 1}; // the color of the 3D object. // Can be changed using preferences -UC_SHMEM* shmem = NULL; + +RPC_CLIENT rpc; +CC_STATE cc_state; + +struct APP_SLIDES { + string name; + int index; + double switch_time; + vector slides; + APP_SLIDES(string n): name(n), index(0), switch_time(0) {} +}; + +struct PROJECT_IMAGES { + string url; + TEXTURE_DESC icon; + vector app_slides; +}; + +vector project_images; // set up lighting model // @@ -75,56 +95,120 @@ static void draw_logo() { } } -static void draw_text() { - static float x=0, y=0; - static float dx=0.0003, dy=0.0007; - char buf[256]; - x += dx; - y += dy; - if (x < 0 || x > .5) dx *= -1; - if (y < 0 || y > .5) dy *= -1; - double fd = 0, cpu=0, dt; - if (shmem) { - fd = shmem->fraction_done; - cpu = shmem->cpu_time; - } - sprintf(buf, "User: %s", uc_aid.user_name); - txf_render_string(.1, x, y, 0, 500, white, 0, buf); - sprintf(buf, "Team: %s", uc_aid.team_name); - txf_render_string(.1, x, y+.1, 0, 500, white, 0, buf); - sprintf(buf, "%% Done: %f", 100*fd); - txf_render_string(.1, x, y+.2, 0, 500, white, 0, buf); - sprintf(buf, "CPU time: %f", cpu); - txf_render_string(.1, x, y+.3, 0, 500, white, 0, buf); - if (shmem) { - dt = dtime() - shmem->update_time; - if (dt > 10) { - boinc_close_window_and_quit("shmem not updated"); - } else if (dt > 5) { - txf_render_string(.1, 0, 0, 0, 500, white, 0, "App not running - exiting in 5 seconds"); - } else if (shmem->status.suspended) { - txf_render_string(.1, 0, 0, 0, 500, white, 0, "App suspended"); - } - } else { - txf_render_string(.1, 0, 0, 0, 500, white, 0, "No shared mem"); +void icon_path(PROJECT* p, char* buf) { + char dir[256]; + url_to_project_dir((char*)p->master_url.c_str(), dir); + sprintf(buf, "%s/stat_icon", dir); +} + +void slideshow(PROJECT* p) { + char dir[256], buf[256]; + int i; + + url_to_project_dir((char*)p->master_url.c_str(), dir); + for (i=0; i<99; i++) { + sprintf(buf, "%s/slideshow_%02d", dir, i); } } -static void draw_3d_stuff() { - static float x=0, y=0, z=10; - static float dx=0.3, dy=0.2, dz=0.5; - x += dx; - y += dy; - z += dz; - if (x < -15 || x > 15) dx *= -1; - if (y < -15 || y > 15) dy *= -1; - if (z < 0 || z > 40) dz *= -1; - float pos[3]; - pos[0] = x; - pos[1] = y; - pos[2] = z; - drawSphere(pos, 4); - drawCylinder(false, pos, 6, 6); +PROJECT_IMAGES* get_project_images(PROJECT* p) { + unsigned int i; + char dir[256], path[256], filename[256]; + + for (i=0; imaster_url) return π + } + PROJECT_IMAGES pim; + pim.url = p->master_url; + url_to_project_dir((char*)p->master_url.c_str(), dir); + sprintf(path, "%s/stat_icon", dir); + boinc_resolve_filename(path, filename, 256); + pim.icon.load_image_file(filename); + for (i=0; iapp->user_friendly_name.c_str()); + y -= 3; + progress.init(prog_pos, 10., 1., 0.8, prog_c, prog_ci); + progress.draw(r->fraction_done); + mode_unshaded(); + sprintf(buf, "%.2f%%", r->fraction_done*100); + txf_render_string(.1, x+15, y, 0, 8., white, 0, buf); + y -= 3; +} + +void show_coords() { + int i; + char buf[256]; + for (i=-100; i< 101; i+=5) { + sprintf(buf, "%d", i); + float x = (float)i; + txf_render_string(.1, x, 0, 0, 10., white, 0, buf); + } + for (i=-100; i< 101; i+=5) { + sprintf(buf, "%d", i); + float y = (float)i; + txf_render_string(.1, 0, y, 0, 10., white, 0, buf); + } +} +void show_project(PROJECT* p, float x, float& y) { + unsigned int i; + PROJECT_IMAGES* pim = get_project_images(p); + txf_render_string(.1, x, y, 0, 5., white, 0, (char*)p->project_name.c_str()); + if (pim->icon.present) { + float pos[3] = {x, y, 1}; + float size[2] = {3., 3.}; + pim->icon.draw(pos, size, 0, 0); + } + y -= 3; + for (i=0; iproject != p) continue; + if (!r->active_task) continue; + if (r->active_task_state != PROCESS_EXECUTING) continue; + show_result(r, x, y); + } +} + +void show_projects() { + char buf[256]; + float x=-45, y=30; + unsigned int i; + for (i=0; icountdown = 5; +void app_graphics_render(int xs, int ys, double t) { + int retval = update_data(t); + if (retval) { + boinc_close_window_and_quit("RPC failed"); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -181,15 +258,15 @@ void app_graphics_render(int xs, int ys, double time_of_day) { // init_camera(viewpoint_distance); scale_screen(width, height); - mode_shaded(color); - draw_3d_stuff(); + //mode_shaded(color); // draw text on top // - mode_unshaded(); - mode_ortho(); - draw_text(); - ortho_done(); + //mode_unshaded(); + //mode_ortho(); + show_projects(); + show_coords(); + //ortho_done(); } void app_graphics_resize(int w, int h){ @@ -232,59 +309,27 @@ void boinc_app_key_press(int, int){} void boinc_app_key_release(int, int){} void app_graphics_init() { - char path[256]; - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - txf_load_fonts("."); - - boinc_resolve_filename("logo.jpg", path, sizeof(path)); - logo.load_image_file(path); - + logo.load_image_file("boinc_logo_black.jpg"); init_lights(); } -static void parse_project_prefs(char* buf) { - char cs[256]; - COLOR c; - double hue; - double max_frames_sec, max_gfx_cpu_pct; - if (!buf) return; - if (parse_str(buf, "", cs, 256)) { - if (!strcmp(cs, "Tahiti Sunset")) { - hue = .9; - } else if (!strcmp(cs, "Desert Sands")) { - hue = .1; - } else { - hue = .5; - } - HLStoRGB(hue, .5, .5, c); - color[0] = c.r; - color[1] = c.g; - color[2] = c.b; - color[3] = 1; - } - if (parse_double(buf, "", max_frames_sec)) { - boinc_max_fps = max_frames_sec; - } - if (parse_double(buf, "", max_gfx_cpu_pct)) { - boinc_max_gfx_cpu_frac = max_gfx_cpu_pct/100; - } -} - int main(int argc, char** argv) { - boinc_init_graphics_diagnostics(BOINC_DIAG_DEFAULTS); + int retval; + +#ifdef _WIN32 + WinsockInitialize(); +#endif + retval = rpc.init("localhost"); + if (retval) exit(retval); #ifdef __APPLE__ setMacIcon(argv[0], MacAppIconData, sizeof(MacAppIconData)); #endif - - boinc_parse_init_data_file(); - boinc_get_init_data(uc_aid); - if (uc_aid.project_preferences) { - parse_project_prefs(uc_aid.project_preferences); - } boinc_graphics_loop(argc, argv); - boinc_finish_diag(); +#ifdef _WIN32 + WinsockCleanup(); +#endif } diff --git a/doc/logo/boinc_logo_black.jpg b/doc/logo/boinc_logo_black.jpg new file mode 100644 index 0000000000..64fb6b4539 Binary files /dev/null and b/doc/logo/boinc_logo_black.jpg differ diff --git a/win_build/ss_app.vcproj b/win_build/ss_app.vcproj index 432bf4969c..828efc9a56 100644 --- a/win_build/ss_app.vcproj +++ b/win_build/ss_app.vcproj @@ -81,7 +81,7 @@ /> + + + +