Changeset 9705

Show
Ignore:
Timestamp:
02/08/09 16:56:35 (5 years ago)
Author:
robert
Message:

From Paul Melis, "While trying out the osgbrowser example (where I had forgotten to update
LD_LIBRARY_PATH so the XUL libs would be found) I noticed that although
the gecko plugin was found it could not be loaded. But this did not
trigger any visible warning/error message (at least not without INFO
notify level). Would you mind if we change the notify level for a
dlerror() to WARNING? This will also make it more explicit for the case
when a plugin isn't actually found, which seems to come up a lot for
novice users (e.g. no freetype on win32, so no freetype plugin, etc).
Also, the current error message is misleading ("Warning: Could not FIND
plugin to ...") because the it's not always a case of not finding the
plugin. I slightly enhanced the situation of not finding a plugin versus
finding it but not being able to load it.

Here's also a few fixes to some of the examples:
- osgfont: make usage help line more in line with the actual behaviour
- osgcompositeviewer: complain when no model file was provided
- osgmovie: don't include quicktime-dependent feature on Linux
- osgocclussionquery: comment addition (as I was surprised that lines
were being drawn in a function called createRandomTriangles())"

Location:
OpenSceneGraph/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgcompositeviewer/osgcompositeviewer.cpp

    r9565 r9705  
    1616*  THE SOFTWARE. 
    1717*/ 
     18 
     19#include <iostream> 
    1820 
    1921#include <osgUtil/Optimizer> 
     
    135137    osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments); 
    136138 
    137     if (!scene) return 1; 
     139    if (!scene) 
     140    { 
     141        std::cout << argv[0] << ": requires filename argument." << std::endl; 
     142        return 1; 
     143    } 
    138144 
    139145    // construct the viewer. 
    140146    osgViewer::CompositeViewer viewer(arguments); 
    141  
    142  
    143  
    144147 
    145148    if (arguments.read("-1")) 
     
    301304     return viewer.run(); 
    302305} 
     306 
  • OpenSceneGraph/trunk/examples/osgfont/osgfont.cpp

    r8274 r9705  
    1212 
    1313        const osgText::Text::TextureGlyphQuadMap::const_iterator tgqmi = tgqm.begin(); 
    14          
     14 
    1515        const osgText::Text::GlyphQuads& gq = tgqmi->second; 
    1616 
     
    6060        camera->setClearMask(GL_DEPTH_BUFFER_BIT); 
    6161        camera->setRenderOrder(osg::Camera::POST_RENDER); 
    62          
     62 
    6363        return camera; 
    6464} 
     
    9898        if(argc <= 2) 
    9999        { 
    100                 osg::notify(osg::FATAL) << "usage: " << args[0] << " FONTFILE [sizes...]" << std::endl; 
     100                osg::notify(osg::FATAL) << "usage: " << args[0] << " fontfile size1 [size2 ...]" << std::endl; 
    101101 
    102102                return 1; 
     
    107107 
    108108        osg::Group*  group  = new osg::Group(); 
    109         osg::Camera* camera = createOrthoCamera(1280.0f, 1024.0f);  
     109        osg::Camera* camera = createOrthoCamera(1280.0f, 1024.0f); 
    110110 
    111111        // Create the list of desired sizes. 
     
    139139        return viewer.run(); 
    140140} 
     141 
  • OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp

    r9637 r9705  
    4545 
    4646    MovieEventHandler():_playToggle(true),_trackMouse(false) {} 
    47      
     47 
    4848    void setMouseTracking(bool track) { _trackMouse = track; } 
    4949    bool getMouseTracking() const { return _trackMouse; } 
    50      
     50 
    5151    void set(osg::Node* node); 
    5252 
    5353    virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv); 
    54      
     54 
    5555    virtual void getUsage(osg::ApplicationUsage& usage) const; 
    5656 
     
    6666        FindImageStreamsVisitor(ImageStreamList& imageStreamList): 
    6767            _imageStreamList(imageStreamList) {} 
    68              
     68 
    6969        virtual void apply(osg::Geode& geode) 
    7070        { 
     
    7575                apply(geode.getDrawable(i)->getStateSet()); 
    7676            } 
    77          
     77 
    7878            traverse(geode); 
    7979        } 
     
    8484            traverse(node); 
    8585        } 
    86          
     86 
    8787        inline void apply(osg::StateSet* stateset) 
    8888        { 
    8989            if (!stateset) return; 
    90              
     90 
    9191            osg::StateAttribute* attr = stateset->getTextureAttribute(0,osg::StateAttribute::TEXTURE); 
    9292            if (attr) 
     
    9999            } 
    100100        } 
    101          
     101 
    102102        inline void apply(osg::ImageStream* imagestream) 
    103103        { 
    104104            if (imagestream) 
    105105            { 
    106                 _imageStreamList.push_back(imagestream);  
    107             } 
    108         } 
    109          
     106                _imageStreamList.push_back(imagestream); 
     107            } 
     108        } 
     109 
    110110        ImageStreamList& _imageStreamList; 
    111111 
    112112    protected: 
    113      
     113 
    114114        FindImageStreamsVisitor& operator = (const FindImageStreamsVisitor&) { return *this; } 
    115115 
     
    120120    bool            _trackMouse; 
    121121    ImageStreamList _imageStreamList; 
    122      
     122 
    123123}; 
    124124 
     
    151151                    (nv==0 ? view->computeIntersections(ea.getX(), ea.getY(), intersections) : 
    152152                             view->computeIntersections(ea.getX(), ea.getY(), nv->getNodePath(), intersections)); 
    153                  
     153 
    154154                if (foundIntersection) 
    155155                { 
    156156 
    157                     // use the nearest intersection                  
     157                    // use the nearest intersection 
    158158                    const osgUtil::LineSegmentIntersector::Intersection& intersection = *(intersections.begin()); 
    159159                    osg::Drawable* drawable = intersection.drawable.get(); 
     
    180180                            if (texcoords_Vec2Array) 
    181181                            { 
    182                                 // we have tex coord array so now we can compute the final tex coord at the point of intersection.                                 
     182                                // we have tex coord array so now we can compute the final tex coord at the point of intersection. 
    183183                                osg::Vec2 tc1 = (*texcoords_Vec2Array)[i1]; 
    184184                                osg::Vec2 tc2 = (*texcoords_Vec2Array)[i2]; 
     
    280280    bool flip = image->getOrigin()==osg::Image::TOP_LEFT; 
    281281    if (option_flip) flip = !flip; 
    282      
     282 
    283283    if (useTextureRectangle) 
    284284    { 
     
    291291        texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); 
    292292        texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); 
    293          
    294          
     293 
     294 
    295295        pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0, 
    296296                                                                        texture, 
    297297                                                                        osg::StateAttribute::ON); 
    298          
     298 
    299299        return pictureQuad; 
    300300    } 
     
    305305                                           xyPlane ? osg::Vec3(0.0f,height,0.0f) : osg::Vec3(0.0f,0.0f,height), 
    306306                                           0.0f, flip ? 1.0f : 0.0f , 1.0f, flip ? 0.0f : 1.0f); 
    307                                      
     307 
    308308        osg::Texture2D* texture = new osg::Texture2D(image); 
    309309        texture->setResizeNonPowerOfTwoHint(false); 
     
    311311        texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); 
    312312        texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); 
    313          
    314          
     313 
     314 
    315315        pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0, 
    316316                    texture, 
     
    325325    // use an ArgumentParser object to manage the program arguments. 
    326326    osg::ArgumentParser arguments(&argc,argv); 
    327      
     327 
    328328    // set up the usage document, in case we need to print out how to use this program. 
    329329    arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); 
     
    335335    arguments.getApplicationUsage()->addCommandLineOption("--interactive","Use camera manipulator to allow movement around movie."); 
    336336    arguments.getApplicationUsage()->addCommandLineOption("--flip","Flip the movie so top becomes bottom."); 
     337#if defined(WIN32) || defined(__APPLE__) 
    337338    arguments.getApplicationUsage()->addCommandLineOption("--devices","Print the Video input capability via QuickTime and exit."); 
    338      
     339#endif 
     340 
    339341    bool useTextureRectangle = true; 
    340342    bool useShader = false; 
     
    342344    // construct the viewer. 
    343345    osgViewer::Viewer viewer(arguments); 
    344      
     346 
    345347    if (arguments.argc()<=1) 
    346348    { 
     
    349351    } 
    350352 
     353#if defined(WIN32) || defined(__APPLE__) 
    351354    // if user requests devices video capability. 
    352355    if (arguments.read("-devices") || arguments.read("--devices")) 
     
    356359        return 1; 
    357360    } 
     361#endif 
    358362 
    359363    while (arguments.read("--texture2D")) useTextureRectangle=false; 
     
    361365 
    362366    bool mouseTracking = false; 
    363     while (arguments.read("--mouse")) mouseTracking=true;  
     367    while (arguments.read("--mouse")) mouseTracking=true; 
    364368 
    365369 
     
    420424    osg::Vec3 topleft = pos; 
    421425    osg::Vec3 bottomright = pos; 
    422      
     426 
    423427    bool xyPlane = fullscreen; 
    424      
     428 
    425429    for(int i=1;i<arguments.argc();++i) 
    426430    { 
     
    434438            { 
    435439                osg::notify(osg::NOTICE)<<"image->s()"<<image->s()<<" image-t()="<<image->t()<<std::endl; 
    436              
     440 
    437441                geode->addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image, useTextureRectangle, xyPlane, flip)); 
    438          
     442 
    439443                bottomright = pos + osg::Vec3(static_cast<float>(image->s()),static_cast<float>(image->t()),0.0f); 
    440444 
     
    445449            { 
    446450                std::cout<<"Unable to read file "<<arguments[i]<<std::endl; 
    447             }             
    448         } 
    449     } 
    450      
     451            } 
     452        } 
     453    } 
     454 
    451455    // set the scene to render 
    452456    viewer.setSceneData(geode.get()); 
     
    497501    } 
    498502} 
     503 
  • OpenSceneGraph/trunk/examples/osgocclusionquery/osgocclusionquery.cpp

    r9395 r9705  
    246246            if (_total > _limit) 
    247247                break; 
    248         }  
     248        } 
    249249    } 
    250250 
     
    312312        //   Don't add one here to avoid hierarchical nesting. 
    313313        return; 
    314      
     314 
    315315    // There are no OQNs below this group. If the vertex 
    316316    //   count exceeds the threshold, add an OQN here. 
     
    396396 
    397397 
    398 void  
     398void 
    399399DebugDisplayVisitor::apply( osg::OcclusionQueryNode& oqn ) 
    400400{ 
     
    490490// Allow user to do interesting things with an 
    491491// OcclusionQueryNode-enabled scene graph at run time. 
    492 class KeyHandler : public osgGA::GUIEventHandler  
    493 { 
    494 public:  
     492class KeyHandler : public osgGA::GUIEventHandler 
     493{ 
     494public: 
    495495    KeyHandler( osg::Node& node ) 
    496496      : _node( node ), 
     
    564564 
    565565    osg::StateSet* state = box->getOrCreateStateSet(); 
    566     osg::PolygonMode* pm = new osg::PolygonMode(  
     566    osg::PolygonMode* pm = new osg::PolygonMode( 
    567567        osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::FILL ); 
    568568    state->setAttributeAndModes( pm, 
     
    631631//  * Lots of vertices and color data per vertex 
    632632//  * No vertex sharing 
     633//  * Draw the triangles as wireframe 
    633634osg::ref_ptr<osg::Node> 
    634635createRandomTriangles( unsigned int num ) 
     
    656657    unsigned int i; 
    657658    srand( 0 ); 
    658 #define RAND_NEG1_TO_1 ( ((rand()%20)-10)*.1 )  
     659#define RAND_NEG1_TO_1 ( ((rand()%20)-10)*.1 ) 
    659660    for (i=0; i<num; i++) 
    660661    { 
     
    673674    c->resize( num ); 
    674675 
    675 #define RAND_0_TO_1 ( (rand()%10)*.1 )  
     676#define RAND_0_TO_1 ( (rand()%10)*.1 ) 
    676677    for (i=0; i<num; i++) 
    677678    { 
     
    732733        return 1; 
    733734    } 
    734      
     735 
    735736    osgViewer::Viewer viewer( arguments ); 
    736737 
    737738    // add the state manipulator 
    738739    viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); 
    739      
     740 
    740741    // add the stats handler 
    741742    viewer.addEventHandler(new osgViewer::StatsHandler); 
     
    792793    return viewer.run(); 
    793794} 
     795 
  • OpenSceneGraph/trunk/src/osgDB/DynamicLibrary.cpp

    r9459 r9705  
    1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield  
     1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 
    22 * 
    3  * This library is open source and may be redistributed and/or modified under   
    4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or  
     3 * This library is open source and may be redistributed and/or modified under 
     4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
    55 * (at your option) any later version.  The full license is in LICENSE file 
    66 * included with this distribution, and on the openscenegraph.org website. 
    7  *  
     7 * 
    88 * This library is distributed in the hope that it will be useful, 
    99 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
     10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1111 * OpenSceneGraph Public License for more details. 
    1212*/ 
    1313 
    14 //The dlopen calls were not adding to OS X until 10.3  
     14//The dlopen calls were not adding to OS X until 10.3 
    1515#ifdef __APPLE__ 
    1616#include <AvailabilityMacros.h> 
     
    4747using namespace osgDB; 
    4848 
    49 DynamicLibrary::DynamicLibrary(const std::string& name,HANDLE handle) 
     49DynamicLibrary::DynamicLibrary(const std::string& name, HANDLE handle) 
    5050{ 
    5151    _name = name; 
     
    6868#else // other unix 
    6969        dlclose(_handle); 
    70 #endif     
     70#endif 
    7171    } 
    7272} 
     
    8080    if (!fullLibraryName.empty()) handle = getLibraryHandle( fullLibraryName ); // try the lib we have found 
    8181    else handle = getLibraryHandle( libraryName ); // havn't found a lib ourselves, see if the OS can find it simply from the library name. 
    82      
     82 
    8383    if (handle) return new DynamicLibrary(libraryName,handle); 
    8484 
     
    116116    else 
    117117        localLibraryName = libraryName; 
     118 
    118119    handle = dlopen( localLibraryName.c_str(), RTLD_LAZY | RTLD_GLOBAL); 
    119120    if( handle == NULL ) 
    120         notify(INFO) << "DynamicLibrary::getLibraryHandle( "<< libraryName << ") - dlopen(): " << dlerror() << std::endl; 
     121    { 
     122        if (fileExists(localLibraryName)) 
     123        { 
     124            notify(WARN) << "Warning: dynamic library '" << libraryName << "' exists, but an error occurred while trying to open it:" << std::endl; 
     125            notify(WARN) << dlerror() << std::endl; 
     126        } 
     127        else 
     128        { 
     129            notify(WARN) << "Warning: dynamic library '" << libraryName << "' does not exist (or isn't readable):" << std::endl; 
     130            notify(WARN) << dlerror() << std::endl; 
     131        } 
     132    } 
    121133#endif 
    122134    return handle; 
     
    156168#endif 
    157169} 
     170