*** empty log message ***

svn path=/trunk/boinc/; revision=11404
This commit is contained in:
David Anderson 2006-10-31 00:29:30 +00:00
parent 33117c0959
commit da173a0dc1
5 changed files with 79 additions and 76 deletions

View File

@ -308,7 +308,11 @@ int boinc_init_options_general(BOINC_OPTIONS& opt) {
} else { } else {
retval = setup_shared_mem(); retval = setup_shared_mem();
if (retval) { if (retval) {
fprintf(stderr, "Can't set up shared mem: %d\n", retval); fprintf(stderr,
"Can't set up shared mem: %d\n"
"Will run in standalone mode.\n",
retval
);
standalone = true; standalone = true;
} }
} }
@ -1020,4 +1024,27 @@ void block_sigalrm() {
} }
#endif #endif
bool boinc_graphics_possible() {
#ifdef _WIN32
// Attempt to load the dlls that are required to display graphics, if
// any of them fail do not start the application in graphics mode.
if (FAILED(__HrLoadAllImportsForDll("GDI32.dll"))) {
fprintf(stderr, "Failed to load GDI32.DLL\n" );
return false;
}
if (FAILED(__HrLoadAllImportsForDll("OPENGL32.dll"))) {
fprintf( stderr, "Failed to load OPENGL32.DLL\n" );
return false;
}
if (FAILED(__HrLoadAllImportsForDll("GLU32.dll"))) {
fprintf( stderr, "Failed to load GLU32.DLL\n" );
return false;
}
#elif defined(__APPLE__)
#else
if (!getenv("DISPLAY")) return false;
#endif
return true;
}
const char *BOINC_RCSID_0fa0410386 = "$Id$"; const char *BOINC_RCSID_0fa0410386 = "$Id$";

View File

@ -20,12 +20,9 @@
#ifndef BOINC_GRAPHICS_API_H #ifndef BOINC_GRAPHICS_API_H
#define BOINC_GRAPHICS_API_H #define BOINC_GRAPHICS_API_H
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*WORKER_FUNC_PTR)(); typedef void (*WORKER_FUNC_PTR)();
extern bool boinc_graphics_possible();
extern int boinc_init_graphics(WORKER_FUNC_PTR); extern int boinc_init_graphics(WORKER_FUNC_PTR);
// Functions that must be supplied by the app // Functions that must be supplied by the app
@ -43,10 +40,6 @@ extern void boinc_app_mouse_move(int x, int y, int left, int middle, int right);
extern void boinc_app_key_press(int, int); extern void boinc_app_key_press(int, int);
extern void boinc_app_key_release(int, int); extern void boinc_app_key_release(int, int);
#ifdef __cplusplus
} // extern "C"
#endif
// C++ API follows here // C++ API follows here
#if defined __cplusplus #if defined __cplusplus

View File

@ -143,7 +143,7 @@ int xwin_glut_is_initialized() {
return glut_is_initialized; return glut_is_initialized;
} }
void app_debug_msg (const char *fmt, ...); bool debug = true;
// This callback is invoked when a user presses a key. // This callback is invoked when a user presses a key.
// //
@ -241,7 +241,7 @@ static void make_new_window(int mode) {
boinc_glut_init(); boinc_glut_init();
} }
app_debug_msg("make_new_window(): now calling glutCreateWindow(%s)...\n", aid.app_name); if (debug) fprintf(stderr, "make_new_window(): now calling glutCreateWindow(%s)...\n", aid.app_name);
char window_title[256]; char window_title[256];
get_window_title(aid, window_title, 256); get_window_title(aid, window_title, 256);
@ -269,7 +269,7 @@ static void make_new_window(int mode) {
if (!have_window) { if (!have_window) {
win = glutCreateWindow(window_title); win = glutCreateWindow(window_title);
app_debug_msg("glutCreateWindow() succeeded. win = %d\n", win); if (debug) fprintf(stderr, "glutCreateWindow() succeeded. win = %d\n", win);
glutReshapeFunc(app_graphics_resize); glutReshapeFunc(app_graphics_resize);
glutKeyboardFunc(keyboardD); glutKeyboardFunc(keyboardD);
@ -298,8 +298,9 @@ static void make_new_window(int mode) {
return; return;
} }
// Initialize glut and screensaver-graphics. Using GLUT, // Initialize GLUT.
// this should only called once, even if restarted by user-exit. // Using GLUT, this should only called once,
// even if the window is closed and opened.
// Using freeGLUT, its called to reinit freeglut and // Using freeGLUT, its called to reinit freeglut and
// the graphics window as freeglut 'deinitialized' itself // the graphics window as freeglut 'deinitialized' itself
// when the window is destroyed // when the window is destroyed
@ -313,9 +314,9 @@ static void boinc_glut_init() {
static bool first = true; static bool first = true;
win = 0; win = 0;
app_debug_msg("Calling glutInit()... \n"); if (debug) fprintf(stderr, "Calling glutInit()... \n");
glutInit (&one, (char**)args); glutInit (&one, (char**)args);
app_debug_msg("...survived glutInit(). \n"); if (debug) fprintf(stderr, "survived glutInit(). \n");
// figure out whether we're running GLUT or freeglut. // figure out whether we're running GLUT or freeglut.
// //
@ -335,7 +336,7 @@ static void boinc_glut_init() {
int major = glut_version/10000; int major = glut_version/10000;
int minor = (glut_version -(major*10000))/100; int minor = (glut_version -(major*10000))/100;
int maint = glut_version - (major*10000) - (minor * 100); int maint = glut_version - (major*10000) - (minor * 100);
app_debug_msg("Running freeGLUT %d.%d.%d.\n", major, minor, maint); if (debug) fprintf(stderr, "Running freeGLUT %d.%d.%d.\n", major, minor, maint);
} }
} }
} }
@ -415,17 +416,17 @@ void set_mode(int mode) {
return; return;
} }
app_debug_msg("set_mode(%d): current_mode = %d.\n", mode, current_graphics_mode); if (debug) fprintf(stderr, "set_mode(%d): current_mode = %d.\n", mode, current_graphics_mode);
if (glut_is_initialized) { if (glut_is_initialized) {
app_debug_msg("Calling KillWindow(): win = %d\n", win); if (debug) fprintf(stderr, "Calling KillWindow(): win = %d\n", win);
KillWindow(); KillWindow();
app_debug_msg("...KillWindow() survived.\n"); if (debug) fprintf(stderr, "KillWindow() survived.\n");
} }
if (mode != MODE_HIDE_GRAPHICS) { if (mode != MODE_HIDE_GRAPHICS) {
app_debug_msg("set_mode(): Calling make_new_window(%d)\n", mode); if (debug) fprintf(stderr, "set_mode(): Calling make_new_window(%d)\n", mode);
make_new_window(mode); make_new_window(mode);
app_debug_msg("...make_new_window() survived.\n"); if (debug) fprintf(stderr, "make_new_window() survived.\n");
} }
#ifdef __APPLE__ #ifdef __APPLE__
else else
@ -499,10 +500,10 @@ static void timer_handler(int) {
void restart() { void restart() {
// don't do anything except when exit is called from the graphics-thread // don't do anything except when exit is called from the graphics-thread
if (!pthread_equal(pthread_self(), graphics_thread)) { if (!pthread_equal(pthread_self(), graphics_thread)) {
app_debug_msg ("exit() was called from worker-thread\n"); if (debug) fprintf(stderr, "exit() was called from worker-thread\n");
return; return;
} }
app_debug_msg ("restart: exit() called from graphics-thread.\n"); if (debug) fprintf(stderr, "restart: exit() called from graphics-thread.\n");
// if we are standalone and glut was initialized, // if we are standalone and glut was initialized,
// we assume user pressed 'close', and we exit the app // we assume user pressed 'close', and we exit the app
@ -510,7 +511,7 @@ void restart() {
// //
if (glut_is_initialized ) { if (glut_is_initialized ) {
if (boinc_is_standalone()) { if (boinc_is_standalone()) {
app_debug_msg( if (debug) fprintf(stderr,
"Assuming user pressed 'close'... means we're exiting now.\n" "Assuming user pressed 'close'... means we're exiting now.\n"
); );
if (boinc_delete_file(LOCKFILE) != 0) { if (boinc_delete_file(LOCKFILE) != 0) {
@ -526,7 +527,7 @@ void restart() {
// jump back to entry-point in xwin_graphics_event_loop(); // jump back to entry-point in xwin_graphics_event_loop();
// //
app_debug_msg( "restart: Jumping back to event_loop.\n"); if (debug) fprintf(stderr, "restart: Jumping back to event_loop.\n");
longjmp(jbuf, JUMP_EXIT); longjmp(jbuf, JUMP_EXIT);
} }
@ -539,14 +540,14 @@ void restart_sig(int /*signal_number*/) {
if (pthread_equal(pthread_self(), graphics_thread)) { if (pthread_equal(pthread_self(), graphics_thread)) {
// alternative approach is for the signal hander to call exit(). // alternative approach is for the signal hander to call exit().
fprintf(stderr, "Caught SIGABRT in graphics thread\n"); fprintf(stderr, "Caught SIGABRT in graphics thread\n");
app_debug_msg ("Caught SIGABRT in graphics thread. Jumping back to xwin_graphics_event_loop()...\n"); if (debug) fprintf(stderr, "Caught SIGABRT in graphics thread. Jumping back to xwin_graphics_event_loop()...\n");
// jump back to entry-point in xwin_graphics_event_loop() // jump back to entry-point in xwin_graphics_event_loop()
longjmp(jbuf, JUMP_ABORT); longjmp(jbuf, JUMP_ABORT);
} else { } else {
// In non-graphics thread: use original signal handler // In non-graphics thread: use original signal handler
// //
fprintf(stderr, "Caught SIGABRT in non-graphics thread\n"); fprintf(stderr, "Caught SIGABRT in non-graphics thread\n");
app_debug_msg("Caught SIGABRT in non-graphics thread. Trying to call previous ABRT-handler...\n"); if (debug) fprintf(stderr, "Caught SIGABRT in non-graphics thread. Trying to call previous ABRT-handler...\n");
if (sigaction(SIGABRT, &original_signal_handler, NULL)) { if (sigaction(SIGABRT, &original_signal_handler, NULL)) {
perror("Unable to restore SIGABRT signal handler in non-graphics thread\n"); perror("Unable to restore SIGABRT signal handler in non-graphics thread\n");
// what to do? call abort(3)?? call exit(nonzero)??? // what to do? call abort(3)?? call exit(nonzero)???
@ -571,7 +572,7 @@ void restart_sig(int /*signal_number*/) {
void xwin_graphics_event_loop() { void xwin_graphics_event_loop() {
int restarted = 0; int restarted = 0;
app_debug_msg ("Direct call to xwin_graphics_event_loop()\n"); if (debug) fprintf(stderr, "Direct call to xwin_graphics_event_loop()\n");
struct sigaction sa; struct sigaction sa;
sa.sa_handler = restart_sig; sa.sa_handler = restart_sig;
@ -630,11 +631,11 @@ void xwin_graphics_event_loop() {
#endif #endif
set_mode(MODE_HIDE_GRAPHICS); set_mode(MODE_HIDE_GRAPHICS);
while ( current_graphics_mode == MODE_HIDE_GRAPHICS ) { while ( current_graphics_mode == MODE_HIDE_GRAPHICS ) {
app_debug_msg( if (debug) fprintf(stderr,
"Graphics-thread now waiting for client-message...\n" "Graphics-thread now waiting for client-message...\n"
); );
wait_for_initial_message(); wait_for_initial_message();
app_debug_msg ("got a graphics-message from client... \n"); if (debug) fprintf(stderr, "got a graphics-message from client... \n");
timer_handler(0); timer_handler(0);
} }
} else } else
@ -646,50 +647,10 @@ void xwin_graphics_event_loop() {
// ok we should be ready & initialized by now to call glutMainLoop() // ok we should be ready & initialized by now to call glutMainLoop()
// //
app_debug_msg ("now calling glutMainLoop()...\n"); if (debug) fprintf(stderr, "now calling glutMainLoop()...\n");
glutMainLoop(); glutMainLoop();
app_debug_msg("...glutMainLoop() returned!! This should never happen...\n"); if (debug) fprintf(stderr, "glutMainLoop() returned!! This should never happen...\n");
} }
#ifndef _DEBUG
void app_debug_msg (const char* /*fmt*/, ...) {
return;
}
#else
void app_debug_msg (const char* fmt, ...) {
va_list args;
char buffer[5000+1];
static char *boinc_slotdir = NULL;
va_start (args, fmt);
if (boinc_slotdir == NULL) {
char *tmp, *ptr;
if ((tmp = getcwd(NULL, 0)) == NULL) {
perror ("failed to get working directory using getcwd()");
boinc_slotdir = (char*)calloc(1, 20);
strcpy( boinc_slotdir, "[unknown]");
} else {
if ( (ptr = strrchr(tmp, '/')) == NULL) {
ptr = tmp;
} else {
ptr ++;
}
boinc_slotdir = (char*)calloc(1, strlen(ptr)+1);
strcpy(boinc_slotdir, ptr);
free(tmp);
}
}
vsnprintf (buffer, 5000, fmt, args);
fprintf (stdout, "APP '%s' DEBUG: ", boinc_slotdir);
fprintf (stdout, buffer);
fflush (stdout);
va_end (args);
}
#endif
const char *BOINC_RCSID_c457a14644 = "$Id$"; const char *BOINC_RCSID_c457a14644 = "$Id$";

View File

@ -11794,3 +11794,25 @@ Rom 30 Oct 2006
clientgui/ clientgui/
AdvancedFrame.cpp, .h AdvancedFrame.cpp, .h
David 30 Oct 2006
- API: moved the __HrLoadAllImportsForDll() calls out of
boinc_samples/uppercase/uppercase.C
(what were they doing there??)
and put them into a function boinc_graphics_possible().
Applications that can potentially do graphics should call this,
and if it returns false don't try to do graphics
(this means the needed DLLs are not there (Win)
or the DISPLAY env var is not set (Unix))
- API: make the graphics callbacks (e.g. mouse movement)
C++ rather than C functions.
This was breaking the example applications (upper_case).
Bruce et al: if this causes problems, let me know.
- API, X graphics: use fprintf(stderr) instead of app_debug_msg(0
api/
boinc_api.C
graphics_api.h
x_opengl.C
html/inc/
team.inc

View File

@ -16,7 +16,7 @@ function display_team_page($team, $offset, $sort_by) {
$n = 20; $n = 20;
// there aren't indices to support sorting by credit. // there aren't indices to support sorting by credit.
// set the following to turn off sorted output. // set the following variable to disable sorted output.
// (though since caching is generally used this shouldn't needed) // (though since caching is generally used this shouldn't needed)
// //
$nosort = false; $nosort = false;
@ -43,7 +43,7 @@ function display_team_page($team, $offset, $sort_by) {
} }
row2("Web site", "<a href=$x>$x</a>"); row2("Web site", "<a href=$x>$x</a>");
} }
row2("Members (with AND without Credit)", $team->nusers); row2("Members (with and without credit)", $team->nusers);
$founder = lookup_user_id($team->userid); $founder = lookup_user_id($team->userid);
$user = get_logged_in_user(false); $user = get_logged_in_user(false);
@ -63,7 +63,7 @@ function display_team_page($team, $offset, $sort_by) {
echo "</table>"; echo "</table>";
echo "<p>"; echo "<p>";
start_table(); start_table();
row1("Active members (have gotten Credit)", 4); row1("Active members (with nonzero total credit)", 4);
echo "<tr> echo "<tr>
<th>Name</th> <th>Name</th>
"; ";