Problem loading textures
Problem loading textures
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?
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.
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.
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.
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?
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
.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
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 directorytimofiend 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 true. Listen to this.Radikalizm wrote: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 directorytimofiend 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
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);
