mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=4832
This commit is contained in:
parent
152699da36
commit
12e3ff46a6
|
@ -20,18 +20,18 @@
|
||||||
#ifndef _BOINC_API_
|
#ifndef _BOINC_API_
|
||||||
#define _BOINC_API_
|
#define _BOINC_API_
|
||||||
|
|
||||||
/* to allow prototypes using 'bool' in ANSI-C */
|
// to allow prototypes using 'bool' in ANSI-C
|
||||||
|
//
|
||||||
#if (!defined __cplusplus) && (!defined bool)
|
#if (!defined __cplusplus) && (!defined bool)
|
||||||
#if ((defined(_MSC_VER)) && (_MSC_VER > 1020))
|
#if ((defined(_MSC_VER)) && (_MSC_VER > 1020))
|
||||||
#define bool char
|
#define bool char
|
||||||
#else
|
#else
|
||||||
#define bool int
|
#define bool int
|
||||||
#endif /* defined(_MSC_VER) && (_MSC_VER > 1020) */
|
#endif // defined(_MSC_VER) && (_MSC_VER > 1020)
|
||||||
#endif /* (!defined __cplusplus) && (!defined bool) */
|
#endif // (!defined __cplusplus) && (!defined bool)
|
||||||
|
|
||||||
|
// ANSI C API BEGINS HERE
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
* ANSI C API BEGINS HERE
|
|
||||||
*/
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,28 +75,24 @@ extern int boinc_suspend_other_activities(void);
|
||||||
extern int boinc_resume_other_activities(void);
|
extern int boinc_resume_other_activities(void);
|
||||||
extern int boinc_report_app_status(double, double, double);
|
extern int boinc_report_app_status(double, double, double);
|
||||||
|
|
||||||
/* we can use those in ANSI-C with a suitable define for 'bool' */
|
// we can use those in ANSI-C with a suitable define for 'bool'
|
||||||
extern bool boinc_is_standalone(void);
|
extern bool boinc_is_standalone(void);
|
||||||
extern bool boinc_receive_trickle_down(char* buf, int len);
|
extern bool boinc_receive_trickle_down(char* buf, int len);
|
||||||
extern bool boinc_time_to_checkpoint();
|
extern bool boinc_time_to_checkpoint();
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" { */
|
} // extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
// C++ API follows
|
||||||
* C++ API follows
|
|
||||||
*/
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "app_ipc.h"
|
#include "app_ipc.h"
|
||||||
|
|
||||||
|
|
||||||
extern APP_INIT_DATA aid;
|
extern APP_INIT_DATA aid;
|
||||||
|
|
||||||
/* C++ prototypes */
|
|
||||||
extern int boinc_init_options(BOINC_OPTIONS&);
|
extern int boinc_init_options(BOINC_OPTIONS&);
|
||||||
extern int boinc_get_status(BOINC_STATUS&);
|
extern int boinc_get_status(BOINC_STATUS&);
|
||||||
extern int boinc_resolve_filename_s(const char*, std::string&);
|
extern int boinc_resolve_filename_s(const char*, std::string&);
|
||||||
|
@ -118,6 +114,6 @@ extern int set_worker_timer(void);
|
||||||
|
|
||||||
/////////// IMPLEMENTATION STUFF ENDS HERE
|
/////////// IMPLEMENTATION STUFF ENDS HERE
|
||||||
|
|
||||||
#endif /* C++ part */
|
#endif // C++ part
|
||||||
|
|
||||||
#endif /* double-inclusion protection */
|
#endif // double-inclusion protection
|
||||||
|
|
|
@ -1,51 +1,69 @@
|
||||||
|
// The contents of this file are subject to the BOINC Public License
|
||||||
|
// Version 1.0 (the "License"); you may not use this file except in
|
||||||
|
// compliance with the License. You may obtain a copy of the License at
|
||||||
|
// http://boinc.berkeley.edu/license_1.0.txt
|
||||||
|
//
|
||||||
|
// Software distributed under the License is distributed on an "AS IS"
|
||||||
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||||
|
// License for the specific language governing rights and limitations
|
||||||
|
// under the License.
|
||||||
|
//
|
||||||
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
||||||
|
//
|
||||||
|
// The Initial Developer of the Original Code is the SETI@home project.
|
||||||
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
||||||
|
// University of California at Berkeley. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Contributor(s):
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BOINC_GRAPHICS_API_H
|
#ifndef BOINC_GRAPHICS_API_H
|
||||||
#define BOINC_GRAPHICS_API_H
|
#define BOINC_GRAPHICS_API_H
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
// PURE ANSI-C API follows here
|
||||||
* PURE ANSI-C API follows here
|
// to allow prototypes using 'bool' in ANSI-C
|
||||||
*/
|
|
||||||
/* to allow prototypes using 'bool' in ANSI-C */
|
|
||||||
#if (!defined __cplusplus) && (!defined bool)
|
#if (!defined __cplusplus) && (!defined bool)
|
||||||
#if ((defined(_MSC_VER)) && (_MSC_VER > 1020))
|
#if ((defined(_MSC_VER)) && (_MSC_VER > 1020))
|
||||||
#define bool char
|
#define bool char
|
||||||
#else
|
#else
|
||||||
#define bool int
|
#define bool int
|
||||||
#endif /* defined(_MSC_VER) && (_MSC_VER > 1020) */
|
#endif // defined(_MSC_VER) && (_MSC_VER > 1020)
|
||||||
#endif /* (!defined __cplusplus) && (!defined bool) */
|
#endif // (!defined __cplusplus) && (!defined bool)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int boinc_init_graphics(void (*worker)());
|
typedef void (*WORKER_FUNC_PTR)();
|
||||||
|
|
||||||
// Functions that must be supplied by the app
|
extern int boinc_init_graphics(WORKER_FUNC_PTR);
|
||||||
// application needs to define mouse, keyboard handlers
|
|
||||||
//
|
// Functions that must be supplied by the app
|
||||||
extern void app_graphics_render(int xs, int ys, double time_of_day);
|
// application needs to define mouse, keyboard handlers
|
||||||
extern void app_graphics_init(void);
|
//
|
||||||
|
extern void app_graphics_render(int xs, int ys, double time_of_day);
|
||||||
|
extern void app_graphics_init(void);
|
||||||
// called each time a window is opened;
|
// called each time a window is opened;
|
||||||
// called in the graphics thread
|
// called in the graphics thread
|
||||||
extern void app_graphics_reread_prefs(void);
|
extern void app_graphics_reread_prefs(void);
|
||||||
// called when get REREAD_PREFS message from core client.
|
// called when get REREAD_PREFS message from core client.
|
||||||
// called in the graphics thread
|
// called in the graphics thread
|
||||||
extern void app_graphics_resize(int width, int height);
|
extern void app_graphics_resize(int width, int height);
|
||||||
extern void boinc_app_mouse_button(int x, int y, int which, bool is_down);
|
extern void boinc_app_mouse_button(int x, int y, int which, bool is_down);
|
||||||
extern void boinc_app_mouse_move(int x, int y, bool left, bool middle, bool right);
|
extern void boinc_app_mouse_move(int x, int y, bool left, bool middle, bool 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
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
// C++ API follows here
|
||||||
* C++ API follows here
|
|
||||||
*/
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
#include "boinc_api.h"
|
#include "boinc_api.h"
|
||||||
|
|
||||||
extern int boinc_init_options_graphics(BOINC_OPTIONS&, void (*worker)());
|
extern int boinc_init_options_graphics(BOINC_OPTIONS&, WORKER_FUNC_PTR);
|
||||||
|
|
||||||
// Implementation stuff
|
// Implementation stuff
|
||||||
//
|
//
|
||||||
|
@ -57,9 +75,9 @@ extern bool throttled_app_render(int, int, double);
|
||||||
extern HANDLE hQuitEvent;
|
extern HANDLE hQuitEvent;
|
||||||
extern HANDLE graphics_threadh;
|
extern HANDLE graphics_threadh;
|
||||||
extern BOOL win_loop_done;
|
extern BOOL win_loop_done;
|
||||||
#endif /* WIN32 */
|
#endif // WIN32
|
||||||
|
|
||||||
|
|
||||||
#endif /* C++ API */
|
#endif // C++ API
|
||||||
|
|
||||||
#endif /* double-inclusion protection */
|
#endif // double-inclusion protection
|
||||||
|
|
|
@ -33,12 +33,13 @@ extern void win_graphics_event_loop();
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include "x_opengl.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD
|
#ifdef HAVE_PTHREAD
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "x_opengl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
@ -59,7 +60,7 @@ HANDLE hQuitEvent;
|
||||||
|
|
||||||
bool graphics_inited = false;
|
bool graphics_inited = false;
|
||||||
|
|
||||||
static void (*worker_main)();
|
static WORKER_FUNC_PTR worker_main;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD WINAPI foobar(LPVOID) {
|
DWORD WINAPI foobar(LPVOID) {
|
||||||
|
@ -71,15 +72,16 @@ void* foobar(void*) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int boinc_init_graphics_impl(
|
// the following function can be in a shared library,
|
||||||
void (*worker)(), int (*init_func)(BOINC_OPTIONS&)
|
// so it calls boinc_init_options_general() via a pointer instead of directly
|
||||||
) {
|
//
|
||||||
|
int boinc_init_graphics_impl(WORKER_FUNC_PTR worker, BIOG_FUNC_PTR init_func) {
|
||||||
BOINC_OPTIONS opt;
|
BOINC_OPTIONS opt;
|
||||||
options_defaults(opt);
|
options_defaults(opt);
|
||||||
return boinc_init_options_graphics_impl(opt, worker, init_func);
|
return boinc_init_options_graphics_impl(opt, worker, init_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
int start_worker_thread(void (*_worker_main)()) {
|
int start_worker_thread(WORKER_FUNC_PTR _worker_main) {
|
||||||
worker_main = _worker_main;
|
worker_main = _worker_main;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
@ -153,12 +155,12 @@ int start_worker_thread(void (*_worker_main)()) {
|
||||||
|
|
||||||
int boinc_init_options_graphics_impl(
|
int boinc_init_options_graphics_impl(
|
||||||
BOINC_OPTIONS& opt,
|
BOINC_OPTIONS& opt,
|
||||||
void (*_worker_main)(),
|
WORKER_FUNC_PTR _worker_main,
|
||||||
int (*init_func)(BOINC_OPTIONS&)
|
BIOG_FUNC_PTR init_func
|
||||||
) {
|
) {
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
retval = (*init_func)(opt);
|
retval = init_func(opt);
|
||||||
if (retval) return retval;
|
if (retval) return retval;
|
||||||
if (_worker_main) {
|
if (_worker_main) {
|
||||||
retval = start_worker_thread(_worker_main);
|
retval = start_worker_thread(_worker_main);
|
||||||
|
|
|
@ -18,21 +18,29 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "boinc_api.h"
|
#include "boinc_api.h"
|
||||||
|
#include "graphics_api.h"
|
||||||
|
|
||||||
|
typedef int (*BIOG_FUNC_PTR)(BOINC_OPTIONS&);
|
||||||
|
// ptr to a function like boinc_init_options_general()
|
||||||
|
|
||||||
|
typedef int (*BIOGI_FUNC_PTR)(BOINC_OPTIONS&, WORKER_FUNC_PTR, BIOG_FUNC_PTR);
|
||||||
|
// ptr to a function like boinc_init_options_graphics_impl()
|
||||||
|
|
||||||
extern int boinc_init_graphics_impl(
|
extern int boinc_init_graphics_impl(
|
||||||
void (*worker)(), int (*init_func)(BOINC_OPTIONS&)
|
WORKER_FUNC_PTR worker, BIOG_FUNC_PTR init_func
|
||||||
);
|
);
|
||||||
|
|
||||||
// This extern C is needed, even to make this code work correctly on a 100% C++
|
// This extern C is needed to make this code work correctly,
|
||||||
// platoform, app, and build. This is because we need to dlsym() resolve this
|
// even in a 100% C++ context.
|
||||||
// function. That does not work unless the symbol is in the library in UNMANGED
|
// This is because we need to dlsym() resolve this function.
|
||||||
// form. See http://www.isotton.com/howtos/C++-dlopen-mini-HOWTO/C++-dlopen-mini-HOWTO.html
|
// That does not work unless the symbol is in the library in UNMANGLED form.
|
||||||
|
// See http://www.isotton.com/howtos/C++-dlopen-mini-HOWTO/C++-dlopen-mini-HOWTO.html
|
||||||
// for some additional discussion.
|
// for some additional discussion.
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
int boinc_init_options_graphics_impl(
|
extern int boinc_init_options_graphics_impl(
|
||||||
BOINC_OPTIONS& opt,
|
BOINC_OPTIONS& opt,
|
||||||
void (*_worker_main)(),
|
WORKER_FUNC_PTR _worker_main,
|
||||||
int (*init_func)(BOINC_OPTIONS&)
|
BIOG_FUNC_PTR init_func
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,14 +25,14 @@
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
#include "boinc_api.h"
|
#include "boinc_api.h"
|
||||||
|
#include "graphics_api.h"
|
||||||
|
#include "graphics_impl.h"
|
||||||
#include "graphics_lib.h"
|
#include "graphics_lib.h"
|
||||||
|
|
||||||
#define BOINC_STRLEN 512
|
#define BOINC_STRLEN 512
|
||||||
|
|
||||||
void* graphics_lib_handle=NULL;
|
void* graphics_lib_handle=NULL;
|
||||||
|
|
||||||
typedef int (*BIOGI_FUNC)(BOINC_OPTIONS&, void(*worker)(), int (*)(BOINC_OPTIONS&));
|
|
||||||
|
|
||||||
// This routine never returns.
|
// This routine never returns.
|
||||||
// If a problem arises, it calls boinc_finish(nonzero).
|
// If a problem arises, it calls boinc_finish(nonzero).
|
||||||
//
|
//
|
||||||
|
@ -42,14 +42,14 @@ typedef int (*BIOGI_FUNC)(BOINC_OPTIONS&, void(*worker)(), int (*)(BOINC_OPTIONS
|
||||||
// This is the executable name, and is used to derive
|
// This is the executable name, and is used to derive
|
||||||
// the shared object library name: executable_name.so
|
// the shared object library name: executable_name.so
|
||||||
|
|
||||||
int boinc_init_graphics_lib(void (*worker)(), char* argv0) {
|
int boinc_init_graphics_lib(WORKER_FUNC_PTR worker, char* argv0) {
|
||||||
BOINC_OPTIONS opt;
|
BOINC_OPTIONS opt;
|
||||||
options_defaults(opt);
|
options_defaults(opt);
|
||||||
return boinc_init_options_graphics_lib(opt, worker, argv0);
|
return boinc_init_options_graphics_lib(opt, worker, argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int boinc_init_options_graphics_lib(
|
int boinc_init_options_graphics_lib(
|
||||||
BOINC_OPTIONS& opt, void (*worker)(), char* argv0
|
BOINC_OPTIONS& opt, WORKER_FUNC_PTR worker, char* argv0
|
||||||
) {
|
) {
|
||||||
char graphics_lib[BOINC_STRLEN];
|
char graphics_lib[BOINC_STRLEN];
|
||||||
char resolved_name[BOINC_STRLEN];
|
char resolved_name[BOINC_STRLEN];
|
||||||
|
@ -58,7 +58,7 @@ int boinc_init_options_graphics_lib(
|
||||||
int retval;
|
int retval;
|
||||||
char *errormsg;
|
char *errormsg;
|
||||||
|
|
||||||
BIOGI_FUNC boinc_init_options_graphics_impl_hook;
|
BIOGI_FUNC_PTR boinc_init_options_graphics_impl_hook;
|
||||||
|
|
||||||
// figure out name of executable, and append .so
|
// figure out name of executable, and append .so
|
||||||
//
|
//
|
||||||
|
@ -98,7 +98,7 @@ int boinc_init_options_graphics_lib(
|
||||||
// use handle from shared library to resolve the 'initialize
|
// use handle from shared library to resolve the 'initialize
|
||||||
// graphics' routine from shared library
|
// graphics' routine from shared library
|
||||||
//
|
//
|
||||||
boinc_init_options_graphics_impl_hook = (BIOGI_FUNC) dlsym(
|
boinc_init_options_graphics_impl_hook = (BIOGI_FUNC_PTR) dlsym(
|
||||||
graphics_lib_handle,
|
graphics_lib_handle,
|
||||||
"boinc_init_options_graphics_impl"
|
"boinc_init_options_graphics_impl"
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,15 +21,15 @@
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern int boinc_init_graphics_lib(void (*worker)(), char* argv0);
|
extern int boinc_init_graphics_lib(WORKER_FUNC_PTR worker, char* argv0);
|
||||||
extern void* graphics_lib_handle;
|
extern void* graphics_lib_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int boinc_init_options_graphics_lib(
|
extern int boinc_init_options_graphics_lib(
|
||||||
BOINC_OPTIONS&, void (*worker)(), char* argv0
|
BOINC_OPTIONS&, WORKER_FUNC_PTR worker, char* argv0
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
extern int boinc_init_graphics_lib(void (*worker)(), char* argv0);
|
extern int boinc_init_graphics_lib(WORKER_FUNC_PTR worker, char* argv0);
|
||||||
extern void* graphics_lib_handle;
|
extern void* graphics_lib_handle;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21155,3 +21155,12 @@ Bruce 12 Dec 2004
|
||||||
graphics_lib.C
|
graphics_lib.C
|
||||||
graphics_lib.h
|
graphics_lib.h
|
||||||
graphics_impl.h
|
graphics_impl.h
|
||||||
|
|
||||||
|
David 12 Dec 2004
|
||||||
|
- spruced up graphics lib stuff, removed a "*" that may have caused crash.
|
||||||
|
|
||||||
|
api/
|
||||||
|
boinc_api.h
|
||||||
|
graphics_api.h
|
||||||
|
graphics_impl.C,h
|
||||||
|
graphics_lib.C,h
|
||||||
|
|
Loading…
Reference in New Issue