Corrupt path when loading 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
AndJuly
Posts: 3
Joined: Wed Oct 09, 2019 2:08 am

Corrupt path when loading files

Post by AndJuly »

I am using the following code snippet to load a map...

Code: Select all

 
bool sceneLoaded = scene->loadScene(path("../../assets/map1.irr"));
assert(sceneLoaded);
 
However, the loadScene function prints the this line in the console before returning false.

Code: Select all

 
Unable to open scene file: ./.ast/a1ir²²▌▌▌╜j\
 
Does anyone know what might be causing this? It doesn't seem to matter if I use the file path and name directly or if I put it in the path(const char*) constructor. Thank you!
CuteAlien
Admin
Posts: 9652
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Corrupt path when loading files

Post by CuteAlien »

That part looks fine. Either the scene-file is messed up or the scene pointer is messed up or some other bug which I can't see from this. Or a bug in Irrlicht? Can't tell without more info.
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
AndJuly
Posts: 3
Joined: Wed Oct 09, 2019 2:08 am

Re: Corrupt path when loading files

Post by AndJuly »

Here is the entirety of the graphics class. I have been able to add geometry to the scene through the GeometryFactory and can see them rendered in the scene, but I have not been able to load any assets.

Graphics.h

Code: Select all

 
class Graphics
{
    Client& _client;
 
    IrrlichtDevice* _device;
    IVideoDriver* _driver;
    ISceneManager* _sceneManager;
    IGUIEnvironment* _gui;
 
    TopDownCamera _camera;
    Terrain _terrain;
 
public:
    Graphics(Client& client);
    ~Graphics();
 
    // Draws the scene as is and waits until the desired frametime has passed
    bool draw();
};
 
Graphics.cpp

Code: Select all

 
#include "Graphics.h"
#include "Scene.h"
#include <irrlicht\irrlicht.h>
 
Graphics::Graphics(Client& client)
    : _client(client)
{
    _device = createDevice(video::EDT_OPENGL, dimension2d<u32>(640, 480), 16U, false, false, true, 0);
    if (!_device)
    {
        printf("Graphics: Error creating the IrrlichtDevice!\n");
        return;
    }
    _device->setWindowCaption(L"MMO Client");
    printf("%ws\n", _device->getFileSystem()->getWorkingDirectory().c_str());
 
    _driver = _device->getVideoDriver();
    _sceneManager = _device->getSceneManager();
 
    // Setup the gui
    _gui = _device->getGUIEnvironment();
    _gui->addStaticText(L"Hello World! This is Irrlicht with the OpenGL renderer!", rect<s32>(10, 10, 260, 22), true);
 
    _camera = TopDownCamera(_sceneManager);
 
    bool sceneLoaded = _sceneManager->loadScene(path("../../assets/map1.irr"));
    assert(sceneLoaded);
}
 
Graphics::~Graphics()
{
    if (_driver)
        _driver->drop();
}
 
bool Graphics::draw()
{
    if (!_device->run())
        return false;
 
    _driver->beginScene(true, true, SColor(255, 255, 255, 255));
    _sceneManager->drawAll();
    //_gui->drawAll();
    _driver->endScene();
    return true;
}
 
 
Here is the console output from the code:

Code: Select all

 
Irrlicht Engine version 1.8.4
 (Build 9200)
WGL_extensions: WGL_EXT_depth_float WGL_ARB_buffer_region WGL_ARB_extensions_string WGL_ARB_make_current_read WGL_ARB_pixel_format WGL_ARB_pbuffer WGL_EXT_extensions_string WGL_EXT_swap_control WGL_ARB_multisample WGL_ARB_pixel_format_float WGL_ARB_framebuffer_sRGB WGL_ARB_create_context WGL_ARB_create_context_profile WGL_EXT_pixel_format_packed_float WGL_EXT_create_context_es_profile WGL_EXT_create_context_es2_profile WGL_NV_DX_interop WGL_WGL_INTEL_cl_sharing WGL_NV_DX_interop2 WGL_ARB_create_context_robustness WGL_ARB_context_flush_control
Pixel Format: 20
Using renderer: OpenGL 4.5.0
Intel(R) HD Graphics 630: Intel
OpenGL driver version is 1.2 or better.
GLSL version: 4.5
Resizing window (640 480)
C:/Users/liamd/source/repos/MMO/MMOClient
Unable to open scene file: ./.ast/a1ir²²
 
CuteAlien
Admin
Posts: 9652
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Corrupt path when loading files

Post by CuteAlien »

Have you tried loading the scene in the MeshViewer example? If it works there the bug is likely in the code, if it fails there as well the bug is in the scene-file.

The additional code you posted doesn't really help me to help you as I can't use it for debugging. I can't see if any pointers go wrong or something like that. Did you check the 'scene' pointer at that place in the debugger? Do it's values seem strange?

If that doesn't help - can you reduce the bug to a simple example? For example you could try to adapt example 15 and put that loading code in there and check if it works there or also fails.
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
AndJuly
Posts: 3
Joined: Wed Oct 09, 2019 2:08 am

Re: Corrupt path when loading files

Post by AndJuly »

I tried loading the scene from Tutorial 15 on the Sourceforge page, only to be seeing the same error. "Unable to open scene file: ./.mdaeapeir²²▌▌NI▌". I would assume that the function must be printing the exact filename I gave it when it complains about not being able to open the file (which gives the same error whether the file exists or not), so I don't understand how what's coming out of this function could be so corrupt. The fact that anything shows up at all suggests to me that IrrlichtDevice* at least points to a virtual function table pointing to the correct function. The camera moves properly in the sample as well, and I am seeing 2200 fps.

By the way, thank you so much for your speedy reply. I wasn't expecting to receive so much help :)
CuteAlien
Admin
Posts: 9652
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Corrupt path when loading files

Post by CuteAlien »

And does the .irr file load in example 09? (without any changes, just load it from the menu).
If it fails there as well then I need the .irr file to debug what's going on.

Speedy replies are a special this week ;-)
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
Post Reply