Changeset 9705
- Timestamp:
- 02/08/09 16:56:35 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 5 modified
-
examples/osgcompositeviewer/osgcompositeviewer.cpp (modified) (3 diffs)
-
examples/osgfont/osgfont.cpp (modified) (5 diffs)
-
examples/osgmovie/osgmovie.cpp (modified) (22 diffs)
-
examples/osgocclusionquery/osgocclusionquery.cpp (modified) (10 diffs)
-
src/osgDB/DynamicLibrary.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgcompositeviewer/osgcompositeviewer.cpp
r9565 r9705 16 16 * THE SOFTWARE. 17 17 */ 18 19 #include <iostream> 18 20 19 21 #include <osgUtil/Optimizer> … … 135 137 osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments); 136 138 137 if (!scene) return 1; 139 if (!scene) 140 { 141 std::cout << argv[0] << ": requires filename argument." << std::endl; 142 return 1; 143 } 138 144 139 145 // construct the viewer. 140 146 osgViewer::CompositeViewer viewer(arguments); 141 142 143 144 147 145 148 if (arguments.read("-1")) … … 301 304 return viewer.run(); 302 305 } 306 -
OpenSceneGraph/trunk/examples/osgfont/osgfont.cpp
r8274 r9705 12 12 13 13 const osgText::Text::TextureGlyphQuadMap::const_iterator tgqmi = tgqm.begin(); 14 14 15 15 const osgText::Text::GlyphQuads& gq = tgqmi->second; 16 16 … … 60 60 camera->setClearMask(GL_DEPTH_BUFFER_BIT); 61 61 camera->setRenderOrder(osg::Camera::POST_RENDER); 62 62 63 63 return camera; 64 64 } … … 98 98 if(argc <= 2) 99 99 { 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; 101 101 102 102 return 1; … … 107 107 108 108 osg::Group* group = new osg::Group(); 109 osg::Camera* camera = createOrthoCamera(1280.0f, 1024.0f); 109 osg::Camera* camera = createOrthoCamera(1280.0f, 1024.0f); 110 110 111 111 // Create the list of desired sizes. … … 139 139 return viewer.run(); 140 140 } 141 -
OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp
r9637 r9705 45 45 46 46 MovieEventHandler():_playToggle(true),_trackMouse(false) {} 47 47 48 48 void setMouseTracking(bool track) { _trackMouse = track; } 49 49 bool getMouseTracking() const { return _trackMouse; } 50 50 51 51 void set(osg::Node* node); 52 52 53 53 virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv); 54 54 55 55 virtual void getUsage(osg::ApplicationUsage& usage) const; 56 56 … … 66 66 FindImageStreamsVisitor(ImageStreamList& imageStreamList): 67 67 _imageStreamList(imageStreamList) {} 68 68 69 69 virtual void apply(osg::Geode& geode) 70 70 { … … 75 75 apply(geode.getDrawable(i)->getStateSet()); 76 76 } 77 77 78 78 traverse(geode); 79 79 } … … 84 84 traverse(node); 85 85 } 86 86 87 87 inline void apply(osg::StateSet* stateset) 88 88 { 89 89 if (!stateset) return; 90 90 91 91 osg::StateAttribute* attr = stateset->getTextureAttribute(0,osg::StateAttribute::TEXTURE); 92 92 if (attr) … … 99 99 } 100 100 } 101 101 102 102 inline void apply(osg::ImageStream* imagestream) 103 103 { 104 104 if (imagestream) 105 105 { 106 _imageStreamList.push_back(imagestream); 107 } 108 } 109 106 _imageStreamList.push_back(imagestream); 107 } 108 } 109 110 110 ImageStreamList& _imageStreamList; 111 111 112 112 protected: 113 113 114 114 FindImageStreamsVisitor& operator = (const FindImageStreamsVisitor&) { return *this; } 115 115 … … 120 120 bool _trackMouse; 121 121 ImageStreamList _imageStreamList; 122 122 123 123 }; 124 124 … … 151 151 (nv==0 ? view->computeIntersections(ea.getX(), ea.getY(), intersections) : 152 152 view->computeIntersections(ea.getX(), ea.getY(), nv->getNodePath(), intersections)); 153 153 154 154 if (foundIntersection) 155 155 { 156 156 157 // use the nearest intersection 157 // use the nearest intersection 158 158 const osgUtil::LineSegmentIntersector::Intersection& intersection = *(intersections.begin()); 159 159 osg::Drawable* drawable = intersection.drawable.get(); … … 180 180 if (texcoords_Vec2Array) 181 181 { 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. 183 183 osg::Vec2 tc1 = (*texcoords_Vec2Array)[i1]; 184 184 osg::Vec2 tc2 = (*texcoords_Vec2Array)[i2]; … … 280 280 bool flip = image->getOrigin()==osg::Image::TOP_LEFT; 281 281 if (option_flip) flip = !flip; 282 282 283 283 if (useTextureRectangle) 284 284 { … … 291 291 texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); 292 292 texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); 293 294 293 294 295 295 pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0, 296 296 texture, 297 297 osg::StateAttribute::ON); 298 298 299 299 return pictureQuad; 300 300 } … … 305 305 xyPlane ? osg::Vec3(0.0f,height,0.0f) : osg::Vec3(0.0f,0.0f,height), 306 306 0.0f, flip ? 1.0f : 0.0f , 1.0f, flip ? 0.0f : 1.0f); 307 307 308 308 osg::Texture2D* texture = new osg::Texture2D(image); 309 309 texture->setResizeNonPowerOfTwoHint(false); … … 311 311 texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); 312 312 texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); 313 314 313 314 315 315 pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0, 316 316 texture, … … 325 325 // use an ArgumentParser object to manage the program arguments. 326 326 osg::ArgumentParser arguments(&argc,argv); 327 327 328 328 // set up the usage document, in case we need to print out how to use this program. 329 329 arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); … … 335 335 arguments.getApplicationUsage()->addCommandLineOption("--interactive","Use camera manipulator to allow movement around movie."); 336 336 arguments.getApplicationUsage()->addCommandLineOption("--flip","Flip the movie so top becomes bottom."); 337 #if defined(WIN32) || defined(__APPLE__) 337 338 arguments.getApplicationUsage()->addCommandLineOption("--devices","Print the Video input capability via QuickTime and exit."); 338 339 #endif 340 339 341 bool useTextureRectangle = true; 340 342 bool useShader = false; … … 342 344 // construct the viewer. 343 345 osgViewer::Viewer viewer(arguments); 344 346 345 347 if (arguments.argc()<=1) 346 348 { … … 349 351 } 350 352 353 #if defined(WIN32) || defined(__APPLE__) 351 354 // if user requests devices video capability. 352 355 if (arguments.read("-devices") || arguments.read("--devices")) … … 356 359 return 1; 357 360 } 361 #endif 358 362 359 363 while (arguments.read("--texture2D")) useTextureRectangle=false; … … 361 365 362 366 bool mouseTracking = false; 363 while (arguments.read("--mouse")) mouseTracking=true; 367 while (arguments.read("--mouse")) mouseTracking=true; 364 368 365 369 … … 420 424 osg::Vec3 topleft = pos; 421 425 osg::Vec3 bottomright = pos; 422 426 423 427 bool xyPlane = fullscreen; 424 428 425 429 for(int i=1;i<arguments.argc();++i) 426 430 { … … 434 438 { 435 439 osg::notify(osg::NOTICE)<<"image->s()"<<image->s()<<" image-t()="<<image->t()<<std::endl; 436 440 437 441 geode->addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image, useTextureRectangle, xyPlane, flip)); 438 442 439 443 bottomright = pos + osg::Vec3(static_cast<float>(image->s()),static_cast<float>(image->t()),0.0f); 440 444 … … 445 449 { 446 450 std::cout<<"Unable to read file "<<arguments[i]<<std::endl; 447 } 448 } 449 } 450 451 } 452 } 453 } 454 451 455 // set the scene to render 452 456 viewer.setSceneData(geode.get()); … … 497 501 } 498 502 } 503 -
OpenSceneGraph/trunk/examples/osgocclusionquery/osgocclusionquery.cpp
r9395 r9705 246 246 if (_total > _limit) 247 247 break; 248 } 248 } 249 249 } 250 250 … … 312 312 // Don't add one here to avoid hierarchical nesting. 313 313 return; 314 314 315 315 // There are no OQNs below this group. If the vertex 316 316 // count exceeds the threshold, add an OQN here. … … 396 396 397 397 398 void 398 void 399 399 DebugDisplayVisitor::apply( osg::OcclusionQueryNode& oqn ) 400 400 { … … 490 490 // Allow user to do interesting things with an 491 491 // OcclusionQueryNode-enabled scene graph at run time. 492 class KeyHandler : public osgGA::GUIEventHandler 493 { 494 public: 492 class KeyHandler : public osgGA::GUIEventHandler 493 { 494 public: 495 495 KeyHandler( osg::Node& node ) 496 496 : _node( node ), … … 564 564 565 565 osg::StateSet* state = box->getOrCreateStateSet(); 566 osg::PolygonMode* pm = new osg::PolygonMode( 566 osg::PolygonMode* pm = new osg::PolygonMode( 567 567 osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::FILL ); 568 568 state->setAttributeAndModes( pm, … … 631 631 // * Lots of vertices and color data per vertex 632 632 // * No vertex sharing 633 // * Draw the triangles as wireframe 633 634 osg::ref_ptr<osg::Node> 634 635 createRandomTriangles( unsigned int num ) … … 656 657 unsigned int i; 657 658 srand( 0 ); 658 #define RAND_NEG1_TO_1 ( ((rand()%20)-10)*.1 ) 659 #define RAND_NEG1_TO_1 ( ((rand()%20)-10)*.1 ) 659 660 for (i=0; i<num; i++) 660 661 { … … 673 674 c->resize( num ); 674 675 675 #define RAND_0_TO_1 ( (rand()%10)*.1 ) 676 #define RAND_0_TO_1 ( (rand()%10)*.1 ) 676 677 for (i=0; i<num; i++) 677 678 { … … 732 733 return 1; 733 734 } 734 735 735 736 osgViewer::Viewer viewer( arguments ); 736 737 737 738 // add the state manipulator 738 739 viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); 739 740 740 741 // add the stats handler 741 742 viewer.addEventHandler(new osgViewer::StatsHandler); … … 792 793 return viewer.run(); 793 794 } 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 2 2 * 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 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * 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 11 11 * OpenSceneGraph Public License for more details. 12 12 */ 13 13 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 15 15 #ifdef __APPLE__ 16 16 #include <AvailabilityMacros.h> … … 47 47 using namespace osgDB; 48 48 49 DynamicLibrary::DynamicLibrary(const std::string& name, HANDLE handle)49 DynamicLibrary::DynamicLibrary(const std::string& name, HANDLE handle) 50 50 { 51 51 _name = name; … … 68 68 #else // other unix 69 69 dlclose(_handle); 70 #endif 70 #endif 71 71 } 72 72 } … … 80 80 if (!fullLibraryName.empty()) handle = getLibraryHandle( fullLibraryName ); // try the lib we have found 81 81 else handle = getLibraryHandle( libraryName ); // havn't found a lib ourselves, see if the OS can find it simply from the library name. 82 82 83 83 if (handle) return new DynamicLibrary(libraryName,handle); 84 84 … … 116 116 else 117 117 localLibraryName = libraryName; 118 118 119 handle = dlopen( localLibraryName.c_str(), RTLD_LAZY | RTLD_GLOBAL); 119 120 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 } 121 133 #endif 122 134 return handle; … … 156 168 #endif 157 169 } 170
