WriteFile 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  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
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef OSGDB_WRITEFILE
  14. #define OSGDB_WRITEFILE 1
  15. #include <osg/Image>
  16. #include <osg/Shape>
  17. #include <osg/Node>
  18. #include <osgDB/Export>
  19. #include <osgDB/Registry>
  20. #include <string>
  21. namespace osgDB {
  22. /** Write an osg::Object to file.
  23. * Return true on success,
  24. * return false on failure.
  25. * Use the Options object to control cache operations and file search paths in osgDB::Registry.
  26. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  27. * for the filename extension, and this plugin then handles the request
  28. * to write the specified file.*/
  29. extern OSGDB_EXPORT bool writeObjectFile(const osg::Object& object, const std::string& filename, const Options* options );
  30. /** Write an osg::Object to file.
  31. * Return true on success,
  32. * return false on failure.
  33. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  34. * for the filename extension, and this plugin then handles the request
  35. * to write the specified file.*/
  36. inline bool writeObjectFile(const osg::Object& object, const std::string& filename)
  37. {
  38. return writeObjectFile( object, filename, Registry::instance()->getOptions() );
  39. }
  40. /** Write an osg::Image to file.
  41. * Return true on success,
  42. * return false on failure.
  43. * Use the Options object to control cache operations and file search paths in osgDB::Registry.
  44. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  45. * for the filename extension, and this plugin then handles the request
  46. * to write the specified file.*/
  47. extern OSGDB_EXPORT bool writeImageFile(const osg::Image& image, const std::string& filename, const Options* options );
  48. /** Write an osg::Image to file.
  49. * Return true on success,
  50. * return false on failure.
  51. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  52. * for the filename extension, and this plugin then handles the request
  53. * to write the specified file.*/
  54. inline bool writeImageFile(const osg::Image& image, const std::string& filename)
  55. {
  56. return writeImageFile( image, filename, Registry::instance()->getOptions() );
  57. }
  58. /** Write an osg::HeightField to file.
  59. * Return true on success,
  60. * return false on failure.
  61. * Use the Options object to control cache operations and file search paths in osgDB::Registry.
  62. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  63. * for the filename extension, and this plugin then handles the request
  64. * to write the specified file.*/
  65. extern OSGDB_EXPORT bool writeHeightFieldFile(const osg::HeightField& hf, const std::string& filename, const Options* options );
  66. /** Write an osg::HeightField to file.
  67. * Return true on success,
  68. * return false on failure.
  69. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  70. * for the filename extension, and this plugin then handles the request
  71. * to write the specified file.*/
  72. inline bool writeHeightFieldFile(const osg::HeightField& hf, const std::string& filename)
  73. {
  74. return writeHeightFieldFile( hf, filename, Registry::instance()->getOptions() );
  75. }
  76. /** Write an osg::Node to file.
  77. * Return true on success,
  78. * return false on failure.
  79. * Use the Options object to control cache operations and file search paths in osgDB::Registry.
  80. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  81. * for the filename extension, and this plugin then handles the request
  82. * to write the specified file.*/
  83. extern OSGDB_EXPORT bool writeNodeFile(const osg::Node& node, const std::string& filename, const Options* options );
  84. /** Write an osg::Node to file.
  85. * Return true on success,
  86. * return false on failure.
  87. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  88. * for the filename extension, and this plugin then handles the request
  89. * to write the specified file.*/
  90. inline bool writeNodeFile(const osg::Node& node, const std::string& filename)
  91. {
  92. return writeNodeFile( node, filename, Registry::instance()->getOptions() );
  93. }
  94. /** Write an osg::Shader to file.
  95. * Return true on success,
  96. * return false on failure.
  97. * Use the Options object to control cache operations and file search paths in osgDB::Registry.
  98. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  99. * for the filename extension, and this plugin then handles the request
  100. * to write the specified file.*/
  101. extern OSGDB_EXPORT bool writeShaderFile(const osg::Shader& shader, const std::string& filename, const Options* options );
  102. /** Write an osg::Shader to file.
  103. * Return true on success,
  104. * return false on failure.
  105. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  106. * for the filename extension, and this plugin then handles the request
  107. * to write the specified file.*/
  108. inline bool writeShaderFile(const osg::Shader& shader, const std::string& filename)
  109. {
  110. return writeShaderFile( shader, filename, Registry::instance()->getOptions() );
  111. }
  112. /** Write an osg::Script to file.
  113. * Return true on success,
  114. * return false on failure.
  115. * Use the Options object to control cache operations and file search paths in osgDB::Registry.
  116. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  117. * for the filename extension, and this plugin then handles the request
  118. * to write the specified file.*/
  119. extern OSGDB_EXPORT bool writeScriptFile(const osg::Script& image, const std::string& filename, const Options* options );
  120. /** Write an osg::Script to file.
  121. * Return true on success,
  122. * return false on failure.
  123. * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  124. * for the filename extension, and this plugin then handles the request
  125. * to write the specified file.*/
  126. inline bool writeScriptFile(const osg::Script& image, const std::string& filename)
  127. {
  128. return writeScriptFile( image, filename, Registry::instance()->getOptions() );
  129. }
  130. }
  131. #endif