diff --git a/checkin_notes b/checkin_notes index 37447e1fb0..d6d604f3bc 100644 --- a/checkin_notes +++ b/checkin_notes @@ -568,3 +568,9 @@ David 6 Mar 2008 wrapper/ wrapper.C + +David 9 Mar 2008 + - wrapper: compile fixes for Mac + + wrapper/ + wrapper.C diff --git a/uppercase/Makefile b/uppercase/Makefile deleted file mode 100644 index 331ec8594f..0000000000 --- a/uppercase/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# This should work on Linux. Modify as needed for other platforms. - -# Do this first: -# ln -s `g++ -print-file-name=libstdc++.a` -# This creates a symbolic link to the C++ library, -# which is linked statically - -BOINC_DIR = ../../boinc -BOINC_API_DIR = $(BOINC_DIR)/api -BOINC_LIB_DIR = $(BOINC_DIR)/lib - -CXXFLAGS = -g \ - -I$(BOINC_DIR) \ - -I$(BOINC_LIB_DIR) \ - -I$(BOINC_API_DIR) \ - -L$(BOINC_API_DIR) \ - -L$(BOINC_LIB_DIR) \ - -L /usr/X11R6/lib \ - -L. - -# the following should be freeglut; use nm to check -# you may have to change the paths for your system -LIBGLUT = /usr/local/lib/libglut.a -LIBGLU = /usr/local/lib/libGLU.a -LIBJPEG = /usr/local/lib/libjpeg.a - -PROGS = upper_case upper_case.so - -all: $(PROGS) - -clean: - rm $(PROGS) - -# the -Wl,--export-dynamic causes the main program's symbols -# to be exported to the graphics library - -upper_case: upper_case.o $(BOINC_API_DIR)/libboinc_api.a $(BOINC_API_DIR)/libboinc_graphics_lib.a $(BOINC_LIB_DIR)/libboinc.a - $(CXX) $(CXXFLAGS) -Wl,--export-dynamic -o upper_case upper_case.o libstdc++.a -pthread -lboinc_api -lboinc -lboinc_graphics_lib -ldl - -upper_case.so: uc_graphics.o $(BOINC_LIB_DIR)/libboinc.a $(BOINC_API_DIR)/libboinc_graphics_impl.a - $(CXX) $(CXXFLAGS) -o upper_case.so \ - -shared -fPIC -pthread \ - uc_graphics.o \ - libstdc++.a \ - -lboinc_graphics_impl -lboinc \ - $(LIBGLUT) $(LIBGLU) $(LIBJPEG) \ - -lGL -lX11 -lXmu -lm; \ diff --git a/uppercase/README b/uppercase/README deleted file mode 100644 index 894db028af..0000000000 --- a/uppercase/README +++ /dev/null @@ -1,9 +0,0 @@ -NOTE: this app is deprecated and won't build. -Use boinc_samples/example_app/ instead. ----------------------- - -The graphics should show a bouncing ball. - -If you want a logo, put a file "logo.jpg" in this directory. - -If you want text, copy Helvetica.txf to this directory. diff --git a/uppercase/in b/uppercase/in deleted file mode 100644 index 8caf86e2f9..0000000000 --- a/uppercase/in +++ /dev/null @@ -1 +0,0 @@ -test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test diff --git a/uppercase/logo.jpg b/uppercase/logo.jpg deleted file mode 100644 index f681f3916e..0000000000 Binary files a/uppercase/logo.jpg and /dev/null differ diff --git a/uppercase/uc_graphics.C b/uppercase/uc_graphics.C deleted file mode 100644 index fe15b3e3e1..0000000000 --- a/uppercase/uc_graphics.C +++ /dev/null @@ -1,224 +0,0 @@ -// Berkeley Open Infrastructure for Network Computing -// http://boinc.berkeley.edu -// Copyright (C) 2005 University of California -// -// This 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 2.1 of the License, or (at your option) any later version. -// -// This software 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. -// -// To view the GNU Lesser General Public License visit -// http://www.gnu.org/copyleft/lesser.html -// or write to the Free Software Foundation, Inc., -// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -// graphics code for upper_case - -#ifdef _WIN32 -#include "boinc_win.h" -#else -#include -#include "config.h" -#endif - -#include "parse.h" -#include "gutil.h" -#include "boinc_gl.h" -#include "graphics_api.h" -#include "txf_util.h" - -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}; - -static void parse_project_prefs(char* buf) { - char cs[256]; - COLOR c; - double hue; - 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; - } -} - -// 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); -} - -void app_graphics_init() { - char path[256]; - 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)); - logo.load_image_file(path); - init_lights(); - get_viewport(viewport); - app_graphics_resize(viewport[2], viewport[3]); -} - -static void draw_logo() { - if (logo.present) { - float pos[3] = {.2, .3, 0}; - float size[3] = {.6, .4, 0}; - logo.draw(pos, size, ALIGN_CENTER, ALIGN_CENTER); - } -} - -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; - 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*boinc_get_fraction_done()); - txf_render_string(.1, x, y+.2, 0, 500, white, 0, buf); -} - -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); -} - -void set_viewpoint(double dist) { - double x, y, z; - x = 0; - y = 3.0*dist; - z = 11.0*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 - ); - glRotated(pitch_angle, 1., 0., 0); - glRotated(roll_angle, 0., 1., 0); -} - -static void app_init_camera(double dist) { - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective( - 45.0, // field of view in degree - 1.0, // aspect ratio - 1.0, // Z near clip - 1000.0 // Z far - ); - set_viewpoint(dist); -} - -extern "C" { - -void app_graphics_render(int xs, int ys, double time_of_day) { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - mode_unshaded(); - mode_ortho(); - draw_logo(); - ortho_done(); - - app_init_camera(viewpoint_distance); - - scale_screen(width, height); - mode_shaded(color); - draw_3d_stuff(); - - scale_screen(width, height); - mode_unshaded(); - mode_ortho(); - draw_text(); - ortho_done(); -} - -void app_graphics_resize(int w, int h){ - width = w; - height = h; - glViewport(0, 0, w, h); -} - -void app_graphics_reread_prefs(){ - boinc_parse_init_data_file(); - boinc_get_init_data(uc_aid); - parse_project_prefs(uc_aid.project_preferences); -} - -void boinc_app_mouse_move(int x, int y, int left, int middle, int right) { - if (left) { - pitch_angle += (y-mouse_y)*.1; - roll_angle += (x-mouse_x)*.1; - mouse_y = y; - mouse_x = x; - } else if (right) { - double d = (y-mouse_y); - viewpoint_distance *= exp(d/100.); - mouse_y = y; - mouse_x = x; - } else { - mouse_down = false; - } -} - -void boinc_app_mouse_button(int x, int y, int which, int is_down) { - if (is_down) { - mouse_down = true; - mouse_x = x; - mouse_y = y; - } else { - mouse_down = false; - } -} - -void boinc_app_key_press(int, int){} - -void boinc_app_key_release(int, int){} - -} diff --git a/uppercase/upper_case.C b/uppercase/upper_case.C deleted file mode 100755 index ef9db80b47..0000000000 --- a/uppercase/upper_case.C +++ /dev/null @@ -1,274 +0,0 @@ -// Berkeley Open Infrastructure for Network Computing -// http://boinc.berkeley.edu -// Copyright (C) 2005 University of California -// -// This 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 2.1 of the License, or (at your option) any later version. -// -// This software 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. -// -// To view the GNU Lesser General Public License visit -// http://www.gnu.org/copyleft/lesser.html -// or write to the Free Software Foundation, Inc., -// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -// DEPRECATED!!! Use example_app/ instead -// -// This is the primary sample BOINC application; -// it shows most of the features of the BOINC API. -// -// read "in", convert to upper case, write to "out" -// -// command line options (use for debugging various scenarios): -// -run_slow: sleep 1 second after each character; useful for debugging -// -cpu_time N: use about N CPU seconds after copying files -// -early_exit: exit(10) after 30 chars -// -early_crash: crash after 30 chars -// - -#ifdef _WIN32 -#include "boinc_win.h" -#else -#include "config.h" -#endif - -#ifndef _WIN32 -#include -#include -#include -#include -#include -#include -#include -#endif - -#define BOINC_APP_GRAPHICS - -#ifdef BOINC_APP_GRAPHICS -#include "graphics_api.h" -#include "graphics_lib.h" -#endif - -#include "diagnostics.h" -#include "str_util.h" -#include "util.h" -#include "filesys.h" -#include "boinc_api.h" -#include "mfile.h" - -using std::string; - -#define CHECKPOINT_FILE "upper_case_state" -#define INPUT_FILENAME "in" -#define OUTPUT_FILENAME "out" - -bool run_slow = false; -bool early_exit = false; -bool early_crash = false; -bool early_sleep = false; -double cpu_time = 20; - - -static void use_some_cpu() { - double j = 3.14159; - int i, n = 0; - for (i=0; i<20000000; i++) { - n++; - j *= n+j-3.14159; - j /= (float)n; - } -} - -int do_checkpoint(MFILE& mf, int nchars) { - int retval; - string resolved_name; - - FILE* f = fopen("temp", "w"); - if (!f) return 1; - fprintf(f, "%d", nchars); - fclose(f); - - fprintf(stderr, "APP: upper_case checkpointing\n"); - - retval = mf.flush(); - if (retval) return retval; - boinc_resolve_filename_s(CHECKPOINT_FILE, resolved_name); - retval = boinc_rename("temp", resolved_name.c_str()); - if (retval) return retval; - - //use_some_cpu(); - fprintf(stderr, "APP: upper_case checkpoint done\n"); - return 0; -} - - -void worker() { - int c, nchars = 0, retval, n; - double fsize; - char input_path[512], output_path[512], chkpt_path[512]; - MFILE out; - FILE* state, *infile; - - // open the input file (resolve logical name first) - // - boinc_resolve_filename(INPUT_FILENAME, input_path, sizeof(input_path)); - infile = boinc_fopen(input_path, "r"); - if (!infile) { - fprintf(stderr, - "Couldn't find input file, resolved name %s.\n", input_path - ); - exit(-1); - } - - // get size of input file (used to compute fraction done) - // - file_size(input_path, fsize); - - // open output file - // - boinc_resolve_filename(OUTPUT_FILENAME, output_path, sizeof(output_path)); - - // See if there's a valid checkpoint file. - // If so seek input file and truncate output file - // - boinc_resolve_filename(CHECKPOINT_FILE, chkpt_path, sizeof(chkpt_path)); - state = boinc_fopen(chkpt_path, "r"); - if (state) { - n = fscanf(state, "%d", &nchars); - fclose(state); - } - if (state && n==1) { - fseek(infile, nchars, SEEK_SET); - boinc_truncate(output_path, nchars); - retval = out.open(output_path, "a"); - } else { - retval = out.open(output_path, "w"); - } - if (retval) { - fprintf(stderr, "APP: upper_case output open failed:\n"); - fprintf(stderr, "resolved name %s, retval %d\n", output_path, retval); - perror("open"); - exit(1); - } - - // main loop - read characters, convert to UC, write - // - for (int i=0; ; i++) { - c = fgetc(infile); - - if (c == EOF) break; - c = toupper(c); - out._putchar(c); - nchars++; - if (run_slow) { - boinc_sleep(1.); - } - - if (early_exit && i>30) { - exit(-10); - } - - if (early_crash && i>30) { -#ifdef _WIN32 - DebugBreak(); -#else - *(int*)0 = 0; -#endif - } - if (early_sleep && i>30) { - g_sleep = true; - while (1) boinc_sleep(1); - } - - if (boinc_time_to_checkpoint()) { - retval = do_checkpoint(out, nchars); - if (retval) { - fprintf(stderr, "APP: upper_case checkpoint failed %d\n", retval); - exit(retval); - } - boinc_checkpoint_completed(); - } - - double f = nchars/fsize; - if (cpu_time) f /= 2; - boinc_fraction_done(f); - } - - retval = out.flush(); - if (retval) { - fprintf(stderr, "APP: upper_case flush failed %d\n", retval); - exit(1); - } - - // burn up some CPU time if needed - // - if (cpu_time) { - double start = dtime(); - while (1) { - double e = dtime()-start; - if (e > cpu_time) break; - boinc_fraction_done(.5 + e/(cpu_time*2)); - - if (boinc_time_to_checkpoint()) { - retval = do_checkpoint(out, nchars); - if (retval) { - fprintf(stderr, "APP: upper_case checkpoint failed %d\n", retval); - exit(1); - } - boinc_checkpoint_completed(); - } - - use_some_cpu(); - } - } - boinc_finish(0); -} - -int main(int argc, char **argv) { - int i; - int retval = 0; - - for (i=0; i