diff --git a/include/osg/Export b/include/osg/Export index 3f876ed7e..2c56e2de3 100644 --- a/include/osg/Export +++ b/include/osg/Export @@ -5,14 +5,14 @@ #ifndef OSG_EXPORT #define OSG_EXPORT 1 -#ifdef WIN32 +#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) #pragma warning( disable : 4275 ) #pragma warning( disable : 4786 ) #endif -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) # ifdef SG_LIBRARY # define SG_EXPORT __declspec(dllexport) # else diff --git a/include/osg/GL b/include/osg/GL index 717fd583f..11b9e1612 100644 --- a/include/osg/GL +++ b/include/osg/GL @@ -24,6 +24,18 @@ #else +#if defined(__CYGWIN__) || defined(__MINGW32__) +# ifndef APIENTRY +# define GLUT_APIENTRY_DEFINED +# define APIENTRY __stdcall +# endif + // XXX This is from Win32's +# ifndef CALLBACK +# define CALLBACK __stdcall +# endif + +#else // ! __CYGWIN__ + // Under windows avoid including // to avoid name space pollution, but Win32's // needs APIENTRY and WINGDIAPI defined properly. @@ -49,17 +61,20 @@ # define CALLBACK # endif # endif - // XXX This is from Win32's and - # ifndef WINGDIAPI - # define GLUT_WINGDIAPI_DEFINED - # define WINGDIAPI __declspec(dllimport) - # endif - // XXX This is from Win32's - # ifndef _WCHAR_T_DEFINED - typedef unsigned short wchar_t; - # define _WCHAR_T_DEFINED - # endif - # endif + +#endif // __CYGWIN__ + + // XXX This is from Win32's and +# ifndef WINGDIAPI +# define GLUT_WINGDIAPI_DEFINED +# define WINGDIAPI __declspec(dllimport) +# endif + // XXX This is from Win32's +# ifndef _WCHAR_T_DEFINED +typedef unsigned short wchar_t; +# define _WCHAR_T_DEFINED +# endif +# endif #ifndef __gl_h_ #include diff --git a/include/osg/Math b/include/osg/Math index 8cf060f2b..d82f26a20 100644 --- a/include/osg/Math +++ b/include/osg/Math @@ -7,13 +7,9 @@ #include -#if defined(WIN32) - // needed for _isnan & _finite used below. - #include -#endif - #if defined(WIN32) || defined (macintosh) #include +#if !defined(__CYGWIN__) #define M_E 2.7182818284590452354 #define M_LOG2E 1.4426950408889634074 #define M_LOG10E 0.43429448190325182765 @@ -27,6 +23,7 @@ #define M_2_SQRTPI 1.12837916709551257390 #define M_SQRT2 1.41421356237309504880 #define M_SQRT1_2 0.70710678118654752440 +#endif // __CYGWIN__ #endif // PJA MAC OSX @@ -75,7 +72,7 @@ inline double inRadians(double angle) { return angle; } inline double DegreesToRadians(double angle) { return angle*M_PI/180.0; } inline double RadiansToDegrees(double angle) { return angle*180.0/M_PI; } -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) inline bool isNaN(float v) { return ::_isnan(v)!=0; } inline bool isNaN(double v) { return ::_isnan(v)!=0; } inline bool isInfinite(float v) { return !::_finite(v); } diff --git a/include/osg/Timer b/include/osg/Timer index e72d5eb16..9f83621b2 100644 --- a/include/osg/Timer +++ b/include/osg/Timer @@ -10,9 +10,9 @@ namespace osg { -#ifdef WIN32 +#if defined(WIN32 ) && !defined(__CYGWIN__) typedef __int64 Timer_t; -#elif defined(__linux) || defined(__FreeBSD__) +#elif defined(__linux) || defined(__FreeBSD__) || defined(__CYGWIN__) typedef unsigned long long Timer_t; #elif defined(__sgi) typedef unsigned long long Timer_t; @@ -61,7 +61,7 @@ class SG_EXPORT Timer { }; -#ifdef WIN32 +#if defined(_WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) #include #pragma optimize("",off) @@ -92,7 +92,7 @@ namespace osg{ }; #pragma optimize("",on) -#elif defined(__linux) || defined(__FreeBSD__) +#elif defined(__linux) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__MINGW32__) #include diff --git a/include/osgDB/Export b/include/osgDB/Export index 2b717696c..c4f2649ba 100644 --- a/include/osgDB/Export +++ b/include/osgDB/Export @@ -5,15 +5,15 @@ #ifndef OSGDB_EXPORT_ #define OSGDB_EXPORT_ 1 -#ifdef WIN32 - #pragma warning( disable : 4244 ) +#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) + #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) #pragma warning( disable : 4275 ) #pragma warning( disable : 4786 ) #endif -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) # ifdef OSGDB_LIBRARY # define OSGDB_EXPORT __declspec(dllexport) # else diff --git a/include/osgGLUT/Export b/include/osgGLUT/Export index 2bf16de79..43791235c 100644 --- a/include/osgGLUT/Export +++ b/include/osgGLUT/Export @@ -6,14 +6,14 @@ #ifndef OSGGLUT_EXPORT_ #define OSGGLUT_EXPORT_ 1 -#ifdef WIN32 - #pragma warning( disable : 4244 ) +#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) + #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) #pragma warning( disable : 4275 ) #pragma warning( disable : 4786 ) #endif -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) # ifdef OSGGLUT_LIBRARY # define OSGGLUT_EXPORT __declspec(dllexport) # else diff --git a/include/osgText/Export b/include/osgText/Export index 56e1b560a..41bb5ae05 100644 --- a/include/osgText/Export +++ b/include/osgText/Export @@ -5,7 +5,7 @@ #ifndef OSGTEXT_EXPORT_ #define OSGTEXT_EXPORT_ 1 -#ifdef WIN32 +#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) #pragma warning( disable : 4275 ) @@ -13,7 +13,7 @@ #endif -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) # ifdef OSGTEXT_LIBRARY # define OSGTEXT_EXPORT __declspec(dllexport) # else diff --git a/include/osgUtil/Export b/include/osgUtil/Export index 5fe2bd6cc..da7a6f55d 100644 --- a/include/osgUtil/Export +++ b/include/osgUtil/Export @@ -6,14 +6,14 @@ #ifndef OSGUTIL_EXPORT_ #define OSGUTIL_EXPORT_ 1 -#ifdef WIN32 - #pragma warning( disable : 4244 ) +#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) + #pragma warning( disable : 4244 ) #pragma warning( disable : 4251 ) #pragma warning( disable : 4275 ) #pragma warning( disable : 4786 ) #endif -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) # ifdef OSGUTIL_LIBRARY # define OSGUTIL_EXPORT __declspec(dllexport) # else diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 3f3aa84f9..a0364c079 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -1,4 +1,4 @@ -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) #include #elif !defined macintosh #include diff --git a/src/osg/Notify.cpp b/src/osg/Notify.cpp index 171fda247..e66491058 100644 --- a/src/osg/Notify.cpp +++ b/src/osg/Notify.cpp @@ -26,7 +26,7 @@ bool osg::initNotifyLevel() g_NotifyInit = true; // set up global notify null stream for inline notify -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) g_NotifyNulStream = new std::ofstream ("nul"); #else g_NotifyNulStream = new std::ofstream ("/dev/null"); diff --git a/src/osgDB/DynamicLibrary.cpp b/src/osgDB/DynamicLibrary.cpp index fb5d3b172..74c7bed5a 100644 --- a/src/osgDB/DynamicLibrary.cpp +++ b/src/osgDB/DynamicLibrary.cpp @@ -1,4 +1,4 @@ -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) #include #include #include @@ -25,7 +25,7 @@ DynamicLibrary::~DynamicLibrary() { if (_handle) { -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) FreeLibrary((HMODULE)_handle); #elif !defined(macintosh) dlclose(_handle); @@ -39,7 +39,7 @@ DynamicLibrary* DynamicLibrary::loadLibrary(const std::string& libraryName) char* fullLibraryName = osgDB::findDSO( libraryName.c_str() ); if (fullLibraryName==NULL) return NULL; -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) HANDLE handle = LoadLibrary( fullLibraryName ); if (handle) return new DynamicLibrary(libraryName,handle); notify(WARN) << "DynamicLibrary::failed loading "< #include #include @@ -41,7 +41,7 @@ inline static char* strdup(const char *src) #endif #endif -#ifdef WIN32 +#if defined(WIN32) &&!defined(__CYGWIN__) char *PathDelimitor = ";"; static const char *s_default_file_path = ".;"; static const char *s_default_dso_path = "C:/Windows/System/;"; @@ -59,11 +59,15 @@ static char *s_filePath = ".:"; #else char *PathDelimitor = ":"; static const char *s_default_file_path = ".:"; +#if defined(__CYGWIN__) static const char *s_default_dso_path = "/usr/lib/:/usr/local/lib/:"; +#else +static const char *s_default_dso_path = "/usr/lib/:/usr/local/lib/:"; +#endif // __CYGWIN__ static char *s_filePath = ".:"; #endif -#if defined (WIN32) +#if defined(WIN32) &&!defined(__CYGWIN__) #define F_OK 4 #endif @@ -195,7 +199,7 @@ char *osgDB::findDSO( const char *name ) { #ifndef macintosh - #ifdef __linux + #if defined(__linux) || defined(__CYGWIN__) if( access( name, F_OK ) == 0 ) { if (name[0]!='/') @@ -259,7 +263,7 @@ char *osgDB::findDSO( const char *name ) } #endif -#elif WIN32 +#elif defined(WIN32) if ((ptr = getenv( "PATH" ))) { @@ -268,13 +272,13 @@ char *osgDB::findDSO( const char *name ) strcat( path, ptr ); } - #else +#else if( (ptr = getenv( "LD_LIBRARY_PATH" ))) { strcat( path, PathDelimitor ); strcat( path, ptr ); } - #endif +#endif // check existance of dso assembled direct paths. char* fileFound = NULL; @@ -341,7 +345,7 @@ std::string osgDB::findFileInDirectory(const std::string& fileName,const std::st } -#ifdef WIN32 +#if defined(WIN32) &&!defined(__CYGWIN__) #include #include diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index bdd430a94..31f2249a8 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -222,6 +222,7 @@ std::string Registry::createLibraryNameForExt(const std::string& ext) if (itr!=_extAliasMap.end()) return createLibraryNameForExt(itr->second); #if defined(WIN32) +// !! recheck evolving Cygwin DLL extension naming protocols !! NHV # ifdef _DEBUG return "osgdb_"+ext+"d.dll"; # else diff --git a/src/osgGLUT/Viewer.cpp b/src/osgGLUT/Viewer.cpp index 08d2e5df6..6b06668d9 100644 --- a/src/osgGLUT/Viewer.cpp +++ b/src/osgGLUT/Viewer.cpp @@ -3,7 +3,7 @@ #endif #include -#if !defined(WIN32) && !defined(macintosh) +#if (!defined(WIN32) && !defined(macintosh)) || defined(__CYGWIN__) #include #include #endif @@ -50,7 +50,7 @@ #include -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) #include #else #endif diff --git a/src/osgPlugins/flt/GeoSetBuilder.cpp b/src/osgPlugins/flt/GeoSetBuilder.cpp index c42e4696b..d3afa016f 100644 --- a/src/osgPlugins/flt/GeoSetBuilder.cpp +++ b/src/osgPlugins/flt/GeoSetBuilder.cpp @@ -1,6 +1,6 @@ // GeoSetBuilder.cpp -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) #pragma warning( disable : 4786 ) #endif diff --git a/src/osgPlugins/flt/Pool.cpp b/src/osgPlugins/flt/Pool.cpp index e2afa76aa..677692936 100644 --- a/src/osgPlugins/flt/Pool.cpp +++ b/src/osgPlugins/flt/Pool.cpp @@ -1,6 +1,6 @@ // Pool.cpp -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) #pragma warning( disable : 4786 ) #endif diff --git a/src/osgPlugins/flt/ReaderWriterFLT.cpp b/src/osgPlugins/flt/ReaderWriterFLT.cpp index 53900ad5e..63323fbf4 100644 --- a/src/osgPlugins/flt/ReaderWriterFLT.cpp +++ b/src/osgPlugins/flt/ReaderWriterFLT.cpp @@ -1,6 +1,6 @@ // ReaderWriterFLT.cpp -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) #pragma warning( disable : 4786 ) #endif diff --git a/src/osgPlugins/flt/Registry.h b/src/osgPlugins/flt/Registry.h index d7ebebe86..d04b74734 100644 --- a/src/osgPlugins/flt/Registry.h +++ b/src/osgPlugins/flt/Registry.h @@ -1,7 +1,7 @@ #ifndef __FLT_REGISTRY_H #define __FLT_REGISTRY_H -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) #pragma warning( disable : 4786 ) #endif diff --git a/src/osgPlugins/flt/flt.h b/src/osgPlugins/flt/flt.h index eb2a21cc2..9856e10df 100644 --- a/src/osgPlugins/flt/flt.h +++ b/src/osgPlugins/flt/flt.h @@ -6,6 +6,10 @@ #include +#ifdef __CYGWIN__ +#include +#endif + namespace flt { #define ENDIAN2(SRC, DST) endian2((void*)&(SRC), sizeof(SRC), (void*)&(DST), sizeof(DST)) diff --git a/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp b/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp index 1752a5c49..30cb95331 100644 --- a/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp +++ b/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp @@ -13,7 +13,7 @@ #include #include -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__CYGWIN__) #include #else #include @@ -40,7 +40,7 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter char dirname[128]; char command[1024]; - #ifdef _WIN32 + #if defined(_WIN32) && !defined(__CYGWIN__) sprintf( dirname, "C:/Windows/Temp/.osgdb_osgtgz"); // note, the following C option under windows does not seem to work... // will pursue an better tar.exe later. RO. @@ -50,7 +50,7 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter mkdir( dirname); #endif - #ifdef __linux + #if defined(__linux) || defined(__CYGWIN__) sprintf( dirname, "/tmp/.osg%06d", getpid()); sprintf( command, "tar xfCz %s %s", @@ -86,7 +86,7 @@ class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter } } - #ifdef _WIN32 + #if defined(_WIN32) && !defined(__CYGWIN__) // note, is this the right command for windows? // is there any way of overiding the Y/N option? RO. sprintf( command, "erase %s", dirname ); diff --git a/src/osgPlugins/tgz/ReaderWriterTGZ.cpp b/src/osgPlugins/tgz/ReaderWriterTGZ.cpp index 13a60eefa..064eb263c 100644 --- a/src/osgPlugins/tgz/ReaderWriterTGZ.cpp +++ b/src/osgPlugins/tgz/ReaderWriterTGZ.cpp @@ -13,7 +13,7 @@ #include #include -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__CYGWIN__) #include #else #include @@ -41,7 +41,7 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter char dirname[128]; char command[1024]; - #ifdef _WIN32 + #if defined(_WIN32) && !defined(__CYGWIN__) strcpy(dirname, "C:/Windows/Temp/.osgdb_tgz"); mkdir( dirname); // note, the following C option under windows does not seem to work... @@ -51,7 +51,7 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter fileName.c_str(), dirname ); #endif - #ifdef __linux + #if defined(__linux) || defined(__CYGWIN__) sprintf( dirname, "/tmp/.tgz%06d", getpid()); mkdir( dirname, 0700 ); sprintf( command, @@ -94,7 +94,7 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter // restorre original state of the automatic generation of images to geode's. osgDB::Registry::instance()->setCreateNodeFromImage(prevCreateNodeFromImage); - #ifdef _WIN32 + #if defined(_WIN32) && !defined(__CYGWIN__) // note, is this the right command for windows? // is there any way of overiding the Y/N option? RO. sprintf( command, "erase %s", dirname ); diff --git a/src/osgPlugins/zip/ReaderWriterZIP.cpp b/src/osgPlugins/zip/ReaderWriterZIP.cpp index a5b7bb446..4cebecd95 100644 --- a/src/osgPlugins/zip/ReaderWriterZIP.cpp +++ b/src/osgPlugins/zip/ReaderWriterZIP.cpp @@ -13,7 +13,7 @@ #include #include -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__CYGWIN__) #include #else #include @@ -40,7 +40,7 @@ class ReaderWriterZIP : public osgDB::ReaderWriter char dirname[128]; char command[1024]; - #ifdef _WIN32 + #if defined(_WIN32) && !defined(__CYGWIN__) strcpy(dirname, "C:/Windows/Temp/.osgdb_zip"); mkdir(dirname); sprintf( command, @@ -83,7 +83,7 @@ class ReaderWriterZIP : public osgDB::ReaderWriter osgDB::Registry::instance()->setCreateNodeFromImage(prevCreateNodeFromImage); - #ifdef _WIN32 + #if defined(_WIN32) && !defined(__CYGWIN__) // note, is this the right command for windows? // is there any way of overiding the Y/N option? RO. sprintf( command, "erase %s", dirname ); diff --git a/src/osgUtil/NvTriStripObjects.h b/src/osgUtil/NvTriStripObjects.h index 99fc08c9e..8f4fb842f 100644 --- a/src/osgUtil/NvTriStripObjects.h +++ b/src/osgUtil/NvTriStripObjects.h @@ -12,7 +12,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -typedef int WORD; +typedef int nvWORD; typedef unsigned int UINT; struct MyVertex @@ -165,7 +165,7 @@ typedef std::list NvFaceInfoList; typedef std::list NvStripList; typedef std::vector NvEdgeInfoVec; -typedef std::vector WordVec; +typedef std::vector WordVec; typedef std::vector MyVertexVec; typedef std::vector MyFaceVec;