Well... no answers. Hopefully if I report my latests efforts I'll get some attention
![Laughing :lol:](./images/smilies/icon_lol.gif)
.
Summary of this post:
A. Bug fix! My contribution to Irrlicht
B. Remaining (horrible) bugs
C. Information to reproduce the bug(s)
A.
I didn't manage to run the app with the debug .DLL on the Pocket PC emulator, it kept telling me "wrong Windows version". In the end I created a new project and statically linked Irrlicht into my test app, to be able to debug it.
This finally allowed me to solve one of my problems.
I fixed a bug in Irrlicht 1.5 which makes loading any file impossible under Windows Mobile or CE !! That's why loading models and textures failed.
The faulty code is this method in CFileSystem.cpp:
Code: Select all
core::stringc CFileSystem::getAbsolutePath(const core::stringc& filename) const
{
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];
fpath[0]=0;
p = realpath(filename.c_str(), fpath);
if (!p)
{
// content in fpath is undefined at this point
if ('0'==fpath[0]) // seems like fpath wasn't altered
{
// at least remove a ./ prefix
if ('.'==filename[0] && '/'==filename[1])
return filename.subString(2, filename.size()-2);
else
return filename;
}
else
return core::stringc(fpath);
}
#endif
return core::stringc(p);
}
When under Windows CE/Mobile, only the first and last line are executed, so the function does the following, which erases the file path:
Naturally this prevents any file to load. What I did to fix this is to return directly the
filename parameter, since pathnames are always absolute on windows Mobile/CE:
Corrected code, the changes are at the end:
Code: Select all
core::stringc CFileSystem::getAbsolutePath(const core::stringc& filename) const
{
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];
fpath[0]=0;
p = realpath(filename.c_str(), fpath);
if (!p)
{
// content in fpath is undefined at this point
if ('0'==fpath[0]) // seems like fpath wasn't altered
{
// at least remove a ./ prefix
if ('.'==filename[0] && '/'==filename[1])
return filename.subString(2, filename.size()-2);
else
return filename;
}
else
return core::stringc(fpath);
}
#endif
#ifdef _WIN32_WCE
return filename; //unmodified, since WinCE only uses absolute pathnames
#else
return core::stringc(p);
#endif
}
B.
Now for the bad news:
- I get an access violation whenever I attempt to load Sydney.md2. I assume it's because of a lack of memory, since the model is pretty big with all those animation frames, and there's little memory on a PocketPC. Still, shouldn't this be treated more gracefully?
- I replaced Sydney by ninja.b3d, the smallest model file I could find in the /media folder. This time, the model displays and animates, but it's all black. Its texture (the blue ninja one) is not displayed, even though debugging shows that the file is found, and I can display 2D images (such as the Irrlicht logo .tga with transparency) fine.
- If I set the camera close enough to the model (so it almost fills the screen), the ninja goes through a few animations, and then the program crashes with an access violation, always on the following line of CTRTextureGouraud2.cpp:
Code: Select all
#ifdef CMP_W
if ( line.w[0] >= z[i] )
#endif
The access violation is due to z being a pointer to forbidden memory.
I've tried disabling/enabling some features such as Z Buffer, but this just produces an access violation elsewhere. The crash always seems to happen when part of the ninja model moves out of the window, or when the ninja jumps away from the camera (positioned below him).
C.
If you want to help solve the bugs and perfect the Irrlicht WindowsCE/Mobile port, here are the resources:
- You need Visual Studio 2005 SP1 (I'm running this under Windows XP SP3)
- Install the Windows Mobile 5.0 SDK and ActiveSync 4.5
- Start an empty project targeting Windows Mobile 5.
- Add all the source and header files from Irrlicht 1.5 in your project, and add the Source and Source\zlib folders to your additional include directories.
- To statically link Irrlicht into your app, you need to set the following preprocessor definitions in the project properties:
Code: Select all
_IRR_STATIC_LIB_
_DEBUG
_WIN32_WCE=$(CEVER)
UNDER_CE
$(PLATFORMDEFINES)
WINCE
DEBUG
_WINDOWS
$(ARCHFAM)
$(_ARCHFAM_)
_UNICODE
UNICODE
NO_GETENV
_CRT_SECURE_NO_DEPRECATE
- The code for the test program is the following, put it in a new .cpp file:
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(linker, "/subsystem:WINDOWSCE /ENTRY:main")
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_BURNINGSVIDEO, dimension2d<s32>(200, 200), 16,
false, false, false, 0);
if (!device)
return 1;
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,100,22), true);
IAnimatedMesh* mesh = smgr->getMesh("\\Program Files\\HelloWorld_mobile5\\ninja.b3d");
if (!mesh)
return 1;
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setAnimationSpeed(15);
ITexture * texture = driver->getTexture("\\Program Files\\HelloWorld_mobile5\\nskinbl.jpg");
node->setMaterialTexture( 0, texture);
}
smgr->addCameraSceneNode(0, vector3df(0,-5,5), vector3df(0,5,0));
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
- Play with the deployment options in the project properties (as well as the file paths in the test app code) to make sure that ninja.b3d and nskinbl.jpg are deployed in the same folder as your app on the Pocket PC emulator.
- Compile, deploy and run! You'll soon get the crash, but you can avoid it by putting the camera position further away from the model.
- Post your results and bug fixes in this thread.