diff options
author | Alejandro Conty Estevez <conty@yafray.org> | 2004-01-08 02:40:19 +0300 |
---|---|---|
committer | Alejandro Conty Estevez <conty@yafray.org> | 2004-01-08 02:40:19 +0300 |
commit | 50b7c10a7de6544caa8bb2aedb5d9a0f75a1f01d (patch) | |
tree | 2603143d367a8cdc94afb63f62c4e0ed592874f8 /source/blender/yafray | |
parent | d959b8127baff7a43230546324f556361277a7c4 (diff) |
Possible definitive fix for the problem of not finding yafray executable
on win32. Since yafray saves its installation path in the registry, we read it
from there and convert to a legal path for system()
Diffstat (limited to 'source/blender/yafray')
-rw-r--r-- | source/blender/yafray/intern/yafray_Render.cpp | 66 | ||||
-rw-r--r-- | source/blender/yafray/intern/yafray_Render.h | 1 |
2 files changed, 67 insertions, 0 deletions
diff --git a/source/blender/yafray/intern/yafray_Render.cpp b/source/blender/yafray/intern/yafray_Render.cpp index 8cd0f4d271f..8622eb85b23 100644 --- a/source/blender/yafray/intern/yafray_Render.cpp +++ b/source/blender/yafray/intern/yafray_Render.cpp @@ -119,9 +119,12 @@ bool yafrayRender_t::exportScene() clearAll(); // file exported, now render + /* char yfr[1024]; sprintf(yfr, "yafray -c %d \"%s\"", R.r.YF_numprocs, xmlpath.c_str()); if(system(yfr)==0) + */ + if(executeYafray(xmlpath)) displayImage(); else { @@ -1210,6 +1213,69 @@ bool yafrayRender_t::writeWorld() return true; } +#ifdef WIN32 + +#include<windows.h> + +#ifndef FILE_MAXDIR +#define FILE_MAXDIR 160 +#endif + +#ifndef FILE_MAXFILE +#define FILE_MAXFILE 80 +#endif + +static string find_path () +{ + HKEY hkey; + DWORD dwType, dwSize; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\YafRay Team\\YafRay",0,KEY_READ,&hkey)==ERROR_SUCCESS) + { + dwType = REG_EXPAND_SZ; + dwSize = MAX_PATH; + DWORD dwStat; + + char *pInstallDir=new char[MAX_PATH]; + + dwStat=RegQueryValueEx(hkey, TEXT("InstallDir"), + NULL, NULL,(LPBYTE)pInstallDir, &dwSize); + + if (dwStat == NO_ERROR) + { + string res=pInstallDir; + delete [] pInstallDir; + return res; + } + else + cout << "Couldn't READ \'InstallDir\' value. Is yafray correctly installed?\n"; + delete [] pInstallDir; + + RegCloseKey(hkey); + } + else + cout << "Couldn't FOUND registry key.for yafray, is it installed?\n"; + + return string(""); + +} +#endif + +bool yafrayRender_t::executeYafray(const string &xmlpath) +{ + char yfr[8]; + sprintf(yfr, "%d ", R.r.YF_numprocs); +#ifdef WIN32 + char path[FILE_MAXDIR+FILE_MAXFILE]; + GetShortPathName((LPCTSTR)(find_path().c_str()), path, FILE_MAXDIR+FILE_MAXFILE); + string command=string(path)+"\\yafray -c "+yfr+"\""+xmlpath+"\""; +#else + string command=string("yafray -c ")+yfr+"\""+xmlpath+"\""; +#endif + return system(command.c_str())==0; +} + + yafrayRender_t YAFBLEND; extern "C" diff --git a/source/blender/yafray/intern/yafray_Render.h b/source/blender/yafray/intern/yafray_Render.h index da3ae40714d..3a46f025115 100644 --- a/source/blender/yafray/intern/yafray_Render.h +++ b/source/blender/yafray/intern/yafray_Render.h @@ -108,6 +108,7 @@ private: void writePathlight(); bool writeWorld(); void clearAll(); + bool executeYafray(const std::string &xmlpath); }; |