IVideoDriver::getTexture(const c8*) changed

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
aanderse
Posts: 155
Joined: Sun Aug 10, 2008 2:02 pm
Location: Canada

IVideoDriver::getTexture(const c8*) changed

Post by aanderse »

I just updated svn and recompiled, now all my textures aren't showing up.

If i take a look in CNullDriver.cpp at the ITexture* CNullDriver::getTexture(const c8* filename) function I notice it starts with this:

Code: Select all

	// Identify textures by their absolute filenames.
	core::stringc absolutePath = FileSystem->getAbsolutePath(filename);

	ITexture* texture = findTexture(absolutePath.c_str());

	if (texture)
		return texture;
If I take a look in CFileSystem.cpp at core::stringc CFileSystem::getAbsolutePath(const core::stringc& filename) const I see this:

Code: Select all

	c8 *p=0;

#ifdef _IRR_WINDOWS_API_
	#if !defined ( _WIN32_WCE )
		c8 fpath[_MAX_PATH];
		p = _fullpath( fpath, filename.c_str(), _MAX_PATH);
	#endif

#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_))
	c8 fpath[4096];
	p = realpath(filename.c_str(), fpath);
#endif

	return core::stringc(p);
So if I call IVideoDriver::getTexture based on filename AND I'm counting on any of addFolderFileArchive, addZipFileArchive, or addPakFileArchive I'm out of luck because clearly there's no internal (in CFileSystem class) search going on. I'm not understanding how to use this properly I guess. Concrete example of how I'm going wrong.

Concrete example:
code/main.cpp
resources/art/bitmaps/invalid.jpg

Code: Select all

int main()
{
    IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480), 32, false, false, false);

    if (device == 0)
        return 1;

    device->getFileSystem()->addFolderFileArchive("../resources", true, false);
    video::ITexture *texture = device->getVideoDriver()->getTexture("art/bitmaps/invalid.jpg");
    cout << "texture is " << (texture ? "valid" : "invalid") << endl;

    device->drop();
    return 0;
This is going to print out "texture is invalid" obviously. How am I supposed to do this?

Thanks
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Sorry, my bad. Root cause: insufficient testing. :(

I've restored the old behaviour as a fallback if the file can't be found with an absolute path, in SVN 1680 (trunk) and 1681 (1.4 branch).

Test app updated with your test case. Thanks again for the great bug report, and please do let me/us know if there's any further problems.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Note for anyone else effected by this: aanderse reports that he's still having problems on Linux with the SVN 1680 code. I can't replicate the issue on Windows, but will try it on my Linux install tonight.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply