Fixes for Visual .NET and Mingw builds, and fix MacOSX notify() crash.

This commit is contained in:
Robert Osfield 2002-06-15 20:57:50 +00:00
parent 52c36dde70
commit 156a9fbaea
8 changed files with 109 additions and 36 deletions

View File

@ -8,3 +8,8 @@ TARGET_BASENAME := $(PLUGIN_PREFIX)$(TARGET_BASENAME)
PLUGIN_PREFIX := cyg PLUGIN_PREFIX := cyg
endif endif
ifeq ($(OS),MINGW)
TARGET_BASENAME := $(PLUGIN_PREFIX)$(TARGET_BASENAME)
PLUGIN_PREFIX := lib
endif

View File

@ -12,6 +12,11 @@ ifeq ($(findstring CYGWIN,$(OS)),CYGWIN)
OS := CYGWIN OS := CYGWIN
endif 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 needs to be redefined for every Makefile
TOPDIR ?= ../ TOPDIR ?= ../
THISDIR = . THISDIR = .
@ -310,6 +315,78 @@ ifeq ($(OS),CYGWIN)
endif 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=.. VPATH=..

View File

@ -113,7 +113,7 @@ inline T RadiansToDegrees(T angle) { return angle*(T)180.0/(T)PI; }
template<typename T> template<typename T>
inline float computeVolume(const T& a,const T& b,const T& c,const T& d) 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 */ /** compute the volume of prism */

View File

@ -57,9 +57,12 @@ void write_usage(std::ostream& out,const std::string& name)
osg::Node* createOccludersAroundModel(osg::Node* model) osg::Node* createOccludersAroundModel(osg::Node* model)
{ {
osg::Group* scene = osgNew osg::Group; osg::Group* scene = osgNew osg::Group;
scene->setName("rootgroup");
// add the loaded model into a the scene group. // add the loaded model into a the scene group.
scene->addChild(model); scene->addChild(model);
model->setName("model");
// create and occluder which will site along side the loadmodel 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. // attach it to the occluder node.
occluderNode->setOccluder(cpo); occluderNode->setOccluder(cpo);
occluderNode->setName("occluder");
// set the occluder up for the front face of the bounding box. // set the occluder up for the front face of the bounding box.
osg::ConvexPlanerPolygon& occluder = cpo->getOccluder(); osg::ConvexPlanerPolygon& occluder = cpo->getOccluder();

View File

@ -12,12 +12,12 @@ CollectOccludersVisitor::CollectOccludersVisitor()
// overide the default node visitor mode. // overide the default node visitor mode.
setTraversalMode(NodeVisitor::TRAVERSE_ACTIVE_CHILDREN); setTraversalMode(NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
/*setCullingMode(VIEW_FRUSTUM_CULLING| setCullingMode(VIEW_FRUSTUM_CULLING|
NEAR_PLANE_CULLING| NEAR_PLANE_CULLING|
FAR_PLANE_CULLING| FAR_PLANE_CULLING|
SMALL_FEATURE_CULLING);*/ SMALL_FEATURE_CULLING);
_minimumShadowOccluderVolume = 0.01; _minimumShadowOccluderVolume = 0.01f;
_createDrawables = false; _createDrawables = false;
} }

View File

@ -112,7 +112,7 @@ void CullStack::pushProjectionMatrix(Matrix* matrix)
osg::CullingSet* cullingSet = osgNew osg::CullingSet(); osg::CullingSet* cullingSet = osgNew osg::CullingSet();
// set up view frustum. // 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); cullingSet->getFrustum().transformProvidingInverse(*matrix);
// set the small feature culling. // set the small feature culling.

View File

@ -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) std::ostream& osg::notify(const osg::NotifySeverity severity)
{ {
// set up global notify null stream for inline notify // set up global notify null stream for inline notify
#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) static std::ofstream s_NotifyNulStream(NullStreamName);
static std::ofstream s_NotifyNulStream("nul");
#else
static std::ofstream s_NotifyNulStream("/dev/null");
#endif
static bool initialized = osg::initNotifyLevel(); static bool initialized = false;
initialized=initialized; // statement with no effect to stop GCC warning. 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) if (severity<=g_NotifyLevel)
{ {

View File

@ -155,7 +155,7 @@ Plane computeFrontPlane(const PointList& front)
// } // }
// compute the volume between the front and back polygons of the occluder/hole. // 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; float volume = 0.0f;
Vec3 frontStart = front[0].second; Vec3 frontStart = front[0].second;
@ -168,26 +168,6 @@ float computeVolume(const PointList& front, const PointList& back)
return volume; 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) Drawable* createOccluderDrawable(const PointList& front, const PointList& back)
{ {
@ -310,7 +290,7 @@ bool ShadowVolumeOccluder::computeOccluder(const NodePath& nodePath,const Convex
_occluderVolume.flip(); _occluderVolume.flip();
} }
_volume = computeVolume(points,farPoints)/volumeview; _volume = computePolytopeVolume(points,farPoints)/volumeview;
if (createDrawables && !nodePath.empty()) if (createDrawables && !nodePath.empty())
{ {
@ -338,7 +318,7 @@ bool ShadowVolumeOccluder::computeOccluder(const NodePath& nodePath,const Convex
PointList points; PointList points;
if (clip(cullingset.getFrustum().getPlaneList(),hitr->getVertexList(),points)>=3) if (clip(cullingset.getFrustum().getPlaneList(),hitr->getVertexList(),points)>=3)
{ {
_holeList.push_back(); _holeList.push_back(Polytope());
Polytope& polytope = _holeList.back(); Polytope& polytope = _holeList.back();
// compute the points on the far plane. // 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. // remove the hole's volume from the occluder volume.
_volume -= computeVolume(points,farPoints)/volumeview; _volume -= computePolytopeVolume(points,farPoints)/volumeview;
if (createDrawables && !nodePath.empty()) if (createDrawables && !nodePath.empty())
{ {