osg_utility.cpp 563 B

1234567891011121314151617
  1. #include "osg_utility.h"
  2. #include <boost/iostreams/device/mapped_file.hpp>
  3. #include <filesystem>
  4. namespace fs = std::filesystem;
  5. std::string load_shader(const std::string &shader_name) {
  6. using boost::iostreams::mapped_file;
  7. // TODO: load from current binary directory
  8. const fs::path shader_prefix = "/home/tpx/ext/project/DepthGuide/src/render_osg/shaders";
  9. const auto shader_path = shader_prefix / shader_name;
  10. const auto shader = mapped_file(shader_path);
  11. assert(shader.is_open());
  12. return {shader.const_data(), shader.size()};
  13. }