From 256de79f51889067626514d974423a07a50dfdf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Luc=20Peuri=C3=A8re?= Date: Wed, 18 Jul 2007 21:16:07 +0000 Subject: commiting ettore fourth patch (plugin path) --- source/blender/blenlib/BLI_blenlib.h | 1 + source/blender/blenloader/intern/writefile.c | 2 +- source/blender/src/ghostwinlay.c | 56 ++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 13 deletions(-) (limited to 'source') diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h index 6e51d171461..75a0e7b49a1 100644 --- a/source/blender/blenlib/BLI_blenlib.h +++ b/source/blender/blenlib/BLI_blenlib.h @@ -247,6 +247,7 @@ void BLI_free_file_lines(struct LinkNode *lines); */ void BLI_where_am_i(char *fullname, char *name); +char *get_install_dir(void); /** * determines the full path to the application bundle on OS X * diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 226561ab97b..9ab1321b45e 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1981,7 +1981,7 @@ int BLO_write_file_mem(MemFile *compare, MemFile *current, int write_flags, char #define PATHSEPERATOR "/" #endif -static char *get_install_dir(void) { +char *get_install_dir(void) { extern char bprogname[]; char *tmpname = BLI_strdup(bprogname); char *cut; diff --git a/source/blender/src/ghostwinlay.c b/source/blender/src/ghostwinlay.c index 0a04b0b8003..60cbc4d89ba 100644 --- a/source/blender/src/ghostwinlay.c +++ b/source/blender/src/ghostwinlay.c @@ -889,21 +889,53 @@ Window *winlay_get_active_window(void) { return active_gl_window; } -void window_open_ndof(Window* win) -{ - PILdynlib* ndofLib = PIL_dynlib_open("XXXXXXX-PUT-HERE-YOUR-PATH-TO-THE-PLUG--/spaceplug.plug"); - if (ndofLib) { +#ifdef _WIN32 +#define PATH_SEP "\\" +#else +#define PATH_SEP "/" +#endif - GHOST_OpenNDOF(g_system, win->ghostwin, - PIL_dynlib_find_symbol(ndofLib, "ndofInit"), - PIL_dynlib_find_symbol(ndofLib, "ndofShutdown"), - PIL_dynlib_find_symbol(ndofLib, "ndofOpen")); -// original patch only -// PIL_dynlib_find_symbol(ndofLib, "ndofEventHandler")); - } +void window_open_ndof(Window* win) +{ + char *inst_path, *plug_path; + const char *plug_dir = "plugins"; + const char *plug_name = "3DxNdofBlender.plug"; + PILdynlib *ndofLib; + + // build the plugin path + plug_path = NULL; + inst_path = get_install_dir(); // path to main blender exec/bundle + if (inst_path) { + // assume the ndof plugin is located in the plug-in dir + size_t len = strlen(inst_path) + strlen(plug_dir) + strlen(PATH_SEP)*2 + + strlen(plug_name) + 1; + plug_path = MEM_mallocN(len, "ndofpluginpath"); + if (plug_path) { + strncpy(plug_path, inst_path, len); + strcat(plug_path, PATH_SEP); + strcat(plug_path, plug_dir); + strcat(plug_path, PATH_SEP); + strcat(plug_path, plug_name); + } + MEM_freeN(inst_path); + } + + ndofLib = PIL_dynlib_open(plug_path); +#if 0 + fprintf(stderr, "plugin path=%s; ndofLib=%p\n", plug_path, (void*)ndofLib); +#endif + + if (plug_path) + MEM_freeN(plug_path); + + if (ndofLib) { + GHOST_OpenNDOF(g_system, win->ghostwin, + PIL_dynlib_find_symbol(ndofLib, "ndofInit"), + PIL_dynlib_find_symbol(ndofLib, "ndofShutdown"), + PIL_dynlib_find_symbol(ndofLib, "ndofOpen")); + } else { -// GHOST_OpenNDOF(g_system, win->ghostwin, 0, 0, 0, 0); GHOST_OpenNDOF(g_system, win->ghostwin, 0, 0, 0); } } -- cgit v1.2.3