*** empty log message ***

svn path=/trunk/boinc_samples/; revision=10067
This commit is contained in:
David Anderson 2006-04-30 05:38:08 +00:00
parent dcefa25408
commit 6f1802bc83
3 changed files with 37 additions and 32 deletions

View File

@ -49,6 +49,7 @@ David 21 Apr 2006
uc_graphics.C
upper_case.C
Charlie 27 April 2006
- Mac: updated XCode project for upper_case, fixed
jconfig.h to be cross-platform. upper_case now
@ -59,3 +60,11 @@ Charlie 27 April 2006
mac_build/
UpperCase.xcodeproj/
project.pbxproj
David 29 Apr 2006
- use project preferences (<color_scheme>) for graphics color
- remove -exit, -signal options from upper_case
uppercase/
uc_graphics.C
upper_case.C

View File

@ -26,6 +26,7 @@
#include "config.h"
#endif
#include "parse.h"
#include "gutil.h"
#include "boinc_gl.h"
#include "graphics_api.h"
@ -38,6 +39,27 @@ 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};
static void parse_project_prefs(char* buf) {
char cs[256];
COLOR c;
double hue;
if (parse_str(buf, "<color_scheme>", 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;
}
}
// set up lighting model
//
@ -55,6 +77,7 @@ void app_graphics_init() {
int viewport[4];
boinc_get_init_data(uc_aid);
parse_project_prefs(uc_aid.project_preferences);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
txf_load_fonts(".");
boinc_resolve_filename("logo.jpg", path, sizeof(path));
@ -113,9 +136,9 @@ void set_viewpoint(double dist) {
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(
x, y, z, // eye position
0,-.8,0, // where we're looking
0.0, 1.0, 0. // up is in positive Y direction
x, y, z, // eye position
0,-.8,0, // where we're looking
0.0, 1.0, 0. // up is in positive Y direction
);
glRotated(pitch_angle, 1., 0., 0);
glRotated(roll_angle, 0., 1., 0);
@ -128,7 +151,7 @@ static void app_init_camera(double dist) {
45.0, // field of view in degree
1.0, // aspect ratio
1.0, // Z near clip
1000.0 // Z far
1000.0 // Z far
);
set_viewpoint(dist);
}
@ -144,7 +167,6 @@ void app_graphics_render(int xs, int ys, double time_of_day) {
app_init_camera(viewpoint_distance);
scale_screen(width, height);
GLfloat color[4] = {.7, .2, .5, 1};
mode_shaded(color);
draw_3d_stuff();

View File

@ -20,9 +20,7 @@
// read "in", convert to UC, write to "out"
// command line options:
// -run_slow: sleep 1 second after each character, useful for debugging
// -cpu_time N: use about N CPU seconds
// -signal: raise SIGHUP signal (for testing signal handler)
// -exit: exit with status -10 (for testing exit handler)
// -cpu_time N: use about N CPU seconds after copying files
//
#ifdef _WIN32
@ -159,17 +157,6 @@ void worker() {
boinc_sleep(1.);
}
#ifdef HAVE_SIGNAL_H
if (raise_signal) {
raise(SIGHUP);
}
#endif
if (random_exit) {
if (drand() < 0.05) {
exit(-10);
}
}
int flag = boinc_time_to_checkpoint();
if (flag) {
retval = do_checkpoint(out, nchars);
@ -196,10 +183,6 @@ void worker() {
use_some_cpu();
}
}
if (random_exit) exit(-10);
fprintf(stderr, "APP: upper_case ending, wrote %d chars\n", nchars);
boinc_finish(0);
}
@ -213,27 +196,18 @@ int main(int argc, char **argv) {
BOINC_DIAG_TRACETOSTDERR
);
// NOTE: if you change output here, remember to change the output that
// test_uc.py pattern-matches against.
for (i=0; i<argc; i++) {
fprintf(stderr, "APP: upper_case: argv[%d] is %s\n", i, argv[i]);
if (!strcmp(argv[i], "-run_slow")) run_slow = true;
if (!strcmp(argv[i], "-cpu_time")) {
cpu_time = atof(argv[++i]);
}
if (!strcmp(argv[i], "-signal")) raise_signal = true;
if (!strcmp(argv[i], "-exit")) random_exit = true;
}
fprintf(stderr, "APP: upper_case: starting, argc %d\n", argc);
#ifdef BOINC_APP_GRAPHICS
#if defined(_WIN32) || defined(__APPLE__)
retval = boinc_init_graphics(worker);
#else
setbuf(stderr, 0);
fprintf(stderr, "About to call graphics init\n");
retval = boinc_init_graphics_lib(worker, argv[0]);
#endif
if (retval) exit(retval);