diff --git a/Make/cygwin_plugin_def b/Make/cygwin_plugin_def index a7a806c4d..010d27c76 100644 --- a/Make/cygwin_plugin_def +++ b/Make/cygwin_plugin_def @@ -8,3 +8,8 @@ TARGET_BASENAME := $(PLUGIN_PREFIX)$(TARGET_BASENAME) PLUGIN_PREFIX := cyg endif +ifeq ($(OS),MINGW) +TARGET_BASENAME := $(PLUGIN_PREFIX)$(TARGET_BASENAME) +PLUGIN_PREFIX := lib +endif + diff --git a/Make/makedefs b/Make/makedefs index c15592541..4f6d1597b 100644 --- a/Make/makedefs +++ b/Make/makedefs @@ -12,6 +12,11 @@ ifeq ($(findstring CYGWIN,$(OS)),CYGWIN) OS := CYGWIN endif +## Make MINGW_XXXX MINGW so it's "Windows cross platform" :) +ifeq ($(findstring MINGW,$(OS)),MINGW) +OS := MINGW +endif + # TOPDIR needs to be redefined for every Makefile TOPDIR ?= ../ THISDIR = . @@ -310,6 +315,78 @@ ifeq ($(OS),CYGWIN) endif +#### Cygwin/Mingw specific definitions +ifeq ($(OS),MINGW) + C++ = c++ + DEPARG = -M + INC += + DEF += -DWIN32 -Wall +# -W + OPTF = -O2 + DBGF = -g + SHARED = -shared\ + -Wl,--export-all-symbols \ + -Wl,--output-def,lib$(TARGET_BASENAME).def \ + -Wl,--out-implib,$(TOPDIR)/lib/lib$(TARGET_BASENAME).dll.a \ + + ARCHARGS = + LINKARGS = -W -Wall + DYNAMICLIBRARYLIB = + + OSG_LIBS = -losgGLUT -losgDB -losgUtil -losg + GL_LIBS = -lglu32 -lopengl32 + GLUT_LIB = -lglut32 $(GL_LIBS) + X_LIBS = -lgdi32 -luser32 + OSGDB_LIBS = -losgdb_3ds \ + -losgdb_bmp \ + -losgdb_dw \ + -losgdb_flt \ + -losgdb_jpg \ + -losgdb_lwo \ + -losgdb_obj \ + -losgdb_osg \ + -losgdb_osgtgz \ + -losgdb_pic \ + -losgdb_png \ + -losgdb_rgb \ + -losgdb_tga \ + -losgdb_tgz \ + -losgdb_tiff \ + -losgdb_zip + SOCKET_LIBS = + OTHER_LIBS = $(GL_LIBS) + PNG_LIBS = -lpng -lz + JPEG_LIBS = -ljpeg + GIF_LIBS = -lungif + TIFF_LIB = -ltiff -lz -ljpeg + FREETYPE_LIB = -lfreetype + + +# LIB_PREFIX = cyg + LIB_PREFIX = lib + LIB_EXT = dll + PLUGIN_EXT = dll + + LINK = cp -f + + INST_SYS_PREFIX = /usr/local/OpenSceneGraph + INST_LIBS = $(INST_SYS_PREFIX)/bin + INST_PLUGINS = $(INST_SYS_PREFIX)/bin + INST_INCLUDE = $(INST_SYS_PREFIX)/include + INST_SHARE_PREFIX = /usr/local/OpenSceneGraph + INST_DEMOS = $(INST_SHARE_PREFIX)/bin + INST_DEMO_SRC = $(INST_SHARE_PREFIX)/src/demos + INST_DOC = $(INST_SHARE_PREFIX)/doc + INST_DATA = $(INST_SHARE_PREFIX)/data + + PLUGIN_DIRS = osg rgb lib3ds flt obj lwo bmp pic tga osgtgz tgz zip +# txp + DEMOS_DIRS = hangglide osgbillboard osgconv osgcopy osgcube osgimpostor\ + osgreflect osgscribe osgstereoimage osgtexture osgviews \ + osgversion sgv osghud osgtext +# osgcluster +endif + VPATH=.. diff --git a/include/osg/Math b/include/osg/Math index a5ea3a3a3..26e58d6fb 100644 --- a/include/osg/Math +++ b/include/osg/Math @@ -113,7 +113,7 @@ inline T RadiansToDegrees(T angle) { return angle*(T)180.0/(T)PI; } template inline float computeVolume(const T& a,const T& b,const T& c,const T& d) { - return fabs(((b-c)^(a-b))*(d-b)); + return fabsf(((b-c)^(a-b))*(d-b)); } /** compute the volume of prism */ diff --git a/src/Demos/osgoccluder/osgoccluder.cpp b/src/Demos/osgoccluder/osgoccluder.cpp index cb78c0854..278915dab 100644 --- a/src/Demos/osgoccluder/osgoccluder.cpp +++ b/src/Demos/osgoccluder/osgoccluder.cpp @@ -57,9 +57,12 @@ void write_usage(std::ostream& out,const std::string& name) osg::Node* createOccludersAroundModel(osg::Node* model) { osg::Group* scene = osgNew osg::Group; + scene->setName("rootgroup"); + // add the loaded model into a the scene group. scene->addChild(model); + model->setName("model"); // create and occluder which will site along side the loadmodel model. @@ -77,6 +80,7 @@ osg::Node* createOccludersAroundModel(osg::Node* model) // attach it to the occluder node. occluderNode->setOccluder(cpo); + occluderNode->setName("occluder"); // set the occluder up for the front face of the bounding box. osg::ConvexPlanerPolygon& occluder = cpo->getOccluder(); diff --git a/src/osg/CollectOccludersVisitor.cpp b/src/osg/CollectOccludersVisitor.cpp index 45926afd1..ece017a14 100644 --- a/src/osg/CollectOccludersVisitor.cpp +++ b/src/osg/CollectOccludersVisitor.cpp @@ -12,12 +12,12 @@ CollectOccludersVisitor::CollectOccludersVisitor() // overide the default node visitor mode. setTraversalMode(NodeVisitor::TRAVERSE_ACTIVE_CHILDREN); - /*setCullingMode(VIEW_FRUSTUM_CULLING| + setCullingMode(VIEW_FRUSTUM_CULLING| NEAR_PLANE_CULLING| FAR_PLANE_CULLING| - SMALL_FEATURE_CULLING);*/ + SMALL_FEATURE_CULLING); - _minimumShadowOccluderVolume = 0.01; + _minimumShadowOccluderVolume = 0.01f; _createDrawables = false; } diff --git a/src/osg/CullStack.cpp b/src/osg/CullStack.cpp index 8b2022d1a..4b66fe6ef 100644 --- a/src/osg/CullStack.cpp +++ b/src/osg/CullStack.cpp @@ -112,7 +112,7 @@ void CullStack::pushProjectionMatrix(Matrix* matrix) osg::CullingSet* cullingSet = osgNew osg::CullingSet(); // set up view frustum. - cullingSet->getFrustum().setToUnitFrustum(_cullingMode&NEAR_PLANE_CULLING,_cullingMode&FAR_PLANE_CULLING); + cullingSet->getFrustum().setToUnitFrustum(((_cullingMode&NEAR_PLANE_CULLING)!=0),((_cullingMode&FAR_PLANE_CULLING)!=0)); cullingSet->getFrustum().transformProvidingInverse(*matrix); // set the small feature culling. diff --git a/src/osg/Notify.cpp b/src/osg/Notify.cpp index 87b1d8728..7937c3f8e 100644 --- a/src/osg/Notify.cpp +++ b/src/osg/Notify.cpp @@ -62,17 +62,24 @@ bool osg::initNotifyLevel() } +#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) +const char* NullStreamName = "nul"; +#else +const char* NullStreamName = "/dev/null"; +#endif + std::ostream& osg::notify(const osg::NotifySeverity severity) { // set up global notify null stream for inline notify -#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) - static std::ofstream s_NotifyNulStream("nul"); -#else - static std::ofstream s_NotifyNulStream("/dev/null"); -#endif + static std::ofstream s_NotifyNulStream(NullStreamName); - static bool initialized = osg::initNotifyLevel(); - initialized=initialized; // statement with no effect to stop GCC warning. + static bool initialized = false; + if (!initialized) + { + std::cerr<<""; // dummy op to force construction of cerr, before a reference is passed back to calling code. + std::cout<<""; // dummy op to force construction of cout, before a reference is passed back to calling code. + initialized = osg::initNotifyLevel(); + } if (severity<=g_NotifyLevel) { diff --git a/src/osg/ShadowVolumeOccluder.cpp b/src/osg/ShadowVolumeOccluder.cpp index 4c0ed282b..433e18a2a 100644 --- a/src/osg/ShadowVolumeOccluder.cpp +++ b/src/osg/ShadowVolumeOccluder.cpp @@ -155,7 +155,7 @@ Plane computeFrontPlane(const PointList& front) // } // compute the volume between the front and back polygons of the occluder/hole. -float computeVolume(const PointList& front, const PointList& back) +float computePolytopeVolume(const PointList& front, const PointList& back) { float volume = 0.0f; Vec3 frontStart = front[0].second; @@ -168,26 +168,6 @@ float computeVolume(const PointList& front, const PointList& back) return volume; } -float computeVolumeOfView(osg::Matrix& invP) -{ - PointList front; - front.push_back(Point(0,osg::Vec3(-1,-1,-1))); - front.push_back(Point(0,osg::Vec3(-1, 1,-1))); - front.push_back(Point(0,osg::Vec3( 1, 1,-1))); - front.push_back(Point(0,osg::Vec3( 1,-1,-1))); - transform(front,invP); - - PointList back; - back.push_back(Point(0,osg::Vec3(-1,-1,1))); - back.push_back(Point(0,osg::Vec3(-1, 1,1))); - back.push_back(Point(0,osg::Vec3( 1, 1,1))); - back.push_back(Point(0,osg::Vec3( 1,-1,1))); - transform(back,invP); - - return computeVolume(front,back); -} - - Drawable* createOccluderDrawable(const PointList& front, const PointList& back) { @@ -310,7 +290,7 @@ bool ShadowVolumeOccluder::computeOccluder(const NodePath& nodePath,const Convex _occluderVolume.flip(); } - _volume = computeVolume(points,farPoints)/volumeview; + _volume = computePolytopeVolume(points,farPoints)/volumeview; if (createDrawables && !nodePath.empty()) { @@ -338,7 +318,7 @@ bool ShadowVolumeOccluder::computeOccluder(const NodePath& nodePath,const Convex PointList points; if (clip(cullingset.getFrustum().getPlaneList(),hitr->getVertexList(),points)>=3) { - _holeList.push_back(); + _holeList.push_back(Polytope()); Polytope& polytope = _holeList.back(); // compute the points on the far plane. @@ -366,7 +346,7 @@ bool ShadowVolumeOccluder::computeOccluder(const NodePath& nodePath,const Convex } // remove the hole's volume from the occluder volume. - _volume -= computeVolume(points,farPoints)/volumeview; + _volume -= computePolytopeVolume(points,farPoints)/volumeview; if (createDrawables && !nodePath.empty()) {