Loading textures onto files.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Markhor
Posts: 20
Joined: Thu Sep 02, 2010 2:09 pm

Loading textures onto files.

Post by Markhor »

Excuse me while I get beaten up for asking this amateur hour question..

Where do applications look for texture files? Inside where the binary is located? Because if so it does not like my texture.
I'm wanting to replace Sydney on the tutorial with a cubeSceneNode with a simple brick texture, to see if I can do it.
I ask, and will continue to spam the texture file in different parts of the project's folder until I figure it out. Or get an answer.
Thank you.

Edit: it says "Could not open file of texture: brick.bmp"
Well, it wouldn't open the jpeg either.

Edit2: it's a 615x410 bitmap of a brick wall.
Put the file in every single project folder, but not where the Irrlicht code is stored. Wanting to avoid that.
It's either the resolution, my coding, or the location.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Re: Loading textures onto files.

Post by Lonesome Ducky »

The texture files are relative to the executable (or wherever the program is being run)
Markhor
Posts: 20
Joined: Thu Sep 02, 2010 2:09 pm

Re: Loading textures onto files.

Post by Markhor »

Lonesome Ducky wrote:The texture files are relative to the executable (or wherever the program is being run)
Thank you. I'm doing it wrong.
Even with the brick.bmp file in the executable's folder, I cannot get it to load. Same error message when running it through Code::Blocks, and the EXE needs Irrlicht stuff probably copied over into the folder to test it. Hmm.

Edit: copying Irrlicht.dll into the EXE's folder and running the executable causes a crash. Ok.

Any ideas why the compiler/IDE might not pick up on the file? I'll focus on that issue first, hopefully avoiding my mistake later.

Edit 2:
2 Questions. Still in idiot hour myself, not understanding this.
1) Can a simple "addCubeSceneNode" be textured?
and 2) do I need to convert it to a mesh or anything? I'm not using a cube model, just a function node.
Yes I can post code if wanted.
Thank you for at least reading.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Loading textures onto files.

Post by mongoose7 »

I think code blocks runs the EXE with a different CWD than where the EXE is written - probably your project folder.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Loading textures onto files.

Post by CuteAlien »

The working directory when started from within C::B is defined by the "Execution working dir" which can be find in the "Build target"s tab. So the path is relative to that when starting from within C::B and relative to the exe-file when clicking the exe directly (so life can sometimes be made easier by setting the Execution working dir to the same path where the exe is located.

Copying the Irrllicht dll beside the exe should be fine. If it crashes there is a good chance that it's either the wrong DLL or you compile against the wrong headers. Or there is simply a bug in your code.

And yes - you can texture a cube you added with addCubeSceneNode.
Try: node->getMaterial(0).TextureLayer[0].Texture = ... your texture here ...;
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Markhor
Posts: 20
Joined: Thu Sep 02, 2010 2:09 pm

Re: Loading textures onto files.

Post by Markhor »

Well the file seems to be in the right place. Now my code is causing it to crash. So I'll look at that. Thanks.

edit:
Got it to work. Wrong Irrlicht dll...gcc didn't work originally so used VC thing, went back to gcc. working fine, thank you all
Post Reply