2012-10-24 71 views
1

在這個簡單的例子煤渣(由煤渣介紹 - http://libcinder.org/docs/v0.8.4/hello_cinder.html)我得到這個編譯錯誤:煤渣函數重載錯誤

myImage = gl::Texture(loadImage(loadResource("image.jpg"))); 

錯誤1個錯誤C2661: '煤渣::應用::應用:: loadResource':沒有重載函數有1個參數

但是文檔說:

DataSourceRef cinder::app::loadResource ( const std::string &  macPath ) 

任何想法?

回答

2

你指的是相同的功能:

cinder::app::App::loadResoure 
cinder::app::loadResource 

沒用過這個LIB,但醫生說第一個功能需要更多的參數:

http://libcinder.org/docs/v0.8.4/classcinder_1_1app_1_1_app.html#afef905bb792960152d38c2680f88ea33

static DataSourceRef cinder::app::App::loadResource ( 
     const std::string & macPath, 
     int mswID, 
     const std::string & mswType 
) 
+0

謝謝。顯然,cinder在Windows上以不同方式處理資源。教程是爲Mac。有關cinder資源的更多信息:(http://libcinder.org/docs/v0.8.4/_cinder_resources.html) cinder對windows的支持似乎還處於初級階段。 – dvgvrco

+0

我不會說Cinder對Windows的支持還處於起步階段。 OS X和Windows平臺都積極保持最新狀態,其中一個與另一個沒有多大區別。然而,Cinder的文檔有點落後,這是你錯誤的原因:在編寫文檔後功能被改變了。 Cinder有一個非常活躍的論壇,其中你在這裏發佈的問題通常在幾個小時內得到解答,請參閱http://forum.libcinder.org,但我想你現在已經發現了:) –

0

你最好試裝作爲資產而不是資源:

gl::TextureRef  texImagen; 
    texImagen = gl::Texture::create(loadImage(getAssetPath("image.jpg"))); 

其中image.jpg位於資產文件夾中。資產在運行時從此資產文件夾加載。這個文件夾可以在程序的同一層或上面三個。

資源均位於資源文件夾,並在編譯階段被複制,並與應用程序或可執行包裝。

要使用包括資源頭

#include "Resources.h" 

其中包含這樣的

#pragma once 
#include "cinder/CinderResources.h" 
#define MY_IMAGE  CINDER_RESOURCE(../resources/, image.jpg, 1, IMAGE) 

然後,你可以加載它

texImagen = gl::Texture::create(loadResource(MY_IMAGE)); 

請注意,如果你是在Xcode中,您的圖片必須添加到您的項目中,只需將其拖到項目樹中即可。