[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11311] branches/ndof/source/blender: commiting ettore fourth patch (plugin path)
JLuc Peuriere
jlp at nerim.net
Wed Jul 18 23:16:07 CEST 2007
Revision: 11311
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11311
Author: lukep
Date: 2007-07-18 23:16:07 +0200 (Wed, 18 Jul 2007)
Log Message:
-----------
commiting ettore fourth patch (plugin path)
Modified Paths:
--------------
branches/ndof/source/blender/blenlib/BLI_blenlib.h
branches/ndof/source/blender/blenloader/intern/writefile.c
branches/ndof/source/blender/src/ghostwinlay.c
Modified: branches/ndof/source/blender/blenlib/BLI_blenlib.h
===================================================================
--- branches/ndof/source/blender/blenlib/BLI_blenlib.h 2007-07-18 19:00:03 UTC (rev 11310)
+++ branches/ndof/source/blender/blenlib/BLI_blenlib.h 2007-07-18 21:16:07 UTC (rev 11311)
@@ -247,6 +247,7 @@
*/
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
*
Modified: branches/ndof/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/ndof/source/blender/blenloader/intern/writefile.c 2007-07-18 19:00:03 UTC (rev 11310)
+++ branches/ndof/source/blender/blenloader/intern/writefile.c 2007-07-18 21:16:07 UTC (rev 11311)
@@ -1981,7 +1981,7 @@
#define PATHSEPERATOR "/"
#endif
-static char *get_install_dir(void) {
+char *get_install_dir(void) {
extern char bprogname[];
char *tmpname = BLI_strdup(bprogname);
char *cut;
Modified: branches/ndof/source/blender/src/ghostwinlay.c
===================================================================
--- branches/ndof/source/blender/src/ghostwinlay.c 2007-07-18 19:00:03 UTC (rev 11310)
+++ branches/ndof/source/blender/src/ghostwinlay.c 2007-07-18 21:16:07 UTC (rev 11311)
@@ -889,21 +889,53 @@
return active_gl_window;
}
+#ifdef _WIN32
+#define PATH_SEP "\\"
+#else
+#define PATH_SEP "/"
+#endif
+
+
void window_open_ndof(Window* win)
{
- PILdynlib* ndofLib = PIL_dynlib_open("XXXXXXX-PUT-HERE-YOUR-PATH-TO-THE-PLUG--/spaceplug.plug");
- 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"));
-
-// original patch only
-// PIL_dynlib_find_symbol(ndofLib, "ndofEventHandler"));
- }
+ 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);
}
}
More information about the Bf-blender-cvs
mailing list