cinder function overload error
-
14-07-2021 - |
Question
In this simple cinder example (from cinder introduction - http://libcinder.org/docs/v0.8.4/hello_cinder.html) I get this compilation error:
myImage = gl::Texture( loadImage( loadResource( "image.jpg" ) ) );
Error 1 error C2661: 'cinder::app::App::loadResource' : no overloaded function takes 1 arguments
However documentation says:
DataSourceRef cinder::app::loadResource ( const std::string & macPath )
Any ideas?
Solution
Are you referring to the same function:
cinder::app::App::loadResoure
cinder::app::loadResource
Never used this lib, but doc says the first function needs more parameters:
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
)
OTHER TIPS
You better try loading as an assets instead of a resource:
gl::TextureRef texImagen;
texImagen = gl::Texture::create( loadImage( getAssetPath( "image.jpg" ) ) );
Where image.jpg
is located int the assets folder. Assets are loaded at runtime from this assets folder. This folder can be at the same leve of the program or up to three above.
Resources are located in the resources folders and are copied at compilation stage and packaged with the app or executable.
To use the include the resources header
#include "Resources.h"
which contains something like this
#pragma once
#include "cinder/CinderResources.h"
#define MY_IMAGE CINDER_RESOURCE( ../resources/, image.jpg, 1, IMAGE )
Then you can load it
texImagen = gl::Texture::create( loadResource( MY_IMAGE ) );
Beware that if you are in Xcode, your image must be added to your project, just drag it to the project tree.