diff --git a/examples/osgcompositeviewer/osgcompositeviewer.cpp b/examples/osgcompositeviewer/osgcompositeviewer.cpp index 4ef2dbf03..8ce219504 100644 --- a/examples/osgcompositeviewer/osgcompositeviewer.cpp +++ b/examples/osgcompositeviewer/osgcompositeviewer.cpp @@ -16,6 +16,8 @@ * THE SOFTWARE. */ +#include + #include #include @@ -134,14 +136,15 @@ int main( int argc, char **argv ) // read the scene from the list of file specified commandline args. osg::ref_ptr scene = osgDB::readNodeFiles(arguments); - if (!scene) return 1; + if (!scene) + { + std::cout << argv[0] << ": requires filename argument." << std::endl; + return 1; + } // construct the viewer. osgViewer::CompositeViewer viewer(arguments); - - - if (arguments.read("-1")) { { @@ -300,3 +303,4 @@ int main( int argc, char **argv ) // run the viewer's main frame loop return viewer.run(); } + diff --git a/examples/osgfont/osgfont.cpp b/examples/osgfont/osgfont.cpp index 319457ab6..f7a74869c 100644 --- a/examples/osgfont/osgfont.cpp +++ b/examples/osgfont/osgfont.cpp @@ -11,7 +11,7 @@ void textInfo(osgText::Text* text) const osgText::Text::TextureGlyphQuadMap& tgqm = text->getTextureGlyphQuadMap(); const osgText::Text::TextureGlyphQuadMap::const_iterator tgqmi = tgqm.begin(); - + const osgText::Text::GlyphQuads& gq = tgqmi->second; osgText::String& s = text->getText(); @@ -59,7 +59,7 @@ osg::Camera* createOrthoCamera(double width, double height) camera->setViewMatrix(osg::Matrix::identity()); camera->setClearMask(GL_DEPTH_BUFFER_BIT); camera->setRenderOrder(osg::Camera::POST_RENDER); - + return camera; } @@ -97,7 +97,7 @@ int main(int argc, char** argv) // Make sure we have the minimum args... if(argc <= 2) { - osg::notify(osg::FATAL) << "usage: " << args[0] << " FONTFILE [sizes...]" << std::endl; + osg::notify(osg::FATAL) << "usage: " << args[0] << " fontfile size1 [size2 ...]" << std::endl; return 1; } @@ -106,7 +106,7 @@ int main(int argc, char** argv) viewer.addEventHandler(new osgViewer::WindowSizeHandler()); osg::Group* group = new osg::Group(); - osg::Camera* camera = createOrthoCamera(1280.0f, 1024.0f); + osg::Camera* camera = createOrthoCamera(1280.0f, 1024.0f); // Create the list of desired sizes. Sizes sizes; @@ -138,3 +138,4 @@ int main(int argc, char** argv) return viewer.run(); } + diff --git a/examples/osgmovie/osgmovie.cpp b/examples/osgmovie/osgmovie.cpp index 51bda6c5f..336529d7a 100644 --- a/examples/osgmovie/osgmovie.cpp +++ b/examples/osgmovie/osgmovie.cpp @@ -44,14 +44,14 @@ class MovieEventHandler : public osgGA::GUIEventHandler public: MovieEventHandler():_playToggle(true),_trackMouse(false) {} - + void setMouseTracking(bool track) { _trackMouse = track; } bool getMouseTracking() const { return _trackMouse; } - + void set(osg::Node* node); virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv); - + virtual void getUsage(osg::ApplicationUsage& usage) const; typedef std::vector< osg::observer_ptr > ImageStreamList; @@ -65,7 +65,7 @@ protected: public: FindImageStreamsVisitor(ImageStreamList& imageStreamList): _imageStreamList(imageStreamList) {} - + virtual void apply(osg::Geode& geode) { apply(geode.getStateSet()); @@ -74,7 +74,7 @@ protected: { apply(geode.getDrawable(i)->getStateSet()); } - + traverse(geode); } @@ -83,11 +83,11 @@ protected: apply(node.getStateSet()); traverse(node); } - + inline void apply(osg::StateSet* stateset) { if (!stateset) return; - + osg::StateAttribute* attr = stateset->getTextureAttribute(0,osg::StateAttribute::TEXTURE); if (attr) { @@ -98,19 +98,19 @@ protected: if (textureRec) apply(dynamic_cast(textureRec->getImage())); } } - + inline void apply(osg::ImageStream* imagestream) { if (imagestream) { - _imageStreamList.push_back(imagestream); + _imageStreamList.push_back(imagestream); } } - + ImageStreamList& _imageStreamList; protected: - + FindImageStreamsVisitor& operator = (const FindImageStreamsVisitor&) { return *this; } }; @@ -119,7 +119,7 @@ protected: bool _playToggle; bool _trackMouse; ImageStreamList _imageStreamList; - + }; @@ -150,11 +150,11 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction bool foundIntersection = view==0 ? false : (nv==0 ? view->computeIntersections(ea.getX(), ea.getY(), intersections) : view->computeIntersections(ea.getX(), ea.getY(), nv->getNodePath(), intersections)); - + if (foundIntersection) { - // use the nearest intersection + // use the nearest intersection const osgUtil::LineSegmentIntersector::Intersection& intersection = *(intersections.begin()); osg::Drawable* drawable = intersection.drawable.get(); osg::Geometry* geometry = drawable ? drawable->asGeometry() : 0; @@ -179,7 +179,7 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction osg::Vec2Array* texcoords_Vec2Array = dynamic_cast(texcoords); if (texcoords_Vec2Array) { - // we have tex coord array so now we can compute the final tex coord at the point of intersection. + // we have tex coord array so now we can compute the final tex coord at the point of intersection. osg::Vec2 tc1 = (*texcoords_Vec2Array)[i1]; osg::Vec2 tc2 = (*texcoords_Vec2Array)[i2]; osg::Vec2 tc3 = (*texcoords_Vec2Array)[i3]; @@ -279,7 +279,7 @@ osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,flo { bool flip = image->getOrigin()==osg::Image::TOP_LEFT; if (option_flip) flip = !flip; - + if (useTextureRectangle) { osg::Geometry* pictureQuad = osg::createTexturedQuadGeometry(pos, @@ -290,12 +290,12 @@ osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,flo osg::TextureRectangle* texture = new osg::TextureRectangle(image); texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); - - + + pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); - + return pictureQuad; } else @@ -304,14 +304,14 @@ osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,flo osg::Vec3(width,0.0f,0.0f), xyPlane ? osg::Vec3(0.0f,height,0.0f) : osg::Vec3(0.0f,0.0f,height), 0.0f, flip ? 1.0f : 0.0f , 1.0f, flip ? 0.0f : 1.0f); - + osg::Texture2D* texture = new osg::Texture2D(image); texture->setResizeNonPowerOfTwoHint(false); texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR); texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); - - + + pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); @@ -324,7 +324,7 @@ int main(int argc, char** argv) { // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc,argv); - + // set up the usage document, in case we need to print out how to use this program. arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" example demonstrates the use of ImageStream for rendering movies as textures."); @@ -334,20 +334,23 @@ int main(int argc, char** argv) arguments.getApplicationUsage()->addCommandLineOption("--shader","Use shaders to post process the video."); arguments.getApplicationUsage()->addCommandLineOption("--interactive","Use camera manipulator to allow movement around movie."); arguments.getApplicationUsage()->addCommandLineOption("--flip","Flip the movie so top becomes bottom."); +#if defined(WIN32) || defined(__APPLE__) arguments.getApplicationUsage()->addCommandLineOption("--devices","Print the Video input capability via QuickTime and exit."); - +#endif + bool useTextureRectangle = true; bool useShader = false; // construct the viewer. osgViewer::Viewer viewer(arguments); - + if (arguments.argc()<=1) { arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); return 1; } +#if defined(WIN32) || defined(__APPLE__) // if user requests devices video capability. if (arguments.read("-devices") || arguments.read("--devices")) { @@ -355,12 +358,13 @@ int main(int argc, char** argv) osgDB::readImageFile("devices.live"); return 1; } +#endif while (arguments.read("--texture2D")) useTextureRectangle=false; while (arguments.read("--shader")) useShader=true; bool mouseTracking = false; - while (arguments.read("--mouse")) mouseTracking=true; + while (arguments.read("--mouse")) mouseTracking=true; // if user request help write it out to cout. @@ -419,9 +423,9 @@ int main(int argc, char** argv) osg::Vec3 pos(0.0f,0.0f,0.0f); osg::Vec3 topleft = pos; osg::Vec3 bottomright = pos; - + bool xyPlane = fullscreen; - + for(int i=1;is()"<s()<<" image-t()="<t()<addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image, useTextureRectangle, xyPlane, flip)); - + bottomright = pos + osg::Vec3(static_cast(image->s()),static_cast(image->t()),0.0f); if (xyPlane) pos.y() += image->t()*1.05f; @@ -444,10 +448,10 @@ int main(int argc, char** argv) else { std::cout<<"Unable to read file "< _limit) break; - } + } } protected: @@ -311,7 +311,7 @@ OcclusionQueryVisitor::apply( osg::Group& group ) // A least one OQN was added below the current node. // Don't add one here to avoid hierarchical nesting. return; - + // There are no OQNs below this group. If the vertex // count exceeds the threshold, add an OQN here. addOQN( group ); @@ -395,7 +395,7 @@ EnableQueryVisitor::apply( osg::OcclusionQueryNode& oqn ) } -void +void DebugDisplayVisitor::apply( osg::OcclusionQueryNode& oqn ) { oqn.setDebugDisplay( _debug ); @@ -489,9 +489,9 @@ StatisticsVisitor::getNumPassed() const // KetHandler -- // Allow user to do interesting things with an // OcclusionQueryNode-enabled scene graph at run time. -class KeyHandler : public osgGA::GUIEventHandler +class KeyHandler : public osgGA::GUIEventHandler { -public: +public: KeyHandler( osg::Node& node ) : _node( node ), _enable( true ), @@ -563,7 +563,7 @@ createBox() osg::ref_ptr box = new osg::Geode; osg::StateSet* state = box->getOrCreateStateSet(); - osg::PolygonMode* pm = new osg::PolygonMode( + osg::PolygonMode* pm = new osg::PolygonMode( osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::FILL ); state->setAttributeAndModes( pm, osg::StateAttribute::ON | osg::StateAttribute::PROTECTED ); @@ -630,6 +630,7 @@ createBox() // * Force glBegin/glEnd slow path // * Lots of vertices and color data per vertex // * No vertex sharing +// * Draw the triangles as wireframe osg::ref_ptr createRandomTriangles( unsigned int num ) { @@ -655,7 +656,7 @@ createRandomTriangles( unsigned int num ) unsigned int i; srand( 0 ); -#define RAND_NEG1_TO_1 ( ((rand()%20)-10)*.1 ) +#define RAND_NEG1_TO_1 ( ((rand()%20)-10)*.1 ) for (i=0; isetColorBinding( osg::Geometry::BIND_PER_PRIMITIVE ); c->resize( num ); -#define RAND_0_TO_1 ( (rand()%10)*.1 ) +#define RAND_0_TO_1 ( (rand()%10)*.1 ) for (i=0; igetOrCreateStateSet()) ); - + // add the stats handler viewer.addEventHandler(new osgViewer::StatsHandler); @@ -791,3 +792,4 @@ int main(int argc, char** argv) return viewer.run(); } + diff --git a/src/osgDB/DynamicLibrary.cpp b/src/osgDB/DynamicLibrary.cpp index 5c884322f..78dbea659 100644 --- a/src/osgDB/DynamicLibrary.cpp +++ b/src/osgDB/DynamicLibrary.cpp @@ -1,17 +1,17 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ -//The dlopen calls were not adding to OS X until 10.3 +//The dlopen calls were not adding to OS X until 10.3 #ifdef __APPLE__ #include #if !defined(MAC_OS_X_VERSION_10_3) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3) @@ -46,7 +46,7 @@ using namespace osg; using namespace osgDB; -DynamicLibrary::DynamicLibrary(const std::string& name,HANDLE handle) +DynamicLibrary::DynamicLibrary(const std::string& name, HANDLE handle) { _name = name; _handle = handle; @@ -67,7 +67,7 @@ DynamicLibrary::~DynamicLibrary() shl_unload (static_cast(_handle)); #else // other unix dlclose(_handle); -#endif +#endif } } @@ -79,7 +79,7 @@ DynamicLibrary* DynamicLibrary::loadLibrary(const std::string& libraryName) std::string fullLibraryName = osgDB::findLibraryFile(libraryName); if (!fullLibraryName.empty()) handle = getLibraryHandle( fullLibraryName ); // try the lib we have found else handle = getLibraryHandle( libraryName ); // havn't found a lib ourselves, see if the OS can find it simply from the library name. - + if (handle) return new DynamicLibrary(libraryName,handle); // else no lib found so report errors. @@ -115,9 +115,21 @@ DynamicLibrary::HANDLE DynamicLibrary::getLibraryHandle( const std::string& libr localLibraryName = "./" + libraryName; else localLibraryName = libraryName; + handle = dlopen( localLibraryName.c_str(), RTLD_LAZY | RTLD_GLOBAL); if( handle == NULL ) - notify(INFO) << "DynamicLibrary::getLibraryHandle( "<< libraryName << ") - dlopen(): " << dlerror() << std::endl; + { + if (fileExists(localLibraryName)) + { + notify(WARN) << "Warning: dynamic library '" << libraryName << "' exists, but an error occurred while trying to open it:" << std::endl; + notify(WARN) << dlerror() << std::endl; + } + else + { + notify(WARN) << "Warning: dynamic library '" << libraryName << "' does not exist (or isn't readable):" << std::endl; + notify(WARN) << dlerror() << std::endl; + } + } #endif return handle; } @@ -155,3 +167,4 @@ DynamicLibrary::PROC_ADDRESS DynamicLibrary::getProcAddress(const std::string& p return sym; #endif } +