2009-02-06 02:17:45 +00:00
|
|
|
// 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
2009-09-25 17:39:50 +00:00
|
|
|
// Default screensaver.
|
|
|
|
// Shows the BOINC logo and a rotating display of
|
|
|
|
// attached projects and jobs in progress
|
2009-02-06 02:17:45 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include "boinc_win.h"
|
|
|
|
#else
|
2013-05-27 23:44:22 +00:00
|
|
|
#include <cmath>
|
2009-02-06 02:17:45 +00:00
|
|
|
#endif
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#ifdef __APPLE__
|
|
|
|
#include "boinc_api.h"
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
|
|
|
|
2012-08-03 01:18:20 +00:00
|
|
|
#include "boinc_gl.h"
|
|
|
|
|
2009-02-06 02:17:45 +00:00
|
|
|
#include "diagnostics.h"
|
2012-08-02 06:53:11 +00:00
|
|
|
#include "ttfont.h"
|
2009-02-06 02:17:45 +00:00
|
|
|
#include "gutil.h"
|
|
|
|
#include "graphics2.h"
|
|
|
|
#include "network.h"
|
|
|
|
#include "gui_rpc_client.h"
|
2009-02-11 00:46:57 +00:00
|
|
|
#include "util.h"
|
2009-02-06 02:17:45 +00:00
|
|
|
#include "app_ipc.h"
|
2009-02-20 11:49:49 +00:00
|
|
|
#include "error_numbers.h"
|
2009-02-06 02:17:45 +00:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
2012-08-02 06:53:11 +00:00
|
|
|
using TTFont::ttf_render_string;
|
|
|
|
using TTFont::ttf_load_fonts;
|
2009-02-06 02:17:45 +00:00
|
|
|
|
2010-02-16 20:10:13 +00:00
|
|
|
// text sizes - larger is smaller (???)
|
2012-08-02 06:53:11 +00:00
|
|
|
#define TASK_INTRO_SIZE 1200.
|
|
|
|
#define TASK_NONE_SIZE 600.
|
2010-02-16 20:10:13 +00:00
|
|
|
#define TASK_NONE_REASON_SIZE 800.
|
2012-08-02 06:53:11 +00:00
|
|
|
#define TASK_PROJ_SIZE 1200.
|
|
|
|
#define TASK_INFO_SIZE 1350.
|
|
|
|
#define PROJ_INTRO_SIZE 900.
|
|
|
|
#define PROJ_NAME_SIZE 600.
|
|
|
|
#define PROJ_INFO_SIZE 900.
|
|
|
|
#define ALERT_SIZE 900.
|
2010-02-16 20:10:13 +00:00
|
|
|
|
2009-02-06 02:17:45 +00:00
|
|
|
float white[4] = {1., 1., 1., 1.};
|
|
|
|
TEXTURE_DESC logo;
|
|
|
|
int width, height; // window dimensions
|
|
|
|
bool mouse_down = false;
|
|
|
|
int mouse_x, mouse_y;
|
|
|
|
|
|
|
|
RPC_CLIENT rpc;
|
2009-02-26 23:32:29 +00:00
|
|
|
bool retry_connect = true;
|
2009-02-19 00:29:12 +00:00
|
|
|
bool connected = false;
|
2009-02-20 02:33:11 +00:00
|
|
|
double next_connect_time = 0.0;
|
2009-02-19 00:29:12 +00:00
|
|
|
|
2009-02-06 02:17:45 +00:00
|
|
|
CC_STATE cc_state;
|
2009-02-11 16:33:08 +00:00
|
|
|
CC_STATUS cc_status;
|
2009-02-06 02:17:45 +00:00
|
|
|
|
2011-11-26 10:56:56 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
// Possible values of brandId (determined at run time on Mac):
|
|
|
|
#define BOINC_BRAND_ID 0
|
|
|
|
#define GRIDREPUBLIC_BRAND_ID 1
|
|
|
|
#define PROGRESSTHRUPROCESSORS_BRAND_ID 2
|
|
|
|
#define CHARITYENGINE_BRAND_ID 3
|
|
|
|
|
|
|
|
char* brand_name = "BOINC";
|
|
|
|
char* logo_file = "boinc_logo_black.jpg";
|
|
|
|
# else
|
|
|
|
// These defines are used only on Windows builds
|
2014-03-20 20:32:32 +00:00
|
|
|
#if defined(_GRIDREPUBLIC)
|
2011-11-25 07:24:18 +00:00
|
|
|
const char* brand_name = "GridRepublic";
|
|
|
|
const char* logo_file = "gridrepublic_ss_logo.jpg";
|
2011-08-09 00:38:30 +00:00
|
|
|
#elif defined(_CHARITYENGINE)
|
2011-11-25 07:24:18 +00:00
|
|
|
const char* brand_name = "Charity Engine";
|
2011-11-26 10:56:56 +00:00
|
|
|
const char* logo_file = "CE_ss_logo.jpg";
|
2014-03-20 20:32:32 +00:00
|
|
|
#elif defined(_PROGRESSTHRUPROCESSORS)
|
|
|
|
const char* brand_name = "Progress Thru Processors";
|
|
|
|
const char* logo_file = "progress_ss_logo.jpg";
|
|
|
|
#elif defined(_WCG)
|
|
|
|
const char* brand_name = "World Community Grid";
|
|
|
|
const char* logo_file = "wcg_ss_logo.jpg";
|
2010-02-02 12:19:01 +00:00
|
|
|
#else
|
2011-11-25 07:24:18 +00:00
|
|
|
const char* brand_name = "BOINC";
|
|
|
|
const char* logo_file = "boinc_logo_black.jpg";
|
2010-02-02 12:19:01 +00:00
|
|
|
#endif
|
2011-11-26 10:56:56 +00:00
|
|
|
#endif
|
2010-02-02 12:19:01 +00:00
|
|
|
|
2009-02-11 16:33:08 +00:00
|
|
|
#if 0
|
2009-02-06 02:17:45 +00:00
|
|
|
struct APP_SLIDES {
|
|
|
|
string name;
|
|
|
|
int index;
|
|
|
|
double switch_time;
|
|
|
|
vector<TEXTURE_DESC> slides;
|
|
|
|
APP_SLIDES(string n): name(n), index(0), switch_time(0) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PROJECT_IMAGES {
|
|
|
|
string url;
|
|
|
|
TEXTURE_DESC icon;
|
|
|
|
vector<APP_SLIDES> app_slides;
|
|
|
|
};
|
|
|
|
|
|
|
|
vector<PROJECT_IMAGES> project_images;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PROJECT_IMAGES* get_project_images(PROJECT* p) {
|
|
|
|
unsigned int i;
|
|
|
|
char dir[256], path[256], filename[256];
|
|
|
|
|
|
|
|
for (i=0; i<project_images.size(); i++) {
|
|
|
|
PROJECT_IMAGES& pi = project_images[i];
|
|
|
|
if (pi.url == p->master_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; i<cc_state.apps.size(); i++) {
|
|
|
|
APP& app = *cc_state.apps[i];
|
|
|
|
if (app.project != p) continue;
|
|
|
|
APP_SLIDES as(app.name);
|
|
|
|
for (int j=0; j<99; j++) {
|
|
|
|
sprintf(path, "%s/slideshow_%s_%02d", dir, app.name.c_str(), j);
|
|
|
|
boinc_resolve_filename(path, filename, 256);
|
|
|
|
TEXTURE_DESC td;
|
|
|
|
int retval = td.load_image_file(filename);
|
|
|
|
if (retval) break;
|
|
|
|
as.slides.push_back(td);
|
|
|
|
}
|
|
|
|
pim.app_slides.push_back(as);
|
|
|
|
}
|
|
|
|
project_images.push_back(pim);
|
2009-02-06 05:37:48 +00:00
|
|
|
return &(project_images.back());
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|
|
|
|
|
2009-02-11 16:33:08 +00:00
|
|
|
#endif
|
|
|
|
|
2014-03-20 20:32:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-02-11 16:33:08 +00:00
|
|
|
// set up lighting model
|
|
|
|
//
|
|
|
|
static void init_lights() {
|
|
|
|
GLfloat ambient[] = {1., 1., 1., 1.0};
|
|
|
|
GLfloat position[] = {-13.0, 6.0, 20.0, 1.0};
|
|
|
|
GLfloat dir[] = {-1, -.5, -3, 1.0};
|
|
|
|
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
|
|
|
|
glLightfv(GL_LIGHT0, GL_POSITION, position);
|
|
|
|
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_logo(float* pos, float alpha) {
|
|
|
|
if (logo.present) {
|
|
|
|
float size[3] = {.6, .4, 0};
|
|
|
|
logo.draw(pos, size, ALIGN_CENTER, ALIGN_CENTER, alpha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-10 19:30:59 +00:00
|
|
|
void show_result(RESULT* r, float x, float& y, float alpha) {
|
2009-02-11 00:46:57 +00:00
|
|
|
PROGRESS_2D progress;
|
2009-02-06 02:17:45 +00:00
|
|
|
char buf[256];
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, TASK_PROJ_SIZE, white, (char*)r->project->project_name.c_str());
|
2009-02-11 00:46:57 +00:00
|
|
|
y -= .02;
|
2009-02-06 02:17:45 +00:00
|
|
|
float prog_pos[] = {x, y, 0};
|
2009-02-10 19:30:59 +00:00
|
|
|
float prog_c[] = {.5, .4, .1, alpha/2};
|
|
|
|
float prog_ci[] = {.1, .8, .2, alpha};
|
2009-02-11 00:46:57 +00:00
|
|
|
progress.init(prog_pos, .4, -.01, -0.008, prog_c, prog_ci);
|
2009-02-06 02:17:45 +00:00
|
|
|
progress.draw(r->fraction_done);
|
2009-02-11 00:46:57 +00:00
|
|
|
sprintf(buf, "%.2f%% ", r->fraction_done*100);
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x+.41, y, 0, TASK_INFO_SIZE, white, buf);
|
2009-02-11 00:46:57 +00:00
|
|
|
y -= .03;
|
|
|
|
x += .05;
|
|
|
|
sprintf(buf, "Elapsed: %.0f sec Remaining: %.0f sec", r->elapsed_time, r->estimated_cpu_time_remaining);
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, TASK_INFO_SIZE, white, buf);
|
2009-02-11 00:46:57 +00:00
|
|
|
y -= .03;
|
2010-03-13 05:42:25 +00:00
|
|
|
sprintf(buf, "App: %s Task: %s", r->app->user_friendly_name, r->wup->name);
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, TASK_INFO_SIZE, white, buf);
|
2009-02-11 00:46:57 +00:00
|
|
|
y -= .03;
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|
|
|
|
|
2009-02-26 23:32:29 +00:00
|
|
|
#if 0
|
2009-02-06 02:17:45 +00:00
|
|
|
void show_coords() {
|
|
|
|
int i;
|
|
|
|
char buf[256];
|
|
|
|
for (i=-100; i< 101; i+=5) {
|
|
|
|
sprintf(buf, "%d", i);
|
2009-02-11 00:46:57 +00:00
|
|
|
float x = (float)i/100;
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, 0, 0, 1000., white, buf);
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|
|
|
|
for (i=-100; i< 101; i+=5) {
|
|
|
|
sprintf(buf, "%d", i);
|
2009-02-11 00:46:57 +00:00
|
|
|
float y = (float)i/100;
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(0, y, 0, 1000., white, buf);
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-26 23:32:29 +00:00
|
|
|
#endif
|
2009-02-10 19:30:59 +00:00
|
|
|
|
2009-02-11 16:33:08 +00:00
|
|
|
void show_project(unsigned int index, float alpha) {
|
2009-02-11 00:46:57 +00:00
|
|
|
float x=.2, y=.6;
|
|
|
|
char buf[1024];
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, PROJ_INTRO_SIZE, white, "This computer is participating in");
|
2009-02-11 00:46:57 +00:00
|
|
|
y -= .07;
|
|
|
|
PROJECT *p = cc_state.projects[index];
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, PROJ_NAME_SIZE, white, (char*)p->project_name.c_str());
|
2009-02-11 00:46:57 +00:00
|
|
|
y -= .07;
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, p->master_url);
|
2009-02-11 00:46:57 +00:00
|
|
|
y -= .05;
|
|
|
|
sprintf(buf, "User: %s", p->user_name.c_str());
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, buf);
|
2009-02-11 00:46:57 +00:00
|
|
|
y -= .05;
|
|
|
|
if (p->team_name.size()) {
|
|
|
|
sprintf(buf, "Team: %s", p->team_name.c_str());
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, buf);
|
2009-02-11 00:46:57 +00:00
|
|
|
y -= .05;
|
|
|
|
}
|
|
|
|
sprintf(buf, "Total credit: %.0f Average credit: %.0f", p->user_total_credit, p->user_expavg_credit);
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, buf);
|
2009-02-11 00:46:57 +00:00
|
|
|
y -= .05;
|
|
|
|
if (p->suspended_via_gui) {
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, "Suspended");
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|
2009-02-11 00:46:57 +00:00
|
|
|
}
|
|
|
|
|
2009-02-19 00:29:12 +00:00
|
|
|
void show_disconnected() {
|
2009-02-19 00:38:34 +00:00
|
|
|
float x=.3, y=.3;
|
2011-11-25 07:24:18 +00:00
|
|
|
char buf[256];
|
|
|
|
sprintf(buf, "%s is not running.", brand_name);
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, ALERT_SIZE, white, buf);
|
2009-02-26 23:32:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void show_no_projects() {
|
|
|
|
float x=.2, y=.3;
|
2011-11-25 07:24:18 +00:00
|
|
|
char buf[256];
|
|
|
|
sprintf(buf, "%s is not attached to any projects.", brand_name);
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, ALERT_SIZE, white, buf);
|
2009-02-26 23:32:29 +00:00
|
|
|
y = .25;
|
2011-11-25 07:24:18 +00:00
|
|
|
sprintf(buf, "Attach to projects using %s.", brand_name);
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, ALERT_SIZE, white, buf);
|
2009-02-19 00:29:12 +00:00
|
|
|
}
|
|
|
|
|
2010-02-16 20:10:13 +00:00
|
|
|
#define MAX_JOBS_DISPLAY 4
|
|
|
|
|
|
|
|
// index is where to start looking in job array
|
|
|
|
//
|
2009-02-12 01:04:59 +00:00
|
|
|
void show_jobs(unsigned int index, double alpha) {
|
2009-02-11 00:46:57 +00:00
|
|
|
float x=.1, y=.7;
|
2009-02-12 01:25:03 +00:00
|
|
|
unsigned int nfound = 0;
|
2009-02-11 16:33:08 +00:00
|
|
|
unsigned int i;
|
2010-03-11 01:39:14 +00:00
|
|
|
cc_status.task_suspend_reason &= ~SUSPEND_REASON_CPU_THROTTLE;
|
2011-11-25 07:24:18 +00:00
|
|
|
char buf[256];
|
2009-02-26 23:32:29 +00:00
|
|
|
|
2009-03-23 17:14:43 +00:00
|
|
|
if (!cc_status.task_suspend_reason) {
|
|
|
|
for (i=0; i<cc_state.results.size(); i++) {
|
2010-02-16 20:10:13 +00:00
|
|
|
int j = (i + index) % cc_state.results.size();
|
|
|
|
RESULT* r = cc_state.results[j];
|
2009-03-23 17:14:43 +00:00
|
|
|
if (!r->active_task) continue;
|
|
|
|
if (r->scheduler_state != CPU_SCHED_SCHEDULED) continue;
|
2010-02-16 20:10:13 +00:00
|
|
|
if (!nfound) {
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, TASK_INTRO_SIZE, white, "Running tasks:");
|
2009-03-23 17:14:43 +00:00
|
|
|
y -= .05;
|
|
|
|
}
|
2010-02-16 20:10:13 +00:00
|
|
|
show_result(r, x, y, alpha);
|
|
|
|
y -= .05;
|
2009-03-23 17:14:43 +00:00
|
|
|
nfound++;
|
2010-02-16 20:10:13 +00:00
|
|
|
if (nfound == MAX_JOBS_DISPLAY) break;
|
2009-02-11 00:46:57 +00:00
|
|
|
}
|
2009-02-11 16:33:08 +00:00
|
|
|
}
|
2009-02-12 01:04:59 +00:00
|
|
|
if (!nfound) {
|
2009-02-11 16:33:08 +00:00
|
|
|
y = .5;
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, TASK_NONE_SIZE, white, "No running tasks");
|
2009-02-11 16:33:08 +00:00
|
|
|
char *p = 0;
|
|
|
|
switch (cc_status.task_suspend_reason) {
|
|
|
|
case SUSPEND_REASON_BATTERIES:
|
|
|
|
p = "Computer is running on batteries"; break;
|
|
|
|
case SUSPEND_REASON_USER_ACTIVE:
|
|
|
|
p = "Computer is in use"; break;
|
|
|
|
case SUSPEND_REASON_USER_REQ:
|
|
|
|
p = "Computing suspended by user"; break;
|
|
|
|
case SUSPEND_REASON_TIME_OF_DAY:
|
|
|
|
p = "Computing suspended during this time of day"; break;
|
|
|
|
case SUSPEND_REASON_BENCHMARKS:
|
|
|
|
p = "Computing suspended while running benchmarks"; break;
|
|
|
|
case SUSPEND_REASON_DISK_SIZE:
|
|
|
|
p = "Computing suspended because no disk space"; break;
|
|
|
|
case SUSPEND_REASON_NO_RECENT_INPUT:
|
|
|
|
p = "Computing suspended while computer not in use"; break;
|
|
|
|
case SUSPEND_REASON_INITIAL_DELAY:
|
2011-11-25 07:24:18 +00:00
|
|
|
sprintf(buf,
|
|
|
|
"Computing suspended while %s is starting up", brand_name
|
|
|
|
);
|
|
|
|
p = buf;
|
|
|
|
break;
|
2009-02-11 16:33:08 +00:00
|
|
|
case SUSPEND_REASON_EXCLUSIVE_APP_RUNNING:
|
|
|
|
p = "Computing suspended while exclusive application running"; break;
|
2010-02-16 20:10:13 +00:00
|
|
|
case SUSPEND_REASON_CPU_USAGE:
|
|
|
|
p = "Computing suspended because processor usage is high"; break;
|
2009-02-11 16:33:08 +00:00
|
|
|
}
|
|
|
|
if (p) {
|
|
|
|
y -= .1;
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_render_string(x, y, 0, TASK_NONE_REASON_SIZE, white, p);
|
2009-02-11 16:33:08 +00:00
|
|
|
}
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-19 00:29:12 +00:00
|
|
|
int update_data() {
|
2009-02-11 16:33:08 +00:00
|
|
|
int retval = rpc.get_state(cc_state);
|
2009-02-19 00:38:34 +00:00
|
|
|
if (!retval) {
|
|
|
|
retval = rpc.get_cc_status(cc_status);
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|
2009-02-19 00:38:34 +00:00
|
|
|
return retval;
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|
|
|
|
|
2009-02-11 00:46:57 +00:00
|
|
|
struct FADER {
|
|
|
|
double grow, on, fade, off;
|
|
|
|
double start, total;
|
|
|
|
FADER(double g, double n, double f, double o) {
|
|
|
|
grow = g;
|
|
|
|
on = n;
|
|
|
|
fade = f;
|
|
|
|
off = o;
|
|
|
|
start = 0;
|
|
|
|
total = grow + on + fade + off;
|
|
|
|
}
|
|
|
|
bool value(double t, double& v) {
|
|
|
|
if (!start) {
|
|
|
|
start = t;
|
|
|
|
v = 0;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
double dt = t - start;
|
|
|
|
if (dt > total) {
|
|
|
|
start = t;
|
|
|
|
v = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (dt < grow) {
|
|
|
|
v = dt/grow;
|
|
|
|
} else if (dt < grow+on) {
|
|
|
|
v = 1;
|
|
|
|
} else if (dt < grow + on + fade) {
|
|
|
|
double x = dt-(grow+on);
|
|
|
|
v = 1-(x/fade);
|
|
|
|
} else {
|
|
|
|
v = 0;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
FADER logo_fader(5,5,5,2);
|
|
|
|
FADER info_fader(4,4,4,1);
|
|
|
|
|
2009-02-06 02:17:45 +00:00
|
|
|
void app_graphics_render(int xs, int ys, double t) {
|
2009-02-11 00:46:57 +00:00
|
|
|
double alpha;
|
|
|
|
static bool showing_project = false;
|
2009-02-11 16:33:08 +00:00
|
|
|
static unsigned int project_index = 0, job_index=0;
|
2009-02-11 00:46:57 +00:00
|
|
|
static float logo_pos[3] = {.2, .2, 0};
|
2009-02-19 00:29:12 +00:00
|
|
|
int retval;
|
2009-02-11 00:46:57 +00:00
|
|
|
|
2009-02-19 00:29:12 +00:00
|
|
|
if (!connected) {
|
|
|
|
if (t > next_connect_time) {
|
2010-10-06 09:00:05 +00:00
|
|
|
retval = rpc.init(NULL);
|
2009-02-19 00:29:12 +00:00
|
|
|
if (!retval) {
|
|
|
|
retval = update_data();
|
|
|
|
}
|
|
|
|
if (retval) {
|
2009-02-20 02:33:11 +00:00
|
|
|
if (!retry_connect) {
|
2009-02-20 11:49:49 +00:00
|
|
|
exit(ERR_CONNECT);
|
2009-02-19 00:29:12 +00:00
|
|
|
}
|
|
|
|
next_connect_time = t + 10;
|
|
|
|
} else {
|
|
|
|
connected = true;
|
|
|
|
}
|
|
|
|
}
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
// draw logo first - it's in background
|
|
|
|
//
|
|
|
|
mode_unshaded();
|
|
|
|
mode_ortho();
|
2009-02-11 00:46:57 +00:00
|
|
|
if (logo_fader.value(t, alpha)) {
|
|
|
|
logo_pos[0] = drand()*.4;
|
|
|
|
logo_pos[1] = drand()*.4;
|
|
|
|
}
|
|
|
|
draw_logo(logo_pos, (float)alpha);
|
2009-02-10 19:30:59 +00:00
|
|
|
|
2009-02-11 00:46:57 +00:00
|
|
|
if (info_fader.value(t, alpha)) {
|
2009-02-19 00:29:12 +00:00
|
|
|
retval = update_data();
|
|
|
|
if (retval) {
|
2009-02-20 02:33:11 +00:00
|
|
|
if (!retry_connect) {
|
2009-02-20 11:49:49 +00:00
|
|
|
exit(ERR_CONNECT);
|
2009-02-19 00:29:12 +00:00
|
|
|
}
|
|
|
|
connected = false;
|
|
|
|
next_connect_time = t + 10;
|
2009-02-11 00:46:57 +00:00
|
|
|
} else {
|
2009-02-19 00:29:12 +00:00
|
|
|
if (showing_project) {
|
|
|
|
showing_project = false;
|
|
|
|
project_index++;
|
|
|
|
} else {
|
2015-01-16 17:29:49 +00:00
|
|
|
int n = (int)cc_state.results.size();
|
2011-11-25 07:24:18 +00:00
|
|
|
if (n) {
|
|
|
|
job_index += MAX_JOBS_DISPLAY;
|
|
|
|
job_index %= n;
|
|
|
|
} else {
|
|
|
|
job_index = 0;
|
|
|
|
}
|
2009-02-19 00:29:12 +00:00
|
|
|
showing_project = true;
|
2009-02-12 01:04:59 +00:00
|
|
|
}
|
2009-02-11 00:46:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
white[3] = alpha;
|
2009-02-19 00:29:12 +00:00
|
|
|
if (connected) {
|
2009-02-26 23:32:29 +00:00
|
|
|
if (cc_state.projects.size() == 0) {
|
|
|
|
show_no_projects();
|
|
|
|
} else if (showing_project) {
|
2009-02-19 00:29:12 +00:00
|
|
|
if (project_index >= cc_state.projects.size()) {
|
|
|
|
project_index = 0;
|
|
|
|
}
|
|
|
|
show_project(project_index, alpha);
|
|
|
|
} else {
|
|
|
|
show_jobs(job_index, alpha);
|
2009-02-11 00:46:57 +00:00
|
|
|
}
|
|
|
|
} else {
|
2009-02-19 00:29:12 +00:00
|
|
|
show_disconnected();
|
2009-02-11 00:46:57 +00:00
|
|
|
}
|
|
|
|
ortho_done();
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void app_graphics_resize(int w, int h){
|
|
|
|
width = w;
|
|
|
|
height = h;
|
|
|
|
glViewport(0, 0, w, h);
|
|
|
|
}
|
|
|
|
|
2009-02-19 00:29:12 +00:00
|
|
|
void boinc_app_mouse_move(int x, int y, int left, int middle, int right) {}
|
|
|
|
void boinc_app_mouse_button(int x, int y, int which, int is_down) {}
|
2009-02-06 02:17:45 +00:00
|
|
|
void boinc_app_key_press(int, int){}
|
|
|
|
void boinc_app_key_release(int, int){}
|
|
|
|
|
|
|
|
void app_graphics_init() {
|
|
|
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
2012-08-02 06:53:11 +00:00
|
|
|
ttf_load_fonts(".");
|
2011-11-25 07:24:18 +00:00
|
|
|
logo.load_image_file(logo_file);
|
2009-02-06 02:17:45 +00:00
|
|
|
init_lights();
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
int retval;
|
2009-02-19 00:29:12 +00:00
|
|
|
bool test = false;
|
2009-02-06 02:17:45 +00:00
|
|
|
|
2009-02-19 00:29:12 +00:00
|
|
|
for (int i=1; i<argc; i++) {
|
2009-02-20 11:49:49 +00:00
|
|
|
if (!strcmp(argv[i], "--test")) {
|
2009-02-19 00:29:12 +00:00
|
|
|
test = true;
|
|
|
|
}
|
2009-02-20 11:49:49 +00:00
|
|
|
if (!strcmp(argv[i], "--retry_connect")) {
|
2009-02-20 02:33:11 +00:00
|
|
|
retry_connect = true;
|
2009-02-19 00:29:12 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-19 21:55:00 +00:00
|
|
|
|
|
|
|
// Initialize the BOINC Diagnostics Framework
|
|
|
|
int dwDiagnosticsFlags =
|
|
|
|
#ifdef _DEBUG
|
|
|
|
BOINC_DIAG_HEAPCHECKENABLED |
|
|
|
|
BOINC_DIAG_MEMORYLEAKCHECKENABLED |
|
|
|
|
#endif
|
|
|
|
BOINC_DIAG_DUMPCALLSTACKENABLED |
|
|
|
|
BOINC_DIAG_PERUSERLOGFILES |
|
|
|
|
BOINC_DIAG_REDIRECTSTDERR |
|
|
|
|
BOINC_DIAG_REDIRECTSTDOUT |
|
|
|
|
BOINC_DIAG_TRACETOSTDOUT;
|
|
|
|
|
|
|
|
diagnostics_init(dwDiagnosticsFlags, "stdoutscrgfx", "stderrscrgfx");
|
|
|
|
|
2009-02-06 02:17:45 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
WinsockInitialize();
|
|
|
|
#endif
|
2009-02-19 00:29:12 +00:00
|
|
|
|
|
|
|
if (test) {
|
2010-10-06 09:00:05 +00:00
|
|
|
retval = rpc.init(NULL);
|
2009-02-19 00:29:12 +00:00
|
|
|
if (!retval) {
|
|
|
|
retval = update_data();
|
|
|
|
}
|
2009-02-20 11:49:49 +00:00
|
|
|
exit(ERR_CONNECT);
|
2009-02-19 00:29:12 +00:00
|
|
|
}
|
2010-02-02 12:19:01 +00:00
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2011-11-26 11:42:12 +00:00
|
|
|
long brandId = BOINC_BRAND_ID;
|
2011-11-26 10:56:56 +00:00
|
|
|
// For GridRepublic or CharityEngine, the installer put a branding file in our data directory
|
2010-02-02 12:19:01 +00:00
|
|
|
FILE *f = fopen("/Library/Application Support/BOINC Data/Branding", "r");
|
|
|
|
if (f) {
|
2011-11-26 10:56:56 +00:00
|
|
|
fscanf(f, "BrandId=%ld\n", &brandId);
|
2010-02-02 12:19:01 +00:00
|
|
|
fclose(f);
|
2011-11-26 11:42:12 +00:00
|
|
|
if (brandId == GRIDREPUBLIC_BRAND_ID) {
|
|
|
|
brand_name = "GridRepublic";
|
|
|
|
logo_file = "gridrepublic_ss_logo.jpg";
|
|
|
|
} else if (brandId == CHARITYENGINE_BRAND_ID) {
|
|
|
|
brand_name = "Charity Engine";
|
|
|
|
logo_file = "CE_ss_logo.jpg";
|
|
|
|
}
|
2011-11-26 10:56:56 +00:00
|
|
|
}
|
2010-02-02 12:19:01 +00:00
|
|
|
#endif
|
2009-02-12 01:19:56 +00:00
|
|
|
|
2009-02-26 23:32:29 +00:00
|
|
|
boinc_graphics_loop(argc, argv, "BOINC screensaver");
|
2014-03-20 20:32:32 +00:00
|
|
|
|
2009-02-06 02:17:45 +00:00
|
|
|
boinc_finish_diag();
|
2014-03-20 20:32:32 +00:00
|
|
|
|
2009-02-06 02:17:45 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
WinsockCleanup();
|
|
|
|
#endif
|
2014-03-20 20:32:32 +00:00
|
|
|
|
|
|
|
return 0;
|
2009-02-06 02:17:45 +00:00
|
|
|
}
|