Problem loading textures

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
timofiend
Posts: 14
Joined: Tue Feb 22, 2011 5:57 pm
Location: 115

Problem loading textures

Post by timofiend »

So I am following tutorial 15 of the tutorials on the Irrlicht website, and I copied and pasted the exact code into Visual Studio express 2010, but for some reason no textures are being loaded, and so nothing appears on screen when i try to run the program.

This is a screenshot of the code that appeared in the command prompt window.

edit - put the correct screenshot in

http://i.imgur.com/qdM9m.jpg

Made no changes to the tutorial instructions, any ideas why the textures arent loading?
Last edited by timofiend on Tue Feb 22, 2011 8:16 pm, edited 1 time in total.
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

Probably path to the textures is wrong.

You can copy all those textures to your Debug folder and use just their names for loading, or you should specify correct relative path.
timofiend
Posts: 14
Joined: Tue Feb 22, 2011 5:57 pm
Location: 115

Post by timofiend »

This is the tutorial I am using:

http://irrlicht.sourceforge.net/docu/example015.html

There is no mention of the texture filepaths, I assumed the textures would be stored in the .irr file and load up automatically?

I did specify file paths for certain objects and it loaded the textures for them, but I thought I would not have to do this as the tutorial made no mention of it?

edit - It cannot seem to load the example file either, says it could not open the .3ds mesh file or the textures, file paths are definitely correct.
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

You better check what returns "device->getFileSystem()->getWorkingDirectory()". Maybe Visual Studio starts your project not from Debug, but from root of the project. I mean it starts not like "app.exe", but like "Debug\app.exe".
timofiend
Posts: 14
Joined: Tue Feb 22, 2011 5:57 pm
Location: 115

Post by timofiend »

Im pretty sure its running from the debug folder, as the irrlicht DLL file has to be in this folder with the .exe otherwise the program will not run
wahagn
Posts: 186
Joined: Sat Dec 06, 2008 5:11 pm
Location: Zundert (Netherlands)

Post by wahagn »

Did you alreday check wheter that folder exist en is on the place where the program is trying to find it? I mean the ../../media folder ofcourse
“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”
(Eagleson’s Law)
timofiend
Posts: 14
Joined: Tue Feb 22, 2011 5:57 pm
Location: 115

Post by timofiend »

Yep double checked the folder exists, and it also says it failed to open the .3ds file and texture files, not failed to find them. But im sure the file paths are correct.

I also tried doing the simpler tutorial that came with the irrlicht download, which did not include collision detection etc, which still didnt work.

This is the code from the simpler tutorial exactly as it was in the tut, apart from the file path amendment, and the stdafx header at the top which was not included in the tut.

I cant see anything wrong here (although I am a newbie at this), and I get no errors when compiling etc, just cannot load any files that I imported into irredit (3ds or obj files etc) or load any textures. Any ideas?

Code: Select all

#include "stdafx.h"
#include <irrlicht.h"
using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

int main()
{
	// ask user for driver

	video::E_DRIVER_TYPE driverType;

	printf("Please select the driver you want for this example:\n"\
		" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
		" (d) Software Renderer\n (e) Apfelbaum Software Renderer\n"\
		" (f) NullDevice\n (otherKey) exit\n\n");

	char i;
	std::cin >> i;

	switch(i)
	{
		case 'a': driverType = video::EDT_DIRECT3D9;break;
		case 'b': driverType = video::EDT_DIRECT3D8;break;
		case 'c': driverType = video::EDT_OPENGL;   break;
		case 'd': driverType = video::EDT_SOFTWARE; break;
		case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
		case 'f': driverType = video::EDT_NULL;     break;
		default: return 1;
	}	

	// create device and exit if creation failed

	IrrlichtDevice* device =
		createDevice(driverType, core::dimension2d(640, 480));

	if (device == 0)
		return 1; // could not create selected driver.

	device->setWindowCaption(L"Load .irr file example");

	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();

//Now load our .irr file. .irr files can store the whole scene graph including animators, materials and particle systems. And there is also the possibility to store arbitrary user data for every scene node in that file. To keep this example simple, we are simply loading the scene here. See the documentation at ISceneManager::loadScene and ISceneManager::saveScene for more information. So to load and display a complicated huge scene, we only need a single call to loadScene().

// load the scene

smgr->loadScene("c:/irrlicht-1.7.2/media/example.irr"); 

//That was it already. Now add a camera and draw the scene.

	// add a user controlled camera

	smgr->addCameraSceneNodeFPS();

	// and draw everything.
	
	while(device->run())
	if (device->isWindowActive())
	{
		driver->beginScene(true, true, video::SColor(0,200,200,200));
		smgr->drawAll();
		driver->endScene();
	}

	device->drop();
	
	return 0;
}

Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

.irr files load textures relative to the executable, and not the irr file. Could that be part of the problem?
Last edited by Lonesome Ducky on Wed Feb 23, 2011 12:07 am, edited 1 time in total.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

timofiend wrote:Im pretty sure its running from the debug folder, as the irrlicht DLL file has to be in this folder with the .exe otherwise the program will not run
This is not necessarily true, check your project settings to see whether your working directory actually is the same directory as your executable, visual studio defaults the working directory to the project directory
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

Radikalizm wrote:
timofiend wrote:Im pretty sure its running from the debug folder, as the irrlicht DLL file has to be in this folder with the .exe otherwise the program will not run
This is not necessarily true, check your project settings to see whether your working directory actually is the same directory as your executable, visual studio defaults the working directory to the project directory
This is true. Listen to this.

Also, try this code snippet. It will set your working directory to the same directory your executable is running from:

Code: Select all

io::path base_directory;
{
	// Get the base directory.
#if defined(WIN32) || defined(_WIN32)
	// Get the path.
	TCHAR path[MAX_PATH];
	GetModuleFileName(0, path, MAX_PATH);

	// Find the program exe and remove it from the path.
	// Assign the path to homepath.
	base_directory = path;
	int pos = base_directory.findLast('\\');
	if (pos == -1) base_directory = "";
	else if (pos != (base_directory.size() - 1))
		base_directory = base_directory.subString(0, pos + 1);
#else
	// Get the path to the program.
	char path[260];
	memset((void*)path, 0, 260);
	readlink("/proc/self/exe", path, sizeof(path));

	// Assign the path to homepath.
	char* end = strrchr(path, '/');
	if (end != 0)
	{
		end++;
		if (end != 0) *end = '\0';
		base_directory = path;
	}
#endif
}
device->getFileSystem()->changeWorkingDirectoryTo(base_directory);
Post Reply