Loading data from Visual Studio

Hello community,

I’m starting with libcinder. I’m encoutering a problem with my first project.
I would like to load a .obj file. To do this, I use the following code:

ObjLoader loader(loadFile("./data/rcube.obj"), true, false, false);
cubeRef = Batch::create(loader, getStockShader(ShaderDef().color()));

When I run the program from Visual Studio, it crashes because it can’t load
the file. If I run the executable directly, it loads the OBJ file.

What do I have to modify in my VS project settings to solve this problem?

Thanks in advance for your answer(s),

Cinder has a concept of “assets”, which is a folder that can be at your executable level, or up to 5 levels above it, and cinder will try its best to find it. My project structure usually looks something like

+- assets
+- build - cmake generated project / build artifacts / compiled binaries
+- proj - where CMakeLists.txt and cinder blocks live
+- src

Then, you can load from the assets folder by passing a relative path to the loadAsset api. If you’re using cmake, cinder will automatically symlink your assets folder for you as a bonus.

ObjLoader loader ( loadAsset ( "rcube.obj" ), true, false, false );
cubeRef = gl::Batch::create ( loader, gl::getStockShader ( ShaderDef ().color() ) );

If for some reason you need to use loadFile instead, here’s a way to change your working directory inside visual studio.

Hello lithium,

Thank you for your answer. I’ve modified the working directory of my project
and now it runs perfectly!