2013-02-05 7 views
0

OSX 10.6.8을 실행하는 Macbook Pro에 Cinder v0.8.4를 다운로드하고 Xcode를 사용하여 Cinder를 시작했습니다. Tinderbox 도구를 사용하여 기본 옵션이있는 CinderProjectApp라는 새 프로젝트를 만들었습니다. 나는 또한 나의 부스트 라이브러리가 디폴트 (1.4.2)와 동일하다는 것을 보장하기 위해 지시 사항을 따른다.Xcode 10.6.8의 Cinder 튜토리얼 초반부에 getOpenFilePath 오류가 발생했습니다.

튜토리얼을 시작하면서/resources 폴더에서 이미지를로드 할 수 있는지 확인하고 싶었 기 때문에 이미지 "Broccoli.jpg"를 다운로드하여 CinderProjectApp/resources/디렉토리에 추가했습니다. '부스트 : filesystem3를 :: 경로를'비에에서 변환 : 내 작은 CinderProjectApp.cpp 코드 전체를 컴파일 할 때

void CinderProjectApp::draw() 
{ 
    gl::clear(Color(0, 0, 0), true); 

    try 
    {  
     std::string p = FilePath("", ImageIo::getLoadExtensions());  

     if(! p.empty()) 
     { // an empty string means the user canceled  
      myImage = gl::Texture(loadImage(p)); 
     } 
    } 

    catch(...) 
    { 
     console() << "Unable to load the image." << std::endl; 
    } 

    gl::draw(myImage, getWindowBounds()); 
} 

, 나는 오류 : 여기

내 무승부() 함수 -scalar type 'std :: basic_string, std :: allocator>'는 파일 경로를 지정하는 줄에을 요청했습니다. 구문 적으로 유효하기 때문에 getOpenFilePath를 사용하여 여기서 잘못된 점이 무엇인지 궁금합니다.

나머지 코드를 확인하려면 알려 주시기 바랍니다. 그건 그렇고, 난 내 질문을 crossposted here.

답변

2

forum.libcinder.org에서 Paul and Sansumbrella’s help 덕분에, 나는 try-catch를 (효율적으로) setup 함수로 옮기고 ci :: fs :: path 객체를 사용하여 경로를 유지했습니다. 다음은 새로운 setup() 함수입니다 (위에서 draw()의 모든 내용이 try-catch 논리의 순서 변경 외에 변경되지 않았다고 가정).

void CinderProjectApp::setup() 
{ 

    try 
    { 
     ci::fs::path p = getOpenFilePath("", ImageIo::getLoadExtensions()); 

     if(! p.empty()) 
     { // an empty string means the user canceled 
      myImage = gl::Texture(loadImage(p)); 
     } 
    } 

    catch(...) 
    { 
     console() << "Unable to load the image." << std::endl; 
    } 
}