Code Monkey home page Code Monkey logo

Comments (4)

NickHardeman avatar NickHardeman commented on May 31, 2024 1

Checking on Windows 10 with VS 2022 and nightly, I can confirm the error :
no instance of overloaded function ofApp::loadModel matches the argument list
The loadModel function takes a string as an argument.
void ofApp::loadModel( string filename );

from openframeworks.

NickHardeman avatar NickHardeman commented on May 31, 2024

Are you working with an up to date master?
I just checked with the nightly on macOS and it compiles without the .string() appended.

from openframeworks.

artificiel avatar artificiel commented on May 31, 2024

@lvdpower are you on windows? it may be related to recent changes with file paths. can you provide the file path you are dragging (does it contain unicode?), as well as the exact error you are getting?

from openframeworks.

artificiel avatar artificiel commented on May 31, 2024

well it's a perfect example. the loadModel function is given an fs::path, which on windows implicitly turns into a wstring.

now the question is: does the underlying assimp lib support windows wide char paths? if so, the path properties should be maintained down to the underlying lib call. if not, I suggest the same pattern we just discussed here:

// pseudo, for a lib that does not support wchar
loadModel(fs::path filename) {
  if (auto name_as_string = ofPathToString(filename)) { // explicit conversion with try-catch turning into an optional
    // GOOD: the path is either native std::string, or contains no untranslatable wchar unicode
    // do the thing with *name_as_string 
  } else {
    // we're on windows, and the path contains untranslatable wchar
    // somehow inform user that the given path is not digestible by the library
  }
}

this introduces the <optional> pattern which is a simple and effective way of dealing with "disappointments". note that this won't work right now as the current implementation of ofPathToString is not <optional>.

if the lib supports wchar:, presumably (invented API):

loadModel(fs::path filename) {
  auto charpath = filename.native().c_str(); // on windows auto is wchar, else is char
  LibObject object;
  #ifdef WIN32 // or maybe an if constexpr switch based on type
     LIB_loadfromwchar(charpath, &object);
  #else 
     LIB_loadfromchar(charpath, &object);
  #endif
  // object contains data
}

all this might seem a bit overkill, but if we want transparent unicode wchar support in OF it means pushing the of::path properties as down and as close to the consumer as possible.

from openframeworks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.