diff --git a/changes.txt b/changes.txt index 47c4fad9..0a346657 100644 --- a/changes.txt +++ b/changes.txt @@ -1,4 +1,16 @@ -Changes in 1.6 (??.??.2009) +Changes in 1.6.1 + + - Fix another (OldValue == NewValue) before drop()/grap(), this time in CTextureAttribute::setTexture. + + - Bugfix: CGUIToolBar::addButton does no longer mess up when no image is set and does now actually work with the text. + + - Fix ninja animation range which got messed up a little when b3d animations got fixed (thx gbox for finding) + +Changes in 1.6 (23.09.2009) + + - Added IFileSystem::createEmptyFileList, exposed IFileList::sort, addItem and added getID + + - Fix MAKE_IRR_ID so it can be used from outside the irr namespace (Micha's patch) - Renamed some methods in ISkinnedMesh to match the official Irrlicht naming scheme according to createXXX() @@ -645,10 +657,27 @@ Changes in 1.6 (??.??.2009) - Add a hitPosition out parameter to ISceneCollisionManager::getCollisionResultPosition() - this is a (small) API breaking change. ------------------------------------- -Changes in version 1.5.1 (??.?? 2009) +Changes in version 1.5.2 (??.??.2009) + + - Fix terrain smoothing, bug found by loverlinfish + + - SOLARIS recognition removed. Please specify the platform define manually. This allows for compilation under sparc/Linux and sparc/Solaris + + - Some uninitialized variables fixed + + - FreeBSD joystick support added (for Debian package) - Fix cursor problems found by buffer and by rvl2 as described in http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=34823&highlight= + - OSX/XCode updates + + - MS3D loader bug fixed + + - Float parse bug fixed + +------------------------------------- +Changes in version 1.5.1 (05.08.2009) + - Make sure a missing font does not corrupt the skin. - Fix getAngle in vector2d as suggested by xray. This has only a minor impact on s32 vectors. diff --git a/examples/04.Movement/main.cpp b/examples/04.Movement/main.cpp index 78fb1f51..8584bb0b 100644 --- a/examples/04.Movement/main.cpp +++ b/examples/04.Movement/main.cpp @@ -176,7 +176,7 @@ int main() */ anms->setMaterialFlag(video::EMF_LIGHTING, false); - anms->setFrameLoop(0, 14); + anms->setFrameLoop(0, 13); anms->setAnimationSpeed(15); // anms->setMD2Animation(scene::EMAT_RUN); diff --git a/examples/09.Meshviewer/main.cpp b/examples/09.Meshviewer/main.cpp index f0edc768..efae647d 100644 --- a/examples/09.Meshviewer/main.cpp +++ b/examples/09.Meshviewer/main.cpp @@ -556,11 +556,9 @@ public: Most of the hard work is done. We only need to create the Irrlicht Engine device and all the buttons, menus and toolbars. We start up the engine as usual, using createDevice(). To make our application catch events, we set our -eventreceiver as parameter. The #ifdef WIN32 preprocessor commands are not -necessary, but I included them to make the tutorial use DirectX on Windows and -OpenGL on all other platforms like Linux. As you can see, there is also a -unusual call to IrrlichtDevice::setResizeAble(). This makes the render window -resizeable, which is quite useful for a mesh viewer. +eventreceiver as parameter. As you can see, there is also a call to +IrrlichtDevice::setResizeable(). This makes the render window resizeable, which +is quite useful for a mesh viewer. */ int main(int argc, char* argv[]) { diff --git a/examples/20.ManagedLights/ManagedLights.vcproj b/examples/20.ManagedLights/ManagedLights.vcproj index 794946fa..586c49e6 100644 --- a/examples/20.ManagedLights/ManagedLights.vcproj +++ b/examples/20.ManagedLights/ManagedLights.vcproj @@ -1,227 +1,160 @@ + SccProjectName="" + SccLocalPath=""> + Name="Win32"/> - - - - - - - + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> + CompileAs="0"/> - - + Name="VCCustomBuildTool"/> + TargetMachine="1"/> + Name="VCMIDLTool" + TypeLibraryName=".\Debug/ManagedLights.tlb" + HeaderFileName=""/> + Name="VCPostBuildEventTool"/> + Name="VCPreBuildEventTool"/> + Name="VCPreLinkEventTool"/> + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG" + Culture="3079"/> + Name="VCWebServiceProxyGeneratorTool"/> + Name="VCXMLDataGeneratorTool"/> + Name="VCWebDeploymentTool"/> + + - - - - - + ATLMinimizesCRunTimeLibraryUsage="FALSE" + CharacterSet="2"> + SuppressStartupBanner="TRUE" + CompileAs="0"/> - - + Name="VCCustomBuildTool"/> + TargetMachine="1"/> + Name="VCMIDLTool" + TypeLibraryName=".\Release/ManagedLights.tlb" + HeaderFileName=""/> + Name="VCPostBuildEventTool"/> + Name="VCPreBuildEventTool"/> + Name="VCPreLinkEventTool"/> + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG" + Culture="3079"/> + Name="VCWebServiceProxyGeneratorTool"/> + Name="VCXMLDataGeneratorTool"/> + Name="VCWebDeploymentTool"/> + + + RelativePath="main.cpp"> + Name="Debug|Win32"> + BasicRuntimeChecks="3"/> + Name="Release|Win32"> + PreprocessorDefinitions=""/> diff --git a/examples/20.ManagedLights/main.cpp b/examples/20.ManagedLights/main.cpp index 4a5757b4..7b2d696c 100644 --- a/examples/20.ManagedLights/main.cpp +++ b/examples/20.ManagedLights/main.cpp @@ -1,8 +1,10 @@ +/** Example 020 Managed Lights -// Written by Colin MacDonald -// Copyright (C) 2002-2009 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h +Written by Colin MacDonald. This tutorial explains the use of the Light Manager +of Irrlicht. It enables the use of more dynamic light sources than the actual +hardware supports. Further applications of the Light Manager, such as per scene +node callbacks, are left out for simplicity of the example. +*/ #include #include @@ -273,7 +275,7 @@ private: }; -/*! +/* */ int main(int argumentCount, char * argumentValues[]) { @@ -328,7 +330,9 @@ int main(int argumentCount, char * argumentValues[]) guienv->addStaticText(L"2 - Closest 3 lights", core::rect(10,30,200,50)); guienv->addStaticText(L"3 - Lights in zone", core::rect(10,50,200,70)); - // Add several "zones". You could use this technique to light individual rooms, for example. +/* +Add several "zones". You could use this technique to light individual rooms, for example. +*/ for(f32 zoneX = -100.f; zoneX <= 100.f; zoneX += 50.f) for(f32 zoneY = -60.f; zoneY <= 60.f; zoneY += 60.f) { @@ -403,3 +407,7 @@ int main(int argumentCount, char * argumentValues[]) device->drop(); return 0; } + +/* +**/ + diff --git a/examples/21.Quake3Explorer/Quake3Explorer_vc7.vcproj b/examples/21.Quake3Explorer/Quake3Explorer_vc7.vcproj index 12a7b656..eefd7bb9 100644 --- a/examples/21.Quake3Explorer/Quake3Explorer_vc7.vcproj +++ b/examples/21.Quake3Explorer/Quake3Explorer_vc7.vcproj @@ -126,6 +126,15 @@ + + + + + + diff --git a/examples/21.Quake3Explorer/main.cpp b/examples/21.Quake3Explorer/main.cpp index c7110a70..12f6e042 100644 --- a/examples/21.Quake3Explorer/main.cpp +++ b/examples/21.Quake3Explorer/main.cpp @@ -23,12 +23,17 @@ Copyright 2006-2009 Burningwater, Thomas Alten #include "sound.h" #include -/*! +/* Game Data is used to hold Data which is needed to drive the game */ struct GameData { - GameData ( const path &startupDir); + GameData ( const path &startupDir) : + retVal(0), createExDevice(0), Device(0), StartupDir(startupDir) + { + setDefault (); + } + void setDefault (); s32 save ( const path &filename ); s32 load ( const path &filename ); @@ -58,18 +63,7 @@ struct GameData IrrlichtDevice *Device; }; -/*! -*/ -GameData::GameData ( const path &startupDir) -{ - retVal = 0; - createExDevice = 0; - Device = 0; - StartupDir = startupDir; - setDefault (); -} - -/*! +/* set default settings */ void GameData::setDefault () @@ -92,7 +86,7 @@ void GameData::setDefault () deviceParam.WindowSize.Height = 600; deviceParam.Fullscreen = false; deviceParam.Bits = 32; - deviceParam.ZBufferBits = 32; + deviceParam.ZBufferBits = 16; deviceParam.Vsync = false; deviceParam.AntiAlias = false; @@ -112,19 +106,17 @@ void GameData::setDefault () CurrentMapName = ""; CurrentArchiveList.clear (); - //! Explorer Media directory + // Explorer Media directory CurrentArchiveList.push_back ( StartupDir + "../../media/" ); - //! Add the original quake3 files before you load your custom map - //! Most mods are using the original shaders, models&items&weapons - CurrentArchiveList.push_back ( "/q/baseq3/" ); - - - CurrentArchiveList.push_back ( StartupDir + "../../media/map-20kdm2.pk3" ); + // Add the original quake3 files before you load your custom map + // Most mods are using the original shaders, models&items&weapons + CurrentArchiveList.push_back("/q/baseq3/"); + CurrentArchiveList.push_back(StartupDir + "../../media/map-20kdm2.pk3"); } -/*! +/* Load the current game State from a typical quake3 cfg file */ s32 GameData::load ( const path &filename ) @@ -132,7 +124,7 @@ s32 GameData::load ( const path &filename ) if (!Device) return 0; - //! the quake3 mesh loader can also handle *.shader and *.cfg file + // the quake3 mesh loader can also handle *.shader and *.cfg file IQ3LevelMesh* mesh = (IQ3LevelMesh*) Device->getSceneManager()->getMesh ( filename ); if (!mesh) return 0; @@ -171,7 +163,7 @@ s32 GameData::load ( const path &filename ) return 1; } -/*! +/* Store the current game State in a quake3 configuration file */ s32 GameData::save ( const path &filename ) @@ -217,7 +209,7 @@ s32 GameData::save ( const path &filename ) return 1; } -/*! +/* Representing a player */ struct Q3Player : public IAnimationEndCallBack @@ -254,7 +246,7 @@ struct Q3Player : public IAnimationEndCallBack }; -/*! +/* End player */ void Q3Player::shutdown () { @@ -274,13 +266,15 @@ void Q3Player::shutdown () } -/*! +/* create a new player */ void Q3Player::create ( IrrlichtDevice *device, IQ3LevelMesh* mesh, ISceneNode *mapNode, IMetaTriangleSelector *meta ) { setTimeFire ( Anim + 0, 200, FIRED ); setTimeFire ( Anim + 1, 5000 ); + if (!device) + return; // load FPS weapon to Camera Device = device; Mesh = mesh; @@ -371,12 +365,14 @@ void Q3Player::create ( IrrlichtDevice *device, IQ3LevelMesh* mesh, ISceneNode * } -/*! +/* so we need a good starting Position in the level. we can ask the Quake3 Loader for all entities with class_name "info_player_deathmatch" */ void Q3Player::respawn () { + if (!Device) + return; ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera(); Device->getLogger()->log( "respawn" ); @@ -395,6 +391,8 @@ void Q3Player::respawn () */ void Q3Player::setpos ( const vector3df &pos, const vector3df &rotation ) { + if (!Device) + return; Device->getLogger()->log( "setpos" ); ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera(); @@ -407,7 +405,7 @@ void Q3Player::setpos ( const vector3df &pos, const vector3df &rotation ) } } -/*! +/* set the Animation of the player and weapon */ void Q3Player::setAnim ( const c8 *name ) { @@ -431,8 +429,7 @@ void Q3Player::setAnim ( const c8 *name ) } -/*! -*/ +// Callback void Q3Player::OnAnimationEnd(IAnimatedMeshSceneNode* node) { setAnim ( 0 ); @@ -440,7 +437,8 @@ void Q3Player::OnAnimationEnd(IAnimatedMeshSceneNode* node) -//! GUIElements +/* GUI Elements +*/ struct GUI { GUI () @@ -483,11 +481,10 @@ struct GUI IGUIStaticText* StatusLine; IGUIImage* Logo; IGUIWindow* Window; - }; -/*! +/* CQuake3EventHandler controls the game */ class CQuake3EventHandler : public IEventReceiver @@ -547,14 +544,14 @@ private: void dropMap (); }; -/*! +/* Constructor */ CQuake3EventHandler::CQuake3EventHandler( GameData *game ) : Game(game), Mesh(0), MapParent(0), ShaderParent(0), ItemParent(0), UnresolvedParent(0), BulletParent(0), FogParent(0), SkyNode(0), Meta(0) { buf[0]=0; - //! Also use 16 Bit Textures for 16 Bit RenderDevice + // Also use 16 Bit Textures for 16 Bit RenderDevice if ( Game->deviceParam.Bits == 16 ) { game->Device->getVideoDriver()->setTextureCreationFlag(ETCF_ALWAYS_16_BIT, true); @@ -572,6 +569,7 @@ CQuake3EventHandler::CQuake3EventHandler( GameData *game ) } +// destructor CQuake3EventHandler::~CQuake3EventHandler () { Player[0].shutdown (); @@ -583,7 +581,7 @@ CQuake3EventHandler::~CQuake3EventHandler () } -//! create runtime textures smog, fog +// create runtime textures smog, fog void CQuake3EventHandler::createTextures () { IVideoDriver * driver = Game->Device->getVideoDriver(); @@ -636,7 +634,7 @@ void CQuake3EventHandler::createTextures () } -/*! +/* create the GUI */ void CQuake3EventHandler::CreateGUI() @@ -829,8 +827,7 @@ void CQuake3EventHandler::CreateGUI() } - -/*! +/* Add an Archive to the FileSystems und updates the GUI */ void CQuake3EventHandler::AddArchive ( const path& archiveName ) @@ -916,7 +913,7 @@ void CQuake3EventHandler::AddArchive ( const path& archiveName ) u32 g = 0; core::stringw s; - //! browse the attached file system + // browse the attached file system fs->setFileListSystem ( FILESYSTEM_VIRTUAL ); fs->changeWorkingDirectoryTo ( "/maps/" ); IFileList *fileList = fs->createFileList (); @@ -994,7 +991,7 @@ void CQuake3EventHandler::AddArchive ( const path& archiveName ) } -/*! +/* clears the Map in Memory */ void CQuake3EventHandler::dropMap () @@ -1031,7 +1028,7 @@ void CQuake3EventHandler::dropMap () Mesh = 0; } -/*! +/* Load new map */ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision ) { @@ -1128,9 +1125,6 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision ) } /* -**/ - -/*! Adds a SceneNode with an icon to the Scene Tree */ void CQuake3EventHandler::addSceneTreeItem( ISceneNode * parent, IGUITreeViewNode* nodeParent) @@ -1203,13 +1197,13 @@ void CQuake3EventHandler::addSceneTreeItem( ISceneNode * parent, IGUITreeViewNod } -//! Adds life! +// Adds life! void CQuake3EventHandler::CreatePlayers() { Player[0].create ( Game->Device, Mesh, MapParent, Meta ); } -//! Adds a skydome to the scene +// Adds a skydome to the scene void CQuake3EventHandler::AddSky( u32 dome, const c8 *texture) { ISceneManager *smgr = Game->Device->getSceneManager (); @@ -1229,10 +1223,13 @@ void CQuake3EventHandler::AddSky( u32 dome, const c8 *texture) snprintf ( buf, 64, "%s_%s.jpg", texture, p[i] ); SkyNode = smgr->addSkyBoxSceneNode( driver->getTexture ( buf ), 0, 0, 0, 0, 0 ); - for ( i = 0; i < 6; ++i ) + if (SkyNode) { - snprintf ( buf, 64, "%s_%s.jpg", texture, p[i] ); - SkyNode->getMaterial(i).setTexture ( 0, driver->getTexture ( buf ) ); + for ( i = 0; i < 6; ++i ) + { + snprintf ( buf, 64, "%s_%s.jpg", texture, p[i] ); + SkyNode->getMaterial(i).setTexture ( 0, driver->getTexture ( buf ) ); + } } } else @@ -1264,7 +1261,8 @@ void CQuake3EventHandler::AddSky( u32 dome, const c8 *texture) ); } - SkyNode->setName ( "Skydome" ); + if (SkyNode) + SkyNode->setName("Skydome"); //SkyNode->getMaterial(0).ZBuffer = video::EMDF_DEPTH_LESS_EQUAL; driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); @@ -1272,8 +1270,7 @@ void CQuake3EventHandler::AddSky( u32 dome, const c8 *texture) } -/*! -*/ +// enable GUI elements void CQuake3EventHandler::SetGUIActive( s32 command) { bool inputState = false; @@ -1315,7 +1312,7 @@ void CQuake3EventHandler::SetGUIActive( s32 command) -/*! +/* Handle game input */ bool CQuake3EventHandler::OnEvent(const SEvent& eve) @@ -1525,7 +1522,7 @@ bool CQuake3EventHandler::OnEvent(const SEvent& eve) else if (eve.KeyInput.Key == KEY_F11) { - //! screenshot are taken without gamma! + // screenshot are taken without gamma! IImage* image = Game->Device->getVideoDriver()->createScreenShot(); if (image) { @@ -1824,8 +1821,7 @@ void CQuake3EventHandler::useItem( Q3Player * player) // play sound } -/*! -*/ +// rendered when bullets hit something void CQuake3EventHandler::createParticleImpacts( u32 now ) { ISceneManager* sm = Game->Device->getSceneManager(); @@ -1969,7 +1965,7 @@ void CQuake3EventHandler::Animate() IAttributes * attr = smgr->getParameters(); swprintf ( msg, 128, - L"Q3 %s [%s], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)", + L"Q3 %s [%ls], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)", Game->CurrentMapName.c_str(), driver->getName(), driver->getFPS (), @@ -2006,7 +2002,7 @@ void CQuake3EventHandler::Animate() } -/*! +/* The main game states */ void runGame ( GameData *game ) { @@ -2024,10 +2020,10 @@ void runGame ( GameData *game ) // create an event receiver based on current game data CQuake3EventHandler *eventHandler = new CQuake3EventHandler( game ); - //! load stored config + // load stored config game->load ( "explorer.cfg" ); - //! add our media directory and archive to the file system + // add our media directory and archive to the file system for ( u32 i = 0; i < game->CurrentArchiveList.size(); ++i ) { eventHandler->AddArchive ( game->CurrentArchiveList[i] ); @@ -2078,7 +2074,7 @@ void runGame ( GameData *game ) #endif -/*! +/* The main routine, doing all setup */ int IRRCALLCONV main(int argc, char* argv[]) { @@ -2130,4 +2126,3 @@ int IRRCALLCONV main(int argc, char* argv[]) /* **/ - diff --git a/examples/BuildAllExamples_v7.sln b/examples/BuildAllExamples_v7.sln index 8cacce69..839aaa70 100644 --- a/examples/BuildAllExamples_v7.sln +++ b/examples/BuildAllExamples_v7.sln @@ -78,15 +78,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "19.MouseAndJoystick", "19.M ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "20.ManagedLights", "20.ManagedLights\ManagedLights_vc7.vcproj", "{16007FE2-142B-47F8-93E1-519BA3F39E71}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "21.Quake3Explorer", "21.Quake3Explorer\Quake3Explorer_vc7.vcproj", "{CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}" ProjectSection(ProjectDependencies) = postProject {E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "20.ManagedLights", "20.ManagedLights\ManagedLights.vcproj", "{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug @@ -167,14 +167,14 @@ Global {EB3B38EA-5CE7-4983-845B-880661E69D09}.Release.Build.0 = Release|Win32 {1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}.Debug.ActiveCfg = Debug|Win32 {1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}.Release.ActiveCfg = Release|Win32 - {16007FE2-142B-47F8-93E1-519BA3F39E71}.Debug.ActiveCfg = Debug|Win32 - {16007FE2-142B-47F8-93E1-519BA3F39E71}.Debug.Build.0 = Debug|Win32 - {16007FE2-142B-47F8-93E1-519BA3F39E71}.Release.ActiveCfg = Release|Win32 - {16007FE2-142B-47F8-93E1-519BA3F39E71}.Release.Build.0 = Release|Win32 {CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}.Debug.ActiveCfg = Debug|Win32 {CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}.Debug.Build.0 = Debug|Win32 {CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}.Release.ActiveCfg = Release|Win32 {CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}.Release.Build.0 = Release|Win32 + {1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}.Debug.ActiveCfg = Debug|Win32 + {1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}.Debug.Build.0 = Debug|Win32 + {1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}.Release.ActiveCfg = Release|Win32 + {1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff --git a/examples/BuildAllExamples_v9.sln b/examples/BuildAllExamples_v9.sln index 472dbece..5d966b40 100644 --- a/examples/BuildAllExamples_v9.sln +++ b/examples/BuildAllExamples_v9.sln @@ -181,8 +181,11 @@ Global {FE853A36-E0D1-4AC5-A792-B643E70D2953}.Debug|Win32.ActiveCfg = Debug|Win32 {FE853A36-E0D1-4AC5-A792-B643E70D2953}.Debug|Win32.Build.0 = Debug|Win32 {FE853A36-E0D1-4AC5-A792-B643E70D2953}.Release|Win32.ActiveCfg = Release|Win32 + {FE853A36-E0D1-4AC5-A792-B643E70D2953}.Release|Win32.Build.0 = Release|Win32 {16007FE2-142B-47F8-93E1-519BA3F39E71}.Debug|Win32.ActiveCfg = Debug|Win32 + {16007FE2-142B-47F8-93E1-519BA3F39E71}.Debug|Win32.Build.0 = Debug|Win32 {16007FE2-142B-47F8-93E1-519BA3F39E71}.Release|Win32.ActiveCfg = Release|Win32 + {16007FE2-142B-47F8-93E1-519BA3F39E71}.Release|Win32.Build.0 = Release|Win32 {CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}.Debug|Win32.ActiveCfg = Debug|Win32 {CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}.Debug|Win32.Build.0 = Debug|Win32 {CDC4AAA9-72E1-4FFA-A04D-7EF59D8B97CD}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/include/IAnimatedMeshSceneNode.h b/include/IAnimatedMeshSceneNode.h index a1e024ad..d942e035 100644 --- a/include/IAnimatedMeshSceneNode.h +++ b/include/IAnimatedMeshSceneNode.h @@ -81,10 +81,14 @@ namespace scene \return True if successful, false if not. */ virtual bool setFrameLoop(s32 begin, s32 end) = 0; - //! Sets the speed with witch the animation is played. + //! Sets the speed with which the animation is played. /** \param framesPerSecond: Frames per second played. */ virtual void setAnimationSpeed(f32 framesPerSecond) = 0; + //! Gets the speed with which the animation is played. + /** \return Frames per second played. */ + virtual f32 getAnimationSpeed() const =0; + //! Creates shadow volume scene node as child of this node. /** The shadow can be rendered using the ZPass or the zfail method. ZPass is a little bit faster because the shadow volume diff --git a/include/IEventReceiver.h b/include/IEventReceiver.h index 89dd0206..7c9e139f 100644 --- a/include/IEventReceiver.h +++ b/include/IEventReceiver.h @@ -313,7 +313,7 @@ struct SEvent * each connected joystick once per run() of the device. Joystick events will * not be generated by default. If joystick support is available for the * active device, _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ is defined, and - * @ref IrrlichtDevice::activateJoysticks() has been called, an event of + * @ref irr::IrrlichtDevice::activateJoysticks() has been called, an event of * this type will be generated once per joystick per @ref IrrlichtDevice::run() * regardless of whether the state of the joystick has actually changed. */ struct SJoystickEvent @@ -420,7 +420,7 @@ public: }; -//! Information on a joystick, returned from @ref IrrlichtDevice::activateJoysticks() +//! Information on a joystick, returned from @ref irr::IrrlichtDevice::activateJoysticks() struct SJoystickInfo { //! The ID of the joystick diff --git a/include/IFileArchive.h b/include/IFileArchive.h index be5f45b3..7f0f4b2c 100644 --- a/include/IFileArchive.h +++ b/include/IFileArchive.h @@ -55,7 +55,7 @@ public: or 0 on failure. */ virtual IReadFile* createAndOpenFile(const path& filename) =0; - //! Opens a file based on its position. + //! Opens a file based on its position in the file list. /** Creates and returns \param index The zero based index of the file. \return Returns a pointer to the created file on success, or 0 on failure. */ @@ -80,7 +80,7 @@ class IArchiveLoader : public virtual IReferenceCounted public: //! Check if the file might be loaded by this class /** Check based on the file extension (e.g. ".zip") - \param fileName Name of file to check. + \param filename Name of file to check. \return True if file seems to be loadable. */ virtual bool isALoadableFileFormat(const path& filename) const =0; @@ -97,12 +97,16 @@ public: virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const =0; //! Creates an archive from the filename - /** \param file File handle to check. + /** \param filename File to use. + \param ignoreCase Searching is performed without regarding the case + \param ignorePaths Files are searched for without checking for the directories \return Pointer to newly created archive, or 0 upon error. */ virtual IFileArchive* createArchive(const path& filename, bool ignoreCase, bool ignorePaths) const =0; //! Creates an archive from the file - /** \param file File handle to check. + /** \param file File handle to use. + \param ignoreCase Searching is performed without regarding the case + \param ignorePaths Files are searched for without checking for the directories \return Pointer to newly created archive, or 0 upon error. */ virtual IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const =0; }; diff --git a/include/IFileList.h b/include/IFileList.h index c6a1bf8c..376d2e62 100644 --- a/include/IFileList.h +++ b/include/IFileList.h @@ -33,7 +33,7 @@ public: //! Gets the full name of a file in the list including the path, based on an index. /** \param index is the zero based index of the file which name should be returned. The index must be less than the amount getFileCount() returns. - \return File name of the file. Returns 0, if an error occured. */ + \return File name of the file. Returns 0 if an error occured. */ virtual const io::path& getFullFileName(u32 index) const = 0; //! Returns the size of a file in the file list, based on an index. @@ -42,6 +42,15 @@ public: \return The size of the file in bytes. */ virtual u32 getFileSize(u32 index) const = 0; + //! Returns the ID of a file in the file list, based on an index. + /** This optional ID can be used to link the file list entry to information held + elsewhere. For example this could be an index in an IFileArchive, linking the entry + to its data offset, uncompressed size and CRC. + \param index is the zero based index of the file which should be returned. + The index must be less than the amount getFileCount() returns. + \return The ID of the file. */ + virtual u32 getID(u32 index) const = 0; + //! Check if the file is a directory /** \param index The zero based index which will be checked. The index must be less than the amount getFileCount() returns. @@ -58,6 +67,16 @@ public: //! Returns the base path of the file list virtual const io::path& getPath() const = 0; + + //! Add as a file or folder to the list + /** \param fullPath The file name including path, from the root of the file list. + \param isDirectory True if this is a directory rather than a file. + \param size The size of the file in bytes. + \param id The ID of the file in the archive which owns it */ + virtual u32 addItem(const io::path& fullPath, u32 size, bool isDirectory, u32 id=0) = 0; + + //! Sorts the file list. You should call this after adding any items to the file list + virtual void sort() = 0; }; } // end namespace irr diff --git a/include/IFileSystem.h b/include/IFileSystem.h index 36a2ba47..8af22568 100644 --- a/include/IFileSystem.h +++ b/include/IFileSystem.h @@ -125,9 +125,10 @@ public: virtual bool removeFileArchive(u32 index) =0; //! Removes an archive from the file system. - /** This will close the archive and free any file handles, but will not close resources which have already - been loaded and are now cached, for example textures and meshes. - \param index: The index of the archive to remove + /** This will close the archive and free any file handles, but will not + close resources which have already been loaded and are now cached, for + example textures and meshes. + \param filename The archive of the given name will be removed \return Returns true on success, false on failure */ virtual bool removeFileArchive(const path& filename) =0; @@ -226,6 +227,12 @@ public: See IReferenceCounted::drop() for more information. */ virtual IFileList* createFileList() =0; + //! Creates an empty filelist + /** \return a Pointer to the created IFileList is returned. After the list has been used + it has to be deleted using its IFileList::drop() method. + See IReferenceCounted::drop() for more information. */ + virtual IFileList* createEmptyFileList(const io::path& path, bool ignoreCase, bool ignorePaths) =0; + //! Set the active type of file system. virtual EFileSystemType setFileListSystem(EFileSystemType listType) =0; diff --git a/include/IGUIContextMenu.h b/include/IGUIContextMenu.h index 5d8cb3c2..4dbc3dca 100644 --- a/include/IGUIContextMenu.h +++ b/include/IGUIContextMenu.h @@ -11,6 +11,21 @@ namespace irr { namespace gui { + //! Close behaviour. + //! Default is ECMC_REMOVE + enum ECONTEXT_MENU_CLOSE + { + //! do nothing - menu stays open + ECMC_IGNORE = 0, + + //! remove the gui element + ECMC_REMOVE = 1, + + //! call setVisible(false) + ECMC_HIDE = 2, + + // note to implementors - this is planned as bitset, so continue with 4 if you need to add further flags. + }; //! GUI Context menu interface. class IGUIContextMenu : public IGUIElement @@ -21,6 +36,12 @@ namespace gui IGUIContextMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) : IGUIElement(EGUIET_CONTEXT_MENU, environment, parent, id, rectangle) {} + //! set behaviour when menus are closed + virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose) = 0; + + //! get current behaviour when the menue will be closed + virtual ECONTEXT_MENU_CLOSE getCloseHandling() const = 0; + //! Get amount of menu items virtual u32 getItemCount() const = 0; @@ -36,7 +57,30 @@ namespace gui \param checked: Specifies if the menu item should be initially checked. \return Returns the index of the new item */ virtual u32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true, - bool hasSubMenu=false, bool checked=false) = 0; + bool hasSubMenu=false, bool checked=false, bool autoChecking=false) = 0; + + //! Insert a menu item at specified position. + /** \param idx: Position to insert the new element, + should be smaller than itemcount otherwise the item is added to the end. + \param text: Text of menu item. Set this to 0 to create + an separator instead of a real item, which is the same like + calling addSeparator(); + \param commandId: Command id of menu item, a simple id you may + set to whatever you want. + \param enabled: Specifies if the menu item should be enabled. + \param hasSubMenu: Set this to true if there should be a submenu + at this item. You can acess this submenu via getSubMenu(). + \param checked: Specifies if the menu item should be initially checked. + \return Returns the index of the new item */ + virtual u32 insertItem(u32 idx, const wchar_t* text, s32 commandId=-1, bool enabled=true, + bool hasSubMenu=false, bool checked=false, bool autoChecking=false) = 0; + + //! Find an item by it's CommandID + /** + \param commandId: We are looking for the first item which has this commandID + \param idxStartSearch: Start searching from this index. + \return Returns the index of the item when found or otherwise -1. */ + virtual s32 findItemWithCommandId(s32 commandId, u32 idxStartSearch=0) const = 0; //! Adds a separator item to the menu virtual void addSeparator() = 0; @@ -94,6 +138,15 @@ namespace gui \param idx: Zero based index of the menu item \return Returns a pointer to the submenu of an item. */ virtual IGUIContextMenu* getSubMenu(u32 idx) const = 0; + + //! should the element change the checked status on clicking + virtual void setItemAutoChecking(u32 idx, bool autoChecking) = 0; + + //! does the element change the checked status on clicking + virtual bool getItemAutoChecking(u32 idx) const = 0; + + //! When an eventparent is set it receives events instead of the usual parent element + virtual void setEventParent(IGUIElement *parent) = 0; }; } // end namespace gui diff --git a/include/IGUIElement.h b/include/IGUIElement.h index 818e3afb..b560fdc2 100644 --- a/include/IGUIElement.h +++ b/include/IGUIElement.h @@ -252,7 +252,7 @@ public: DesiredRect.UpperLeftCorner.X += diffx/2; break; case EGUIA_SCALE: - DesiredRect.UpperLeftCorner.X = (s32)(ScaleRect.UpperLeftCorner.X * fw); + DesiredRect.UpperLeftCorner.X = core::round32(ScaleRect.UpperLeftCorner.X * fw); break; } @@ -267,7 +267,7 @@ public: DesiredRect.LowerRightCorner.X += diffx/2; break; case EGUIA_SCALE: - DesiredRect.LowerRightCorner.X = (s32)(ScaleRect.LowerRightCorner.X * fw); + DesiredRect.LowerRightCorner.X = core::round32(ScaleRect.LowerRightCorner.X * fw); break; } @@ -282,7 +282,7 @@ public: DesiredRect.UpperLeftCorner.Y += diffy/2; break; case EGUIA_SCALE: - DesiredRect.UpperLeftCorner.Y = (s32)(ScaleRect.UpperLeftCorner.Y * fh); + DesiredRect.UpperLeftCorner.Y = core::round32(ScaleRect.UpperLeftCorner.Y * fh); break; } @@ -297,7 +297,7 @@ public: DesiredRect.LowerRightCorner.Y += diffy/2; break; case EGUIA_SCALE: - DesiredRect.LowerRightCorner.Y = (s32)(ScaleRect.LowerRightCorner.Y * fh); + DesiredRect.LowerRightCorner.Y = core::round32(ScaleRect.LowerRightCorner.Y * fh); break; } diff --git a/include/IGUIEnvironment.h b/include/IGUIEnvironment.h index 50acb29a..80838913 100644 --- a/include/IGUIEnvironment.h +++ b/include/IGUIEnvironment.h @@ -149,8 +149,9 @@ public: //! Creates the image list from the given texture. - /** Loads the font if it was not loaded before. - \param filename Filename of the Font. + /** \param texture Texture to split into images + \param imageSize Dimension of each image + \param useAlphaChannel Flag whether alpha channel of the texture should be honored. \return Pointer to the font. Returns 0 if the font could not be loaded. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ @@ -240,11 +241,12 @@ public: to (EMBF_OK | EMBF_CANCEL). \param parent Parent gui element of the message box. \param id Id with which the gui element can be identified. + \param image Optional texture which will be displayed beside the text as an image \return Pointer to the created message box. Returns 0 if an error occured. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, - bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1) = 0; + bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1, video::ITexture* image=0) = 0; //! Adds a scrollbar. /** \param horizontal Specifies if the scroll bar is drawn horizontal @@ -313,6 +315,8 @@ public: \param parent Parent gui element of the list box. \param id Id to identify the gui element. \param drawBackground Flag whether the background should be drawn. + \param scrollBarVertical Flag whether a vertical scrollbar should be used + \param scrollBarHorizontal Flag whether a horizontal scrollbar should be used \return Pointer to the created list box. Returns 0 if an error occured. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ @@ -395,6 +399,7 @@ public: /** An edit box with up and down buttons \param text Text to be displayed. Can be altered after creation by setText(). \param rectangle Rectangle specifying the borders of the spin box. + \param border Set to true if the spin box should have a 3d border. \param parent Parent item of the element, e.g. a window. Set it to 0 to place the spin box directly in the environment. \param id The ID of the element. diff --git a/include/IGUIFont.h b/include/IGUIFont.h index 35c94ab3..e601bcd5 100644 --- a/include/IGUIFont.h +++ b/include/IGUIFont.h @@ -92,7 +92,7 @@ public: //! Define which characters should not be drawn by the font. /** For example " " would not draw any space which is usually blank in most fonts. - \param invisible: string of symbols, which are not send down to the videodriver + \param s String of symbols which are not send down to the videodriver */ virtual void setInvisibleCharacters( const wchar_t *s ) = 0; }; diff --git a/include/IGUISkin.h b/include/IGUISkin.h index d0ce8658..83c4baeb 100644 --- a/include/IGUISkin.h +++ b/include/IGUISkin.h @@ -139,9 +139,9 @@ namespace gui EGDS_WINDOW_BUTTON_WIDTH, //! width of a checkbox check EGDS_CHECK_BOX_WIDTH, - //! width of a messagebox + //! deprecated EGDS_MESSAGE_BOX_WIDTH, - //! height of a messagebox + //! deprecated EGDS_MESSAGE_BOX_HEIGHT, //! width of a default button EGDS_BUTTON_WIDTH, @@ -155,6 +155,17 @@ namespace gui EGDS_TITLEBARTEXT_DISTANCE_X, //! distance for text in the title bar, from the top of the window rect EGDS_TITLEBARTEXT_DISTANCE_Y, + //! free space in a messagebox between borders and contents on all sides + EGDS_MESSAGE_BOX_GAP_SPACE, + //! minimal space to reserve for messagebox text-width + EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH, + //! maximal space to reserve for messagebox text-width + EGDS_MESSAGE_BOX_MAX_TEST_WIDTH, + //! minimal space to reserve for messagebox text-height + EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT, + //! maximal space to reserve for messagebox text-height + EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT, + //! this value is not used, it only specifies the amount of default sizes //! available. EGDS_COUNT @@ -174,7 +185,14 @@ namespace gui "ButtonHeight", "TextDistanceX", "TextDistanceY", - 0, + "TitleBarTextX", + "TitleBarTextY", + "MessageBoxGapSpace", + "MessageBoxMinTextWidth", + "MessageBoxMaxTextWidth", + "MessageBoxMinTextHeight", + "MessageBoxMaxTextHeight", + 0 }; @@ -212,7 +230,7 @@ namespace gui "WindowButtonMaximize", "WindowButtonMinimize", "WindowButtonRestore", - 0, + 0 }; //! Customizable symbols for GUI diff --git a/include/IGUITreeView.h b/include/IGUITreeView.h index 2d2cace2..bd8554d3 100644 --- a/include/IGUITreeView.h +++ b/include/IGUITreeView.h @@ -30,7 +30,7 @@ namespace gui virtual IGUITreeView* getOwner() const = 0; //! Returns the parent node of this node. - //! For the root node this will return 0. + /** For the root node this will return 0. */ virtual IGUITreeViewNode* getParent() const = 0; //! returns the text of the node @@ -79,118 +79,114 @@ namespace gui virtual bool hasChilds() const = 0; //! Adds a new node behind the last child node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node + /** \param text text of the new node + \param icon icon text of the new node + \param imageIndex index of the image for the new node (-1 = none) + \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) + \param data user data (void*) of the new node + \param data2 user data2 (IReferenceCounted*) of the new node + \return The new node + */ virtual IGUITreeViewNode* addChildBack( - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ) = 0; + const wchar_t* text, + const wchar_t* icon = 0, + s32 imageIndex = -1, + s32 selectedImageIndex = -1, + void* data = 0, + IReferenceCounted* data2 = 0 ) = 0; //! Adds a new node before the first child node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node + /** \param text text of the new node + \param icon icon text of the new node + \param imageIndex index of the image for the new node (-1 = none) + \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) + \param data user data (void*) of the new node + \param data2 user data2 (IReferenceCounted*) of the new node + \return The new node + */ virtual IGUITreeViewNode* addChildFront( - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ) = 0; + const wchar_t* text, + const wchar_t* icon = 0, + s32 imageIndex = -1, + s32 selectedImageIndex = -1, + void* data = 0, + IReferenceCounted* data2 = 0 ) = 0; //! Adds a new node behind the other node. - //! The other node has also te be a child node from this node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node or 0 if other is no child node from this + /** The other node has also te be a child node from this node. + \param other Node to insert after + \param text text of the new node + \param icon icon text of the new node + \param imageIndex index of the image for the new node (-1 = none) + \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) + \param data user data (void*) of the new node + \param data2 user data2 (IReferenceCounted*) of the new node + \return The new node or 0 if other is no child node from this + */ virtual IGUITreeViewNode* insertChildAfter( - IGUITreeViewNode* other, - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ) = 0; + IGUITreeViewNode* other, + const wchar_t* text, + const wchar_t* icon = 0, + s32 imageIndex = -1, + s32 selectedImageIndex = -1, + void* data = 0, + IReferenceCounted* data2 = 0 ) = 0; //! Adds a new node before the other node. - //! The other node has also te be a child node from this node. - //! \param text text of the new node - //! \param icon icon text of the new node - //! \param imageIndex index of the image for the new node (-1 = none) - //! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) - //! \param data user data (void*) of the new node - //! \param data2 user data2 (IReferenceCounted*) of the new node - //! \return - //! returns the new node or 0 if other is no child node from this + /** The other node has also te be a child node from this node. + \param other Node to insert before + \param text text of the new node + \param icon icon text of the new node + \param imageIndex index of the image for the new node (-1 = none) + \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex) + \param data user data (void*) of the new node + \param data2 user data2 (IReferenceCounted*) of the new node + \return The new node or 0 if other is no child node from this + */ virtual IGUITreeViewNode* insertChildBefore( - IGUITreeViewNode* other, - const wchar_t* text, - const wchar_t* icon = 0, - s32 imageIndex = -1, - s32 selectedImageIndex = -1, - void* data = 0, - IReferenceCounted* data2 = 0 ) = 0; + IGUITreeViewNode* other, + const wchar_t* text, + const wchar_t* icon = 0, + s32 imageIndex = -1, + s32 selectedImageIndex = -1, + void* data = 0, + IReferenceCounted* data2 = 0 ) = 0; //! Return the first child node from this node. - //! \return - //! Returns the first child node or 0 if this node has no childs. + /** \return The first child node or 0 if this node has no childs. */ virtual IGUITreeViewNode* getFirstChild() const = 0; //! Return the last child node from this node. - //! \return - //! Returns the last child node or 0 if this node has no childs. + /** \return The last child node or 0 if this node has no childs. */ virtual IGUITreeViewNode* getLastChild() const = 0; - //! Returns the preverse sibling node from this node. - //! \return - //! Returns the preverse sibling node from this node or 0 if this is - //! the first node from the parent node. + //! Returns the previous sibling node from this node. + /** \return The previous sibling node from this node or 0 if this is + the first node from the parent node. + */ virtual IGUITreeViewNode* getPrevSibling() const = 0; //! Returns the next sibling node from this node. - //! \return - //! Returns the next sibling node from this node or 0 if this is - //! the last node from the parent node. + /** \return The next sibling node from this node or 0 if this is + the last node from the parent node. + */ virtual IGUITreeViewNode* getNextSibling() const = 0; //! Returns the next visible (expanded, may be out of scrolling) node from this node. - //! \return - //! Returns the next visible node from this node or 0 if this is - //! the last visible node. + /** \return The next visible node from this node or 0 if this is + the last visible node. */ virtual IGUITreeViewNode* getNextVisible() const = 0; //! Deletes a child node. - // \return - //! Returns true if the node was found as a child and is deleted. + /** \return Returns true if the node was found as a child and is deleted. */ virtual bool deleteChild( IGUITreeViewNode* child ) = 0; //! Moves a child node one position up. - //! \return - //! Returns true if the node was found as achild node and was not already the first child. + /** \return True if the node was found as achild node and was not already the first child. */ virtual bool moveChildUp( IGUITreeViewNode* child ) = 0; //! Moves a child node one position down. - //! \return - //! Returns true if the node was found as achild node and was not already the last child. + /** \return True if the node was found as achild node and was not already the last child. */ virtual bool moveChildDown( IGUITreeViewNode* child ) = 0; //! Returns true if the node is expanded (childs are visible). @@ -209,7 +205,7 @@ namespace gui virtual bool isRoot() const = 0; //! Returns the level of this node. - //! The root node has level 0. Direct childs of the root has level 1 ... + /** The root node has level 0. Direct childs of the root has level 1 ... */ virtual s32 getLevel() const = 0; //! Returns true if this node is visible (all parents are expanded). @@ -218,9 +214,10 @@ namespace gui //! Default tree view GUI element. - //! Displays a windows like tree buttons to expand/collaps the child nodes of an node - //! and optional tree lines. - //! Each node consits of an text, an icon text and a void pointer for user data. + /** Displays a windows like tree buttons to expand/collaps the child nodes of an node + and optional tree lines. + Each node consits of an text, an icon text and a void pointer for user data. + */ class IGUITreeView : public IGUIElement { public: @@ -242,17 +239,20 @@ namespace gui virtual bool getLinesVisible() const = 0; //! sets if the tree lines are visible - //! \param visible true for visible, false for invisible + /** \param visible true for visible, false for invisible */ virtual void setLinesVisible( bool visible ) = 0; - //! Sets the font which should be used as icon font. This font is set to the Irrlicht engine - //! built-in-font by default. Icons can be displayed in front of every list item. - //! An icon is a string, displayed with the icon font. When using the build-in-font of the - //! Irrlicht engine as icon font, the icon strings defined in GUIIcons.h can be used. + //! Sets the font which should be used as icon font. + /** This font is set to the Irrlicht engine built-in-font by + default. Icons can be displayed in front of every list item. + An icon is a string, displayed with the icon font. When using + the build-in-font of the Irrlicht engine as icon font, the icon + strings defined in GUIIcons.h can be used. + */ virtual void setIconFont( IGUIFont* font ) = 0; //! Sets the image list which should be used for the image and selected image of every node. - //! The default is 0 (no images). + /** The default is 0 (no images). */ virtual void setImageList( IGUIImageList* imageList ) = 0; //! Returns the image list which is used for the nodes. @@ -265,7 +265,7 @@ namespace gui virtual bool getImageLeftOfIcon() const = 0; //! Returns the node which is associated to the last event. - //! This pointer is only valid inside the OnEvent call! + /** This pointer is only valid inside the OnEvent call! */ virtual IGUITreeViewNode* getLastEventNode() const = 0; }; diff --git a/include/IImageLoader.h b/include/IImageLoader.h index 09258b3f..a9163582 100644 --- a/include/IImageLoader.h +++ b/include/IImageLoader.h @@ -29,7 +29,7 @@ public: //! Check if the file might be loaded by this class /** Check is based on the file extension (e.g. ".tga") - \param fileName Name of file to check. + \param filename Name of file to check. \return True if file seems to be loadable. */ virtual bool isALoadableFileExtension(const io::path& filename) const = 0; diff --git a/include/IImageWriter.h b/include/IImageWriter.h index 1c49f3c8..bbdaafd3 100644 --- a/include/IImageWriter.h +++ b/include/IImageWriter.h @@ -26,7 +26,7 @@ class IImageWriter : public IReferenceCounted { public: //! Check if this writer can write a file with the given extension - /** \param fileName Name of the file to check. + /** \param filename Name of the file to check. \return True if file extension specifies a writable type. */ virtual bool isAWriteableFileExtension(const io::path& filename) const = 0; diff --git a/include/ILightManager.h b/include/ILightManager.h index 274c698b..cb31e6f5 100644 --- a/include/ILightManager.h +++ b/include/ILightManager.h @@ -1,5 +1,5 @@ // Written by Colin MacDonald - all rights assigned to Nikolaus Gebhardt -// Copyright (C) 2008 Nikolaus Gebhardt +// Copyright (C) 2008-2009 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h @@ -15,43 +15,45 @@ namespace scene { class ILightSceneNode; - //! ILightManager provides an interface for user applications to manipulate the list - //! of lights in the scene. The light list can be trimmed or re-ordered before device/ - //! hardware lights are created, and/or individual lights can be switched on and off - //! before or after each scene node is rendered. - //! It is assumed that the ILightManager implementation will store any data that it wishes - //! to retain, i.e. the ISceneManager to which it is assigned, the lightList, the current - //! render pass, and the current scene node. + //! ILightManager provides an interface for user applications to manipulate the list of lights in the scene. + /** The light list can be trimmed or re-ordered before device/ hardware + lights are created, and/or individual lights can be switched on and off + before or after each scene node is rendered. It is assumed that the + ILightManager implementation will store any data that it wishes to + retain, i.e. the ISceneManager to which it is assigned, the lightList, + the current render pass, and the current scene node. */ class ILightManager : public IReferenceCounted { public: //! Called after the scene's light list has been built, but before rendering has begun. - //! As actual device/hardware lights are not created until the ESNRP_LIGHT render pass, - //! this provides an opportunity for the light manager to trim or re-order the light - //! list, before any device/hardware lights have actually been created. - //! \param[in] smgr: the Scene Manager - //! \param[inout] lightLight: the Scene Manager's light list, which the light manager may - //! modify. This reference will remain valid until OnPostRender(). + /** As actual device/hardware lights are not created until the + ESNRP_LIGHT render pass, this provides an opportunity for the + light manager to trim or re-order the light list, before any + device/hardware lights have actually been created. + \param lightList: the Scene Manager's light list, which + the light manager may modify. This reference will remain valid + until OnPostRender(). + */ virtual void OnPreRender(core::array & lightList) = 0; //! Called after the last scene node is rendered. - //! After this call returns, the lightList passed to OnPreRender() becomes invalid. + /** After this call returns, the lightList passed to OnPreRender() becomes invalid. */ virtual void OnPostRender(void) = 0; //! Called before a render pass begins - //! \param[in] renderPass: the render pass that's about to begin + /** \param renderPass: the render pass that's about to begin */ virtual void OnRenderPassPreRender(E_SCENE_NODE_RENDER_PASS renderPass) = 0; //! Called after the render pass specified in OnRenderPassPreRender() ends - //! \param[in] renderPass: the render pass that has finished + /** \param[in] renderPass: the render pass that has finished */ virtual void OnRenderPassPostRender(E_SCENE_NODE_RENDER_PASS renderPass) = 0; //! Called before the given scene node is rendered - //! \param[in] node: the scene node that's about to be rendered + /** \param[in] node: the scene node that's about to be rendered */ virtual void OnNodePreRender(ISceneNode* node) = 0; //! Called after the the node specified in OnNodePreRender() has been rendered - //! \param[in] node: the scene node that has just been rendered + /** \param[in] node: the scene node that has just been rendered */ virtual void OnNodePostRender(ISceneNode* node) = 0; }; } // end namespace scene diff --git a/include/IMeshLoader.h b/include/IMeshLoader.h index 323c2740..34964578 100644 --- a/include/IMeshLoader.h +++ b/include/IMeshLoader.h @@ -33,7 +33,7 @@ public: //! Returns true if the file might be loaded by this class. /** This decision should be based on the file extension (e.g. ".cob") only. - \param fileName Name of the file to test. + \param filename Name of the file to test. \return True if the file might be loaded by this class. */ virtual bool isALoadableFileExtension(const io::path& filename) const = 0; diff --git a/include/IMeshManipulator.h b/include/IMeshManipulator.h index 3185407f..0532afee 100644 --- a/include/IMeshManipulator.h +++ b/include/IMeshManipulator.h @@ -70,7 +70,7 @@ namespace scene virtual void scale(IMeshBuffer* buffer, const core::vector3df& factor) const = 0; //! Scales the actual mesh, not a scene node. - /** \deprecated + /** \deprecated Use scale() instead \param mesh Mesh on which the operation is performed. \param factor Scale factor for each axis. */ virtual void scaleMesh(IMesh* mesh, const core::vector3df& factor) const {return scale(mesh,factor);} @@ -98,7 +98,7 @@ namespace scene virtual void transform(IMeshBuffer* buffer, const core::matrix4& m) const = 0; //! Applies a transformation to a mesh - /** \deprecated + /** \deprecated Use transform() instead \param mesh Mesh on which the operation is performed. \param m transformation matrix. */ virtual void transformMesh(IMesh* mesh, const core::matrix4& m) const {return transform(mesh,m);} @@ -128,7 +128,7 @@ namespace scene //! Creates a planar texture mapping on the meshbuffer /** This method is currently implemented towards the LWO planar mapping. A more general biasing might be required. - \param meshbuffer Buffer on which the operation is performed. + \param buffer Buffer on which the operation is performed. \param resolutionS Resolution of the planar mapping in horizontal direction. This is the ratio between object space and texture space. \param resolutionT Resolution of the planar mapping in vertical direction. This is the ratio between object space and texture space. \param axis The axis along which the texture is projected. The allowed values are 0 (X), 1(Y), and 2(Z). diff --git a/include/ISceneCollisionManager.h b/include/ISceneCollisionManager.h index a0324ae8..e8093b0d 100644 --- a/include/ISceneCollisionManager.h +++ b/include/ISceneCollisionManager.h @@ -26,7 +26,7 @@ namespace scene public: //! Finds the collision point of a line and lots of triangles, if there is one. - /** \param ray: Line with witch collisions are tested. + /** \param ray: Line with which collisions are tested. \param selector: TriangleSelector containing the triangles. It can be created for example using ISceneManager::createTriangleSelector() or @@ -58,6 +58,7 @@ namespace scene movement of the ellipsoid. \param triout: Optional parameter where the last triangle causing a collision is stored, if there is a collision. + \param hitPosition: Return value for the position of the collision \param outFalling: Is set to true if the ellipsoid is falling down, caused by gravity. \param outNode: the node with which the ellipoid collided (if any) diff --git a/include/ISceneManager.h b/include/ISceneManager.h index ed2e3786..630e602a 100644 --- a/include/ISceneManager.h +++ b/include/ISceneManager.h @@ -209,7 +209,7 @@ namespace scene * a dummy object in this mode. Meshes included in the * scene will be added into the scene manager with the * following naming scheme: - * path/to/file/file.dea#meshname. The loading of such + * "path/to/file/file.dea#meshname". The loading of such * meshes is logged. Currently, this loader is able to * create meshes (made of only polygons), lights, and * cameras. Materials and animations are currently not @@ -398,13 +398,12 @@ namespace scene const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - //! Adds a test scene node for test purposes to the scene. - /** It is a simple cube of (1,1,1) size. - \param size: Size of the cube. - \param parent: Parent of the scene node. Can be NULL if no parent. + //! Adds a cube scene node + /** \param size: Size of the cube, uniformly in each dimension. + \param parent: Parent of the scene node. Can be 0 if no parent. \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. + \param position: Position of the space relative to its parent + where the scene node will be placed. \param rotation: Initital rotation of the scene node. \param scale: Initial scale of the scene node. \return Pointer to the created test scene node. This @@ -415,14 +414,14 @@ namespace scene const core::vector3df& rotation = core::vector3df(0,0,0), const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) = 0; - //! Adds a sphere scene node for test purposes to the scene. - /** It is a simple sphere. - \param radius: Radius of the sphere. - \param polyCount: Polycount of the sphere. - \param parent: Parent of the scene node. Can be NULL if no parent. + //! Adds a sphere scene node of the given radius and detail + /** \param radius: Radius of the sphere. + \param polyCount: Polycount of the sphere, i.e. subdivision in + horizontal and vertical direction. + \param parent: Parent of the scene node. Can be 0 if no parent. \param id: Id of the node. This id can be used to identify the scene node. - \param position: Position of the space relative to its parent where the - scene node will be placed. + \param position: Position of the space relative to its parent + where the scene node will be placed. \param rotation: Initital rotation of the scene node. \param scale: Initial scale of the scene node. \return Pointer to the created test scene node. This @@ -537,25 +536,31 @@ namespace scene \param parent: Parent scene node of the camera. Can be null. If the parent moves, the camera will move too. \param id: id of the camera. This id can be used to identify the camera. + \param makeActive Flag whether this camera should become the active one. + Make sure you always have one active camera. \return Pointer to interface to camera if successful, otherwise 0. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& lookat = core::vector3df(0,0,100), s32 id=-1) = 0; + const core::vector3df& lookat = core::vector3df(0,0,100), + s32 id=-1, bool makeActive=true) = 0; //! Adds a maya style user controlled camera scene node to the scene graph. /** This is a standard camera with an animator that provides mouse control similar - to camera in the 3D Software Maya by Alias Wavefront. - \param parent: Parent scene node of the camera. Can be null. - \param rotateSpeed: Rotation speed of the camera. - \param zoomSpeed: Zoom speed of the camera. - \param translationSpeed: TranslationSpeed of the camera. - \param id: id of the camera. This id can be used to identify the camera. - \return Returns a pointer to the interface of the camera if successful, otherwise 0. - This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + to camera in the 3D Software Maya by Alias Wavefront. + \param parent: Parent scene node of the camera. Can be null. + \param rotateSpeed: Rotation speed of the camera. + \param zoomSpeed: Zoom speed of the camera. + \param translationSpeed: TranslationSpeed of the camera. + \param id: id of the camera. This id can be used to identify the camera. + \param makeActive Flag whether this camera should become the active one. + Make sure you always have one active camera. + \return Returns a pointer to the interface of the camera if successful, otherwise 0. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, - f32 translationSpeed = 1500.0f, s32 id=-1) = 0; + f32 translationSpeed = 1500.0f, s32 id=-1, + bool makeActive=true) = 0; //! Adds a camera scene node with an animator which provides mouse and keyboard control appropriate for first person shooters (FPS). /** This FPS camera is intended to provide a demonstration of a @@ -616,13 +621,16 @@ namespace scene up when the mouse is moved down and down when the mouse is moved up, the default is 'false' which means it will follow the movement of the mouse cursor. + \param makeActive Flag whether this camera should become the active one. + Make sure you always have one active camera. \return Pointer to the interface of the camera if successful, otherwise 0. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, f32 rotateSpeed = 100.0f, f32 moveSpeed = 0.5f, s32 id=-1, SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, - f32 jumpSpeed = 0.f, bool invertMouse=false) = 0; + f32 jumpSpeed = 0.f, bool invertMouse=false, + bool makeActive=true) = 0; //! Adds a dynamic light scene node to the scene graph. /** The light will cast dynamic light on all @@ -692,6 +700,7 @@ namespace scene \param spherePercentage: How much of the sphere is drawn. Value should be between 0 and 2, where 1 is an exact half-sphere and 2 is a full sphere. + \param radius The Radius of the sphere \param parent: Parent scene node of the dome. A dome usually has no parent, so this should be null. Note: If a parent is set, the dome will not change how it is drawn. @@ -1098,6 +1107,8 @@ namespace scene move from the start point to the end point. \param loop: If set to false, the node stops when the end point is reached. If loop is true, the node begins again at the start. + \param pingpong Flag to set whether the animator should fly + back from end to start again. \return The animator. Attach it to a scene node with ISceneNode::addAnimator() and the animator will animate it. If you no longer need the animator, you should call ISceneNodeAnimator::drop(). @@ -1199,10 +1210,11 @@ namespace scene virtual ITriangleSelector* createTriangleSelector(IMesh* mesh, ISceneNode* node) = 0; //! Creates a simple ITriangleSelector, based on an animated mesh scene node. - //! Details of the mesh associated with the node will be extracted internally. - //! Call ITriangleSelector::update() to have the triangle selector updated based - //! on the current frame of the animated mesh scene node. - //! \param: The animated mesh scene node from which to build the selector + /** Details of the mesh associated with the node will be extracted internally. + Call ITriangleSelector::update() to have the triangle selector updated based + on the current frame of the animated mesh scene node. + \param node The animated mesh scene node from which to build the selector + */ virtual ITriangleSelector* createTriangleSelector(IAnimatedMeshSceneNode* node) = 0; diff --git a/include/IVideoDriver.h b/include/IVideoDriver.h index bde254e9..464def92 100644 --- a/include/IVideoDriver.h +++ b/include/IVideoDriver.h @@ -132,6 +132,14 @@ namespace video EFT_FOG_EXP2 }; + const c8* const FogTypeNames[] = + { + "FogExp", + "FogLinear", + "FogExp2", + 0 + }; + struct SOverrideMaterial { //! The Material values @@ -396,7 +404,7 @@ namespace video example in picture edit programs. To avoid this problem, you could use the makeColorKeyTexture method, which takes the position of a pixel instead a color value. - \param \deprecated zeroTexels If set to true, then any texels that match + \param zeroTexels \deprecated If set to true, then any texels that match the color key will have their color, as well as their alpha, set to zero (i.e. black). This behaviour matches the legacy (buggy) behaviour prior to release 1.5 and is provided for backwards compatibility only.*/ @@ -412,7 +420,7 @@ namespace video \param colorKeyPixelPos Position of a pixel with the color key color. Every texel with this color will become fully transparent as described above. - \param \deprecated zeroTexels If set to true, then any texels that match + \param zeroTexels \deprecated If set to true, then any texels that match the color key will have their color, as well as their alpha, set to zero (i.e. black). This behaviour matches the legacy (buggy) behaviour prior to release 1.5 and is provided for backwards compatibility only.*/ @@ -548,8 +556,11 @@ namespace video \param vertexCount Amount of vertices in the array. \param indexList Pointer to array of indices. \param triangleCount Amount of Triangles. Usually amount of indices / 3. */ - virtual void drawIndexedTriangleList(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) =0; + void drawIndexedTriangleList(const S3DVertex* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT); + } //! Draws an indexed triangle list. /** Note that there may be at maximum 65536 vertices, because @@ -560,8 +571,11 @@ namespace video \param vertexCount Amount of vertices in the array. \param indexList Pointer to array of indices. \param triangleCount Amount of Triangles. Usually amount of indices / 3. */ - virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) =0; + void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES, EIT_16BIT); + } //! Draws an indexed triangle list. /** Note that there may be at maximum 65536 vertices, because @@ -572,8 +586,11 @@ namespace video \param vertexCount Amount of vertices in the array. \param indexList Pointer to array of indices. \param triangleCount Amount of Triangles. Usually amount of indices / 3. */ - virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) =0; + void drawIndexedTriangleList(const S3DVertexTangents* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES, EIT_16BIT); + } //! Draws an indexed triangle fan. /** Note that there may be at maximum 65536 vertices, because @@ -584,8 +601,11 @@ namespace video \param vertexCount Amount of vertices in the array. \param indexList Pointer to array of indices. \param triangleCount Amount of Triangles. Usually amount of indices - 2. */ - virtual void drawIndexedTriangleFan(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) =0; + void drawIndexedTriangleFan(const S3DVertex* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT); + } //! Draws an indexed triangle fan. /** Note that there may be at maximum 65536 vertices, because @@ -596,18 +616,36 @@ namespace video \param vertexCount Amount of vertices in the array. \param indexList Pointer to array of indices. \param triangleCount Amount of Triangles. Usually amount of indices - 2. */ - virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) =0; + void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN, EIT_16BIT); + } + + //! Draws an indexed triangle fan. + /** Note that there may be at maximum 65536 vertices, because + the index list is an array of 16 bit values each with a maximum + value of 65536. If there are more than 65536 vertices in the + list, results of this operation are not defined. + \param vertices Pointer to array of vertices. + \param vertexCount Amount of vertices in the array. + \param indexList Pointer to array of indices. + \param triangleCount Amount of Triangles. Usually amount of indices - 2. */ + void drawIndexedTriangleFan(const S3DVertexTangents* vertices, + u32 vertexCount, const u16* indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN, EIT_16BIT); + } //! Draws a 3d line. /** For some implementations, this method simply calls - drawIndexedTriangles for some triangles. + drawVertexPrimitiveList for some triangles. Note that the line is drawn using the current transformation matrix and material. So if you need to draw the 3D line independently of the current transformation, use \code - driver->setMaterial(unlitMaterial); - driver->setTransform(video::ETS_WORLD, core::matrix4()); + driver->setMaterial(someMaterial); + driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); \endcode for some properly set up material before drawing the line. Some drivers support line thickness set in the material. @@ -618,15 +656,15 @@ namespace video const core::vector3df& end, SColor color = SColor(255,255,255,255)) =0; //! Draws a 3d triangle. - /** This method calls drawIndexedTriangles for some triangles. + /** This method calls drawVertexPrimitiveList for some triangles. This method works with all drivers because it simply calls - drawIndexedTriangleList but it is hence not very fast. + drawVertexPrimitiveList, but it is hence not very fast. Note that the triangle is drawn using the current transformation matrix and material. So if you need to draw it independently of the current transformation, use \code - driver->setMaterial(unlitMaterial); - driver->setTransform(video::ETS_WORLD, core::matrix4()); + driver->setMaterial(someMaterial); + driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); \endcode for some properly set up material before drawing the triangle. \param triangle The triangle to draw. @@ -640,8 +678,8 @@ namespace video matrix and material. So if you need to draw it independently of the current transformation, use \code - driver->setMaterial(unlitMaterial); - driver->setTransform(video::ETS_WORLD, core::matrix4()); + driver->setMaterial(someMaterial); + driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); \endcode for some properly set up material before drawing the box. \param box The axis aligned box to draw @@ -864,8 +902,7 @@ namespace video /** These are global values attached to each 3d object rendered, which has the fog flag enabled in its material. \param color Color of the fog - \param linearFog Set this to true for linear fog, otherwise - exponential fog is applied. + \param fogType Type of fog used \param start Only used in linear fog mode (linearFog=true). Specifies where fog starts. \param end Only used in linear fog mode (linearFog=true). @@ -883,6 +920,11 @@ namespace video f32 start=50.0f, f32 end=100.0f, f32 density=0.01f, bool pixelFog=false, bool rangeFog=false) =0; + //! Gets the fog mode. + virtual void getFog(SColor& color, E_FOG_TYPE& fogType, + f32& start, f32& end, f32& density, + bool& pixelFog, bool& rangeFog) = 0; + //! Get the current color format of the color buffer /** \return Color format of the color buffer. */ virtual ECOLOR_FORMAT getColorFormat() const =0; @@ -965,7 +1007,7 @@ namespace video //! Returns the maximum amount of primitives /** (mostly vertices) which the device is able to render with - one drawIndexedTriangleList call. + one drawVertexPrimitiveList call. \return Maximum amount of primitives. */ virtual u32 getMaximalPrimitiveCount() const =0; @@ -1253,6 +1295,9 @@ namespace video Use the SceneManager attribute to set this value from your app. \param flag Default behavior is to disable ZWrite, i.e. false. */ virtual void setAllowZWriteOnTransparent(bool flag) =0; + + //! Returns the maximum texture size supported. + virtual core::dimension2du getMaxTextureSize() const =0; }; } // end namespace video diff --git a/include/IrrCompileConfig.h b/include/IrrCompileConfig.h index f18ac63a..301ee609 100644 --- a/include/IrrCompileConfig.h +++ b/include/IrrCompileConfig.h @@ -11,8 +11,8 @@ #define IRRLICHT_VERSION_REVISION 0 // This flag will be defined only in SVN, the official release code will have // it undefined -#define IRRLICHT_VERSION_SVN -#define IRRLICHT_SDK_VERSION "1.6-SVN" +//#define IRRLICHT_VERSION_SVN +#define IRRLICHT_SDK_VERSION "1.6" #include // TODO: Although included elsewhere this is required at least for mingw @@ -92,10 +92,7 @@ #endif #if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) -#if defined(__sparc__) || defined(__sun__) -#define __BIG_ENDIAN__ -#define _IRR_SOLARIS_PLATFORM_ -#else +#ifndef _IRR_SOLARIS_PLATFORM_ #define _IRR_LINUX_PLATFORM_ #endif #define _IRR_POSIX_API_ @@ -126,7 +123,7 @@ headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one. #if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK)) //! Only define _IRR_COMPILE_WITH_DIRECT3D_8_ if you have an appropriate DXSDK, e.g. Summer 2004 -//#define _IRR_COMPILE_WITH_DIRECT3D_8_ +#define _IRR_COMPILE_WITH_DIRECT3D_8_ #define _IRR_COMPILE_WITH_DIRECT3D_9_ #endif @@ -509,6 +506,10 @@ precision will be lower but speed higher. currently X86 only #undef _IRR_WCHAR_FILESYSTEM #endif +#if defined(__sparc__) || defined(__sun__) +#define __BIG_ENDIAN__ +#endif + #if defined(_IRR_SOLARIS_PLATFORM_) #undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ #endif diff --git a/include/SColor.h b/include/SColor.h index 6fe2ae89..400a88a3 100644 --- a/include/SColor.h +++ b/include/SColor.h @@ -191,13 +191,19 @@ namespace video 0 means no blue, 255 means full blue. */ u32 getBlue() const { return color & 0xff; } - //! Returns the luminance of the color. + //! Get lightness of the color in the range [0,255] + f32 getLightness() const + { + return 0.5f*(core::max_(core::max_(getRed(),getGreen()),getBlue())+core::min_(core::min_(getRed(),getGreen()),getBlue())); + } + + //! Get luminance of the color in the range [0,255]. f32 getLuminance() const { return 0.3f*getRed() + 0.59f*getGreen() + 0.11f*getBlue(); } - //! Returns the average intensity of the color. + //! Get average intensity of the color in the range [0,255]. u32 getAverage() const { return ( getRed() + getGreen() + getBlue() ) / 3; diff --git a/include/SViewFrustum.h b/include/SViewFrustum.h index dc5b330c..08eae824 100644 --- a/include/SViewFrustum.h +++ b/include/SViewFrustum.h @@ -85,7 +85,7 @@ namespace scene const core::matrix4& getTransform( video::E_TRANSFORMATION_STATE state) const; //! clips a line to the view frustum. - //! \Return: Returns true if the line was clipped, false if not + /** \return True if the line was clipped, false if not */ bool clipLine(core::line3d& line) const; //! the position of the camera diff --git a/include/irrArray.h b/include/irrArray.h index aae8195f..3d21f641 100644 --- a/include/irrArray.h +++ b/include/irrArray.h @@ -96,7 +96,7 @@ public: //! set a new allocation strategy /** if the maximum size of the array is unknown, you can define how big the allocation should happen. - \param element: newStratgey to applay to this array. */ + \param newStrategy New strategy to apply to this array. */ void setAllocStrategy ( eAllocStrategy newStrategy = ALLOC_STRATEGY_DOUBLE ) { strategy = newStrategy; diff --git a/include/irrMath.h b/include/irrMath.h index aeef0e1d..5c40c70b 100644 --- a/include/irrMath.h +++ b/include/irrMath.h @@ -38,7 +38,7 @@ namespace core //! Rounding error constant often used when comparing f32 values. - const s32 ROUNDING_ERROR_S32 = 1; + const s32 ROUNDING_ERROR_S32 = 0; const f32 ROUNDING_ERROR_f32 = 0.000001f; const f64 ROUNDING_ERROR_f64 = 0.00000001; @@ -450,7 +450,6 @@ namespace core // calculate: 1 / x REALINLINE f32 reciprocal( const f32 f ) { - _IRR_DEBUG_BREAK_IF(f==0.f); //divide by zero #if defined (IRRLICHT_FAST_MATH) // SSE Newton-Raphson reciprocal estimate, accurate to 23 significant @@ -484,7 +483,6 @@ namespace core // calculate: 1 / x REALINLINE f64 reciprocal ( const f64 f ) { - _IRR_DEBUG_BREAK_IF(f==0.); //divide by zero return 1.0 / f; } @@ -492,7 +490,6 @@ namespace core // calculate: 1 / x, low precision allowed REALINLINE f32 reciprocal_approxim ( const f32 f ) { - _IRR_DEBUG_BREAK_IF(f==0.f); //divide by zero #if defined( IRRLICHT_FAST_MATH) // SSE Newton-Raphson reciprocal estimate, accurate to 23 significant diff --git a/include/irrString.h b/include/irrString.h index bf0f3dab..1d0f2160 100644 --- a/include/irrString.h +++ b/include/irrString.h @@ -124,8 +124,7 @@ public: // temporary buffer for 16 numbers - c8 tmpbuf[16]; - tmpbuf[15] = 0; + c8 tmpbuf[16]={0}; u32 idx = 15; // special case '0' @@ -164,8 +163,7 @@ public: { // temporary buffer for 16 numbers - c8 tmpbuf[16]; - tmpbuf[15] = 0; + c8 tmpbuf[16]={0}; u32 idx = 15; // special case '0' @@ -222,7 +220,7 @@ public: //! Destructor - virtual ~string() + ~string() { allocator.deallocate(array); // delete [] array; } @@ -737,10 +735,11 @@ public: //! finds another string in this string /** \param str: Another string + \param start: Start position of the search \return Positions where the string has been found, or -1 if not found. */ template - s32 find(const B* const str) const + s32 find(const B* const str, const u32 start = 0) const { if (str && *str) { @@ -752,7 +751,7 @@ public: if (len > used-1) return -1; - for (u32 i=0; i toRemove) + { + u32 size = toRemove.size(); + u32 pos = 0; + u32 found = 0; + for (u32 i=0; i & characters) + { + u32 pos = 0; + u32 found = 0; + for (u32 i=0; i 1 ? array[used-2] : 0; } diff --git a/include/irrTypes.h b/include/irrTypes.h index fb565f4d..f0e3f725 100644 --- a/include/irrTypes.h +++ b/include/irrTypes.h @@ -122,12 +122,15 @@ typedef unsigned short wchar_t; namespace irr { -//! Should the wide character version of the FileSystem be used +//! Type name for character type used by the file system. +/** Should the wide character version of the FileSystem be used it is a +16 bit character variable. Used for unicode Filesystem and unicode strings. +Else it is a 8 bit character variable. Used for ansi Filesystem and non-unicode +strings +*/ #if defined(_IRR_WCHAR_FILESYSTEM) - //! 16 bit character variable. Used for unicode Filesystem and unicode strings typedef wchar_t fschar_t; #else - //! 8 bit character variable. Used for ansi Filesystem and non-unicode strings typedef char fschar_t; #endif @@ -211,8 +214,8 @@ Compiler version defines: VC6.0 : 1200, VC7.0 : 1300, VC7.1 : 1310, VC8.0 : 1400 /** some compilers can create those by directly writing the code like 'code', but some generate warnings so we use this macro here */ #define MAKE_IRR_ID(c0, c1, c2, c3) \ - ((u32)(u8)(c0) | ((u32)(u8)(c1) << 8) | \ - ((u32)(u8)(c2) << 16) | ((u32)(u8)(c3) << 24 )) + ((irr::u32)(irr::u8)(c0) | ((irr::u32)(irr::u8)(c1) << 8) | \ + ((irr::u32)(irr::u8)(c2) << 16) | ((irr::u32)(irr::u8)(c3) << 24 )) #endif // __IRR_TYPES_H_INCLUDED__ diff --git a/include/irrXML.h b/include/irrXML.h index 45738d9d..76e6f88c 100644 --- a/include/irrXML.h +++ b/include/irrXML.h @@ -17,7 +17,7 @@ Here you'll find any information you'll need to develop applications with irrXML. If you look for a tutorial on how to start, take a look at the \ref irrxmlexample, at the homepage of irrXML at www.ambiera.com/irrxml/ - or into the SDK in the directory \example. + or into the SDK in the directory example. irrXML is intended to be a high speed and easy-to-use XML Parser for C++, and this documentation is an important part of it. If you have any questions or @@ -522,7 +522,7 @@ namespace io bool deleteCallback = false); - /*! \file irrxml.h + /*! \file irrXML.h \brief Header file of the irrXML, the Irrlicht XML parser. This file includes everything needed for using irrXML, @@ -534,7 +534,7 @@ namespace io \endcode It is also common to use the two namespaces in which irrXML is included, - directly after #including irrXML.h: + directly after including irrXML.h: \code #include diff --git a/include/irrlicht.h b/include/irrlicht.h index cf4850d7..389d379b 100644 --- a/include/irrlicht.h +++ b/include/irrlicht.h @@ -184,7 +184,7 @@ #include "vector2d.h" #include "vector3d.h" -/*! \mainpage Irrlicht Engine 1.5 API documentation +/*! \mainpage Irrlicht Engine 1.6 API documentation * *
* @@ -357,7 +357,7 @@ namespace irr // THE FOLLOWING IS AN EMPTY LIST OF ALL SUB NAMESPACES // EXISTING ONLY FOR THE DOCUMENTATION SOFTWARE DOXYGEN. - //! In this namespace can be found basic classes like vectors, planes, arrays, lists and so on. + //! Basic classes such as vectors, planes, arrays, lists, and so on can be found in this namespace. namespace core { } @@ -367,14 +367,12 @@ namespace irr { } - //! This namespace provides interfaces for input/output: Reading and - //! writing files, accessing zip archives, xml files, ... + //! This namespace provides interfaces for input/output: Reading and writing files, accessing zip archives, xml files, ... namespace io { } - //! All scene management can be found in this namespace: Mesh loading, - //! special scene nodes like octrees and billboards, ... + //! All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees and billboards, ... namespace scene { } @@ -391,4 +389,3 @@ namespace irr #endif - diff --git a/include/matrix4.h b/include/matrix4.h index d50366b0..a4c306dd 100644 --- a/include/matrix4.h +++ b/include/matrix4.h @@ -310,9 +310,9 @@ namespace core */ CMatrix4& buildRotateFromTo(const core::vector3df& from, const core::vector3df& to); - //! Builds a combined matrix which translate to a center before rotation and translate afterwards - /** \param from: vector to rotate from - \param to: vector to rotate to + //! Builds a combined matrix which translates to a center before rotation and translates from origin afterwards + /** \param center Position to rotate around + \param translate Translation applied after the rotation */ void setRotationCenter(const core::vector3df& center, const core::vector3df& translate); @@ -1922,9 +1922,6 @@ namespace core //! Builds a combined matrix which translate to a center before rotation and translate afterwards - /** \param from: vector to rotate from - \param to: vector to rotate to - */ template inline void CMatrix4::setRotationCenter(const core::vector3df& center, const core::vector3df& translation) { diff --git a/include/path.h b/include/path.h index 8cb7e4fa..56259d66 100644 --- a/include/path.h +++ b/include/path.h @@ -12,6 +12,8 @@ namespace irr namespace io { +//! Type used for all file system related strings. +/** This type will transparently handle different file system encodings. */ typedef core::string path; } // io diff --git a/include/position2d.h b/include/position2d.h index d2854c26..ea0850b7 100644 --- a/include/position2d.h +++ b/include/position2d.h @@ -14,6 +14,7 @@ namespace irr { namespace core { + // Use typedefs where possible as they are more explicit... //! \deprecated position2d is now a synonym for vector2d, but vector2d should be used directly. @@ -28,3 +29,4 @@ typedef vector2d position2di; #define position2d vector2d #endif // __IRR_POSITION_H_INCLUDED__ + diff --git a/include/quaternion.h b/include/quaternion.h index 568db401..fe60d949 100644 --- a/include/quaternion.h +++ b/include/quaternion.h @@ -83,7 +83,7 @@ class quaternion matrix4 getMatrix() const; //! Creates a matrix from this quaternion - void getMatrix( matrix4 &dest, const vector3df &translation ) const; + void getMatrix( matrix4 &dest, const core::vector3df &translation ) const; /*! Creates a matrix from this quaternion @@ -102,7 +102,7 @@ class quaternion lookat *= m3; */ - void getMatrixCenter( matrix4 &dest, const vector3df ¢er, const vector3df &translation ) const; + void getMatrixCenter( matrix4 &dest, const core::vector3df ¢er, const core::vector3df &translation ) const; //! Creates a matrix from this quaternion inline void getMatrix_transposed( matrix4 &dest ) const; @@ -339,10 +339,9 @@ inline void quaternion::getMatrix( matrix4 &dest, const core::vector3df ¢er m2.setInverseTranslation ( center ); lookat *= m2; */ -inline void quaternion::getMatrixCenter( matrix4 &dest, - const core::vector3df ¢er, - const core::vector3df &translation - ) const +inline void quaternion::getMatrixCenter(matrix4 &dest, + const core::vector3df ¢er, + const core::vector3df &translation) const { f32 * m = dest.pointer(); diff --git a/media/020shot.jpg b/media/020shot.jpg new file mode 100644 index 00000000..da5d98b8 Binary files /dev/null and b/media/020shot.jpg differ diff --git a/media/021shot.jpg b/media/021shot.jpg index db25117d..48b28d7f 100644 Binary files a/media/021shot.jpg and b/media/021shot.jpg differ diff --git a/media/ninja animation ranges.txt b/media/ninja animation ranges.txt index ea09f50c..eaf12fef 100644 --- a/media/ninja animation ranges.txt +++ b/media/ninja animation ranges.txt @@ -32,3 +32,5 @@ Feel free to use however you like, commercial etc, credits are Appreciated as a Psionic http://www.psionic3d.co.uk + +Note for Irrlicht: Irrlicht uses a 0-based frame index. So subtract 1 from each of the loops! \ No newline at end of file diff --git a/scripts/doc/irrlicht/makedocumentation.bat b/scripts/doc/irrlicht/makedocumentation.bat index 80a85f19..fcfad584 100644 --- a/scripts/doc/irrlicht/makedocumentation.bat +++ b/scripts/doc/irrlicht/makedocumentation.bat @@ -21,7 +21,11 @@ rem for /F %%i in ('dir ..\..\..\examples\[01]*\main.cpp') DO ..\sed.exe -f tuto ..\sed.exe -f tutorials.sed ..\..\..\examples\14.Win32Window\main.cpp >>tut.txt ..\sed.exe -f tutorials.sed ..\..\..\examples\15.LoadIrrFile\main.cpp >>tut.txt ..\sed.exe -f tutorials.sed ..\..\..\examples\16.Quake3MapShader\main.cpp >>tut.txt -..\sed.exe -f tutorials.sed ..\..\..\examples\17.SplitScreen\main.cpp >>tut.txt +..\sed.exe -f tutorials.sed ..\..\..\examples\17.HelloWorld_Mobile\main.cpp >>tut.txt +..\sed.exe -f tutorials.sed ..\..\..\examples\18.SplitScreen\main.cpp >>tut.txt +..\sed.exe -f tutorials.sed ..\..\..\examples\19.MouseAndJoystick\main.cpp >>tut.txt +..\sed.exe -f tutorials.sed ..\..\..\examples\20.ManagedLights\main.cpp >>tut.txt +..\sed.exe -f tutorials.sed ..\..\..\examples\21.Quake3Explorer\main.cpp >>tut.txt ..\doxygen.exe doxygen.cfg diff --git a/scripts/doc/irrlicht/makedocumentation.sh b/scripts/doc/irrlicht/makedocumentation.sh index 1239855b..c430b837 100755 --- a/scripts/doc/irrlicht/makedocumentation.sh +++ b/scripts/doc/irrlicht/makedocumentation.sh @@ -1,5 +1,5 @@ rm tut.txt || true; -for i in ../../../examples/[01]*/main.cpp; do +for i in ../../../examples/[012]*/main.cpp; do sed -f tutorials.sed $i >>tut.txt; done diff --git a/source/Irrlicht/CAnimatedMeshMD2.h b/source/Irrlicht/CAnimatedMeshMD2.h index 8b552b51..663eef18 100644 --- a/source/Irrlicht/CAnimatedMeshMD2.h +++ b/source/Irrlicht/CAnimatedMeshMD2.h @@ -126,7 +126,6 @@ namespace scene virtual void calculateBoundingBox(); u32 FrameCount; - s32 TriangleCount; private: diff --git a/source/Irrlicht/CAnimatedMeshSceneNode.cpp b/source/Irrlicht/CAnimatedMeshSceneNode.cpp index 35c9ecb0..75f9aefa 100644 --- a/source/Irrlicht/CAnimatedMeshSceneNode.cpp +++ b/source/Irrlicht/CAnimatedMeshSceneNode.cpp @@ -349,6 +349,7 @@ void CAnimatedMeshSceneNode::render() { video::SMaterial debug_mat; debug_mat.Lighting = false; + debug_mat.AntiAliasing=0; driver->setMaterial(debug_mat); // show normals if (DebugDataVisible & scene::EDS_NORMALS) @@ -523,6 +524,12 @@ void CAnimatedMeshSceneNode::setAnimationSpeed(f32 framesPerSecond) } +f32 CAnimatedMeshSceneNode::getAnimationSpeed() const +{ + return FramesPerSecond * 1000.f; +} + + //! returns the axis aligned bounding box of this node const core::aabbox3d& CAnimatedMeshSceneNode::getBoundingBox() const { @@ -767,8 +774,8 @@ void CAnimatedMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttr out->addBool("Looping", Looping); out->addBool("ReadOnlyMaterials", ReadOnlyMaterials); out->addFloat("FramesPerSecond", FramesPerSecond); - - // TODO: write animation names instead of frame begin and ends + out->addInt("StartFrame", StartFrame); + out->addInt("EndFrame", EndFrame); } @@ -783,6 +790,8 @@ void CAnimatedMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAtt Looping = in->getAttributeAsBool("Looping"); ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials"); FramesPerSecond = in->getAttributeAsFloat("FramesPerSecond"); + StartFrame = in->getAttributeAsInt("StartFrame"); + EndFrame = in->getAttributeAsInt("EndFrame"); if (newMeshStr != "" && oldMeshStr != newMeshStr) { diff --git a/source/Irrlicht/CAnimatedMeshSceneNode.h b/source/Irrlicht/CAnimatedMeshSceneNode.h index ec167207..05874e7f 100644 --- a/source/Irrlicht/CAnimatedMeshSceneNode.h +++ b/source/Irrlicht/CAnimatedMeshSceneNode.h @@ -57,9 +57,12 @@ namespace scene //! playback has ended. Set this to 0 to disable the callback again. virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0); - //! sets the speed with witch the animation is played + //! sets the speed with which the animation is played virtual void setAnimationSpeed(f32 framesPerSecond); + //! gets the speed with which the animation is played + virtual f32 getAnimationSpeed() const; + //! returns the material based on the zero based index i. To get the amount //! of materials used by this scene node, use getMaterialCount(). //! This function is needed for inserting the node into the scene hirachy on a diff --git a/source/Irrlicht/CAttributeImpl.h b/source/Irrlicht/CAttributeImpl.h index 53409b30..4586e9e4 100644 --- a/source/Irrlicht/CAttributeImpl.h +++ b/source/Irrlicht/CAttributeImpl.h @@ -1850,6 +1850,9 @@ public: virtual void setTexture(video::ITexture* value) { + if ( value == Value ) + return; + if (Value) Value->drop(); diff --git a/source/Irrlicht/CCameraSceneNode.cpp b/source/Irrlicht/CCameraSceneNode.cpp index 5dbf11c7..9be28aa4 100644 --- a/source/Irrlicht/CCameraSceneNode.cpp +++ b/source/Irrlicht/CCameraSceneNode.cpp @@ -234,6 +234,16 @@ void CCameraSceneNode::recalculateProjectionMatrix() //! prerender void CCameraSceneNode::OnRegisterSceneNode() { + if ( SceneManager->getActiveCamera () == this ) + SceneManager->registerNodeForRendering(this, ESNRP_CAMERA); + + ISceneNode::OnRegisterSceneNode(); +} + + +//! render +void CCameraSceneNode::render() +{ core::vector3df pos = getAbsolutePosition(); core::vector3df tgtv = Target - pos; tgtv.normalize(); @@ -245,7 +255,7 @@ void CCameraSceneNode::OnRegisterSceneNode() f32 dp = tgtv.dotProduct(up); - if ( core::equals(fabsf(dp), 1.f) ) + if ( core::equals(core::abs_(dp), 1.f) ) { up.X += 0.5f; } @@ -254,16 +264,6 @@ void CCameraSceneNode::OnRegisterSceneNode() ViewArea.getTransform(video::ETS_VIEW) *= Affector; recalculateViewArea(); - if ( SceneManager->getActiveCamera () == this ) - SceneManager->registerNodeForRendering(this, ESNRP_CAMERA); - - ISceneNode::OnRegisterSceneNode(); -} - - -//! render -void CCameraSceneNode::render() -{ video::IVideoDriver* driver = SceneManager->getVideoDriver(); if ( driver) { @@ -345,6 +345,24 @@ bool CCameraSceneNode::getTargetAndRotationBinding(void) const } +//! Creates a clone of this scene node and its children. +ISceneNode* CCameraSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager) +{ + if (!newParent) + newParent = Parent; + if (!newManager) + newManager = SceneManager; + + CCameraSceneNode* nb = new CCameraSceneNode(newParent, + newManager, ID, RelativeTranslation, Target); + + nb->cloneMembers(this, newManager); + + nb->drop(); + return nb; +} + + } // end namespace } // end namespace diff --git a/source/Irrlicht/CCameraSceneNode.h b/source/Irrlicht/CCameraSceneNode.h index 0071bba7..6beee2dc 100644 --- a/source/Irrlicht/CCameraSceneNode.h +++ b/source/Irrlicht/CCameraSceneNode.h @@ -142,6 +142,9 @@ namespace scene //! Queries if the camera scene node's rotation and its target position are bound together. virtual bool getTargetAndRotationBinding(void) const; + //! Creates a clone of this scene node and its children. + virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); + protected: void recalculateProjectionMatrix(); diff --git a/source/Irrlicht/CD3D8Driver.cpp b/source/Irrlicht/CD3D8Driver.cpp index e3dd6a28..e36627cb 100644 --- a/source/Irrlicht/CD3D8Driver.cpp +++ b/source/Irrlicht/CD3D8Driver.cpp @@ -151,7 +151,7 @@ bool CD3D8Driver::initDriver(const core::dimension2d& screenSize, #if defined( _IRR_XBOX_PLATFORM_) D3DCREATETYPE d3dCreate = (D3DCREATETYPE) &Direct3DCreate8; #else - D3DLibrary = LoadLibrary( "d3d8.dll" ); + D3DLibrary = LoadLibrary( __TEXT("d3d8.dll") ); if (!D3DLibrary) { @@ -904,7 +904,19 @@ void CD3D8Driver::draw2D3DVertexPrimitiveList(const void* vertices, return; } else - setRenderStates2DMode(true, (Material.getTexture(0) != 0), true); + { + if (Material.MaterialType==EMT_ONETEXTURE_BLEND) + { + E_BLEND_FACTOR srcFact; + E_BLEND_FACTOR dstFact; + E_MODULATE_FUNC modulo; + u32 alphaSource; + unpack_texureBlendFunc ( srcFact, dstFact, modulo, alphaSource, Material.MaterialTypeParam); + setRenderStates2DMode(alphaSource&video::EAS_VERTEX_COLOR, (Material.getTexture(0) != 0), alphaSource&video::EAS_TEXTURE); + } + else + setRenderStates2DMode(Material.MaterialType==EMT_TRANSPARENT_VERTEX_ALPHA, (Material.getTexture(0) != 0), Material.MaterialType==EMT_TRANSPARENT_ALPHA_CHANNEL); + } switch (pType) { @@ -2296,6 +2308,12 @@ void CD3D8Driver::enableClipPlane(u32 index, bool enable) } +core::dimension2du CD3D8Driver::getMaxTextureSize() const +{ + return core::dimension2du(Caps.MaxTextureWidth, Caps.MaxTextureHeight); +} + + } // end namespace video } // end namespace irr diff --git a/source/Irrlicht/CD3D8Driver.h b/source/Irrlicht/CD3D8Driver.h index 04a9e1ae..38b9edd1 100644 --- a/source/Irrlicht/CD3D8Driver.h +++ b/source/Irrlicht/CD3D8Driver.h @@ -217,6 +217,9 @@ namespace video //! \param enable: If true, enable the clipping plane else disable it. virtual void enableClipPlane(u32 index, bool enable); + //! Returns the maximum texture size supported. + virtual core::dimension2du getMaxTextureSize() const; + virtual bool checkDriverReset() {return DriverWasReset;} private: diff --git a/source/Irrlicht/CD3D8MaterialRenderer.h b/source/Irrlicht/CD3D8MaterialRenderer.h index 66ae92e3..24798012 100644 --- a/source/Irrlicht/CD3D8MaterialRenderer.h +++ b/source/Irrlicht/CD3D8MaterialRenderer.h @@ -401,10 +401,10 @@ public: if (material.MaterialType == EMT_LIGHTMAP_ADD) pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD); else - if (material.MaterialType == EMT_LIGHTMAP_M4) + if (material.MaterialType == EMT_LIGHTMAP_M4 || material.MaterialType == EMT_LIGHTMAP_LIGHTING_M4) pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE4X); else - if (material.MaterialType == EMT_LIGHTMAP_M2) + if (material.MaterialType == EMT_LIGHTMAP_M2 || material.MaterialType == EMT_LIGHTMAP_LIGHTING_M2) pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE2X); else pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); diff --git a/source/Irrlicht/CD3D9Driver.cpp b/source/Irrlicht/CD3D9Driver.cpp index 090a85ea..069ac461 100644 --- a/source/Irrlicht/CD3D9Driver.cpp +++ b/source/Irrlicht/CD3D9Driver.cpp @@ -163,7 +163,7 @@ bool CD3D9Driver::initDriver(const core::dimension2d& screenSize, if (!pID3D) { - D3DLibrary = LoadLibrary( "d3d9.dll" ); + D3DLibrary = LoadLibrary( __TEXT("d3d9.dll") ); if (!D3DLibrary) { @@ -1173,7 +1173,19 @@ void CD3D9Driver::draw2D3DVertexPrimitiveList(const void* vertices, return; } else - setRenderStates2DMode(true, (Material.getTexture(0) != 0), true); + { + if (Material.MaterialType==EMT_ONETEXTURE_BLEND) + { + E_BLEND_FACTOR srcFact; + E_BLEND_FACTOR dstFact; + E_MODULATE_FUNC modulo; + u32 alphaSource; + unpack_texureBlendFunc ( srcFact, dstFact, modulo, alphaSource, Material.MaterialTypeParam); + setRenderStates2DMode(alphaSource&video::EAS_VERTEX_COLOR, (Material.getTexture(0) != 0), (alphaSource&video::EAS_TEXTURE) != 0); + } + else + setRenderStates2DMode(Material.MaterialType==EMT_TRANSPARENT_VERTEX_ALPHA, (Material.getTexture(0) != 0), Material.MaterialType==EMT_TRANSPARENT_ALPHA_CHANNEL); + } switch (pType) { @@ -3111,6 +3123,12 @@ void CD3D9Driver::removeDepthSurface(SDepthSurface* depth) } +core::dimension2du CD3D9Driver::getMaxTextureSize() const +{ + return core::dimension2du(Caps.MaxTextureWidth, Caps.MaxTextureHeight); +} + + } // end namespace video } // end namespace irr diff --git a/source/Irrlicht/CD3D9Driver.h b/source/Irrlicht/CD3D9Driver.h index 4ff672e1..c5a664d1 100644 --- a/source/Irrlicht/CD3D9Driver.h +++ b/source/Irrlicht/CD3D9Driver.h @@ -272,6 +272,9 @@ namespace video /** \return Color format of the color buffer. */ virtual ECOLOR_FORMAT getColorFormat() const; + //! Returns the maximum texture size supported. + virtual core::dimension2du getMaxTextureSize() const; + //! Get the current color format of the color buffer /** \return Color format of the color buffer as D3D color value. */ D3DFORMAT getD3DColorFormat() const; diff --git a/source/Irrlicht/CD3D9MaterialRenderer.h b/source/Irrlicht/CD3D9MaterialRenderer.h index f38e9919..782e167a 100644 --- a/source/Irrlicht/CD3D9MaterialRenderer.h +++ b/source/Irrlicht/CD3D9MaterialRenderer.h @@ -377,7 +377,7 @@ public: pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); // 127 is required by EMT_TRANSPARENT_ALPHA_CHANNEL_REF - pID3DDevice->SetRenderState(D3DRS_ALPHAREF, 127); + pID3DDevice->SetRenderState(D3DRS_ALPHAREF, 127); pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); } @@ -431,10 +431,10 @@ public: if (material.MaterialType == EMT_LIGHTMAP_ADD) pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD); else - if (material.MaterialType == EMT_LIGHTMAP_M4) + if (material.MaterialType == EMT_LIGHTMAP_M4 || material.MaterialType == EMT_LIGHTMAP_LIGHTING_M4) pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE4X); else - if (material.MaterialType == EMT_LIGHTMAP_M2) + if (material.MaterialType == EMT_LIGHTMAP_M2 || material.MaterialType == EMT_LIGHTMAP_LIGHTING_M2) pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE2X); else pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); diff --git a/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp b/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp index f0cf45ec..4647c894 100644 --- a/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp +++ b/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp @@ -325,7 +325,7 @@ HRESULT CD3D9ShaderMaterialRenderer::stubD3DXAssembleShader(LPCSTR pSrcData, if (!pFn && !LoadFailed) { // try to load dll - core::stringc strDllName = "d3dx9_"; + io::path strDllName = "d3dx9_"; strDllName += (int)D3DX_SDK_VERSION; strDllName += ".dll"; @@ -368,7 +368,7 @@ HRESULT CD3D9ShaderMaterialRenderer::stubD3DXAssembleShaderFromFile(LPCSTR pSrcF #endif // invoke static linked function - return D3DXAssembleShaderFromFile(pSrcFile, pDefines, pInclude, Flags, + return D3DXAssembleShaderFromFileA(pSrcFile, pDefines, pInclude, Flags, ppShader, ppErrorMsgs); #else { @@ -385,7 +385,7 @@ HRESULT CD3D9ShaderMaterialRenderer::stubD3DXAssembleShaderFromFile(LPCSTR pSrcF if (!pFn && !LoadFailed) { // try to load dll - core::stringc strDllName = "d3dx9_"; + io::path strDllName = "d3dx9_"; strDllName += (int)D3DX_SDK_VERSION; strDllName += ".dll"; @@ -446,7 +446,7 @@ HRESULT CD3D9ShaderMaterialRenderer::stubD3DXCompileShader(LPCSTR pSrcData, UINT if (!pFn && !LoadFailed) { // try to load dll - core::stringc strDllName = "d3dx9_"; + io::path strDllName = "d3dx9_"; strDllName += (int)D3DX_SDK_VERSION; strDllName += ".dll"; @@ -489,7 +489,7 @@ HRESULT CD3D9ShaderMaterialRenderer::stubD3DXCompileShaderFromFile(LPCSTR pSrcFi #endif // invoke static linked function - return D3DXCompileShaderFromFile(pSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); + return D3DXCompileShaderFromFileA(pSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable); #else { // try to load shader functions from the dll and print error if failed. @@ -506,7 +506,7 @@ HRESULT CD3D9ShaderMaterialRenderer::stubD3DXCompileShaderFromFile(LPCSTR pSrcFi if (!pFn && !LoadFailed) { // try to load dll - core::stringc strDllName = "d3dx9_"; + io::path strDllName = "d3dx9_"; strDllName += (int)D3DX_SDK_VERSION; strDllName += ".dll"; diff --git a/source/Irrlicht/CFileList.cpp b/source/Irrlicht/CFileList.cpp index 4a041cec..4f6be729 100644 --- a/source/Irrlicht/CFileList.cpp +++ b/source/Irrlicht/CFileList.cpp @@ -94,6 +94,12 @@ u32 CFileList::addItem(const io::path& fullPath, u32 size, bool isDirectory, u32 return Files.size() - 1; } +//! Returns the ID of a file in the file list, based on an index. +u32 CFileList::getID(u32 index) const +{ + return index < Files.size() ? Files[index].ID : 0; +} + bool CFileList::isDirectory(u32 index) const { bool ret = false; @@ -107,7 +113,7 @@ bool CFileList::isDirectory(u32 index) const //! Returns the size of a file u32 CFileList::getFileSize(u32 index) const { - return index < Files.size() ? Files[index].IsDirectory : 0; + return index < Files.size() ? Files[index].Size : 0; } diff --git a/source/Irrlicht/CFileList.h b/source/Irrlicht/CFileList.h index 72007b46..97467de0 100644 --- a/source/Irrlicht/CFileList.h +++ b/source/Irrlicht/CFileList.h @@ -80,10 +80,8 @@ public: \param id The ID of the file in the archive which owns it */ virtual u32 addItem(const io::path& fullPath, u32 size, bool isDirectory, u32 id=0); - //! Sorts the file list - void sort(); - - // IFileList methods + //! Sorts the file list. You should call this after adding any items to the file list + virtual void sort(); //! Returns the amount of files in the filelist. virtual u32 getFileCount() const; @@ -94,6 +92,9 @@ public: //! Gets the full name of a file in the list, path included, based on an index. virtual const io::path& getFullFileName(u32 index) const; + //! Returns the ID of a file in the file list, based on an index. + virtual u32 getID(u32 index) const; + //! Returns true if the file is a directory virtual bool isDirectory(u32 index) const; diff --git a/source/Irrlicht/CFileSystem.cpp b/source/Irrlicht/CFileSystem.cpp index 04d24636..e2e3e2dd 100644 --- a/source/Irrlicht/CFileSystem.cpp +++ b/source/Irrlicht/CFileSystem.cpp @@ -24,8 +24,8 @@ #if defined (_IRR_WINDOWS_API_) #if !defined ( _WIN32_WCE ) #include // for _chdir + #include // for _access #endif - #include // for _access #else #if (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) #include @@ -438,7 +438,7 @@ io::path CFileSystem::getAbsolutePath(const io::path& filename) const #elif defined(_IRR_WINDOWS_API_) #if defined(_IRR_WCHAR_FILESYSTEM ) - c16 fpath[_MAX_PATH]; + wchar_t fpath[_MAX_PATH]; p = _wfullpath(fpath, filename.c_str(), _MAX_PATH); #else c8 fpath[_MAX_PATH]; @@ -689,6 +689,13 @@ IFileList* CFileSystem::createFileList() return r; } +//! Creates an empty filelist +IFileList* CFileSystem::createEmptyFileList(const io::path& path, bool ignoreCase, bool ignorePaths) +{ + return new CFileList(path, ignoreCase, ignorePaths); +} + + //! determines if a file exists and would be able to be opened. bool CFileSystem::existFile(const io::path& filename) const { @@ -696,14 +703,31 @@ bool CFileSystem::existFile(const io::path& filename) const if (FileArchives[i]->getFileList()->findFile(filename)!=-1) return true; +#if defined(_IRR_WINDOWS_CE_PLATFORM_) +#if defined(_IRR_WCHAR_FILESYSTEM) + HANDLE hFile = CreateFileW(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); +#else + HANDLE hFile = CreateFileA(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); +#endif + if (hFile == INVALID_HANDLE_VALUE) + return false; + else + { + CloseHandle(hFile); + return true; + } +#else _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; +#if defined(_MSC_VER) #if defined(_IRR_WCHAR_FILESYSTEM) return (_waccess(filename.c_str(), 0) != -1); -#elif defined(_MSC_VER) +#else return (_access(filename.c_str(), 0) != -1); +#endif #else return (access(filename.c_str(), F_OK) != -1); #endif +#endif } diff --git a/source/Irrlicht/CFileSystem.h b/source/Irrlicht/CFileSystem.h index 48f8e15f..79e25809 100644 --- a/source/Irrlicht/CFileSystem.h +++ b/source/Irrlicht/CFileSystem.h @@ -96,6 +96,9 @@ public: //! and returns it. virtual IFileList* createFileList(); + //! Creates an empty filelist + virtual IFileList* createEmptyFileList(const io::path& path, bool ignoreCase, bool ignorePaths); + //! determines if a file exists and would be able to be opened. virtual bool existFile(const io::path& filename) const; diff --git a/source/Irrlicht/CGUIColorSelectDialog.cpp b/source/Irrlicht/CGUIColorSelectDialog.cpp index 96904fa7..e8cb0f46 100644 --- a/source/Irrlicht/CGUIColorSelectDialog.cpp +++ b/source/Irrlicht/CGUIColorSelectDialog.cpp @@ -131,6 +131,8 @@ CGUIColorSelectDialog::CGUIColorSelectDialog(const wchar_t* title, IGUIEnvironme } SBatteryItem item; + item.Incoming=0.f; + item.Outgoing=0.f; r.UpperLeftCorner.X = Template[i].x + 15; r.UpperLeftCorner.Y = Template[i].y; @@ -218,7 +220,7 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d & dim, const f32 r = sqrtf((f32) r2); // normalize, dotproduct = xnorm - const f32 xn = -p.X * core::reciprocal(r); + const f32 xn = r == 0.f ? 0.f : -p.X * core::reciprocal(r); hsl.Hue = acosf(xn); if ( p.Y > 0 ) diff --git a/source/Irrlicht/CGUIContextMenu.cpp b/source/Irrlicht/CGUIContextMenu.cpp index 36323c08..37812452 100644 --- a/source/Irrlicht/CGUIContextMenu.cpp +++ b/source/Irrlicht/CGUIContextMenu.cpp @@ -24,7 +24,7 @@ CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle, bool getFocus, bool allowFocus) : IGUIContextMenu(environment, parent, id, rectangle), EventParent(0), LastFont(0), - HighLighted(-1), ChangeTime(0), AllowFocus(allowFocus) + CloseHandling(ECMC_REMOVE), HighLighted(-1), ChangeTime(0), AllowFocus(allowFocus) { #ifdef _DEBUG setDebugName("CGUIContextMenu"); @@ -51,6 +51,17 @@ CGUIContextMenu::~CGUIContextMenu() LastFont->drop(); } +//! set behaviour when menus are closed +void CGUIContextMenu::setCloseHandling(ECONTEXT_MENU_CLOSE onClose) +{ + CloseHandling = onClose; +} + +//! get current behaviour when the menue will be closed +ECONTEXT_MENU_CLOSE CGUIContextMenu::getCloseHandling() const +{ + return CloseHandling; +} //! Returns amount of menu items u32 CGUIContextMenu::getItemCount() const @@ -60,29 +71,57 @@ u32 CGUIContextMenu::getItemCount() const //! Adds a menu item. -u32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool hasSubMenu, bool checked) +u32 CGUIContextMenu::addItem(const wchar_t* text, s32 commandId, bool enabled, bool hasSubMenu, bool checked, bool autoChecking) +{ + return insertItem(Items.size(), text, commandId, enabled, hasSubMenu, checked, autoChecking); +} + +//! Insert a menu item at specified position. +u32 CGUIContextMenu::insertItem(u32 idx, const wchar_t* text, s32 commandId, bool enabled, + bool hasSubMenu, bool checked, bool autoChecking) { SItem s; s.Enabled = enabled; s.Checked = checked; + s.AutoChecking = autoChecking; s.Text = text; s.IsSeparator = (text == 0); s.SubMenu = 0; - s.CommandId = id; + s.CommandId = commandId; if (hasSubMenu) { - s.SubMenu = new CGUIContextMenu(Environment, this, id, + s.SubMenu = new CGUIContextMenu(Environment, this, commandId, core::rect(0,0,100,100), false, false); s.SubMenu->setVisible(false); } - Items.push_back(s); + u32 result = idx; + if ( idx < Items.size() ) + { + Items.insert(s, idx); + } + else + { + Items.push_back(s); + result = Items.size() - 1; + } recalculateSize(); - return Items.size() - 1; + return result; } +s32 CGUIContextMenu::findItemWithCommandId(s32 commandId, u32 idxStartSearch) const +{ + for ( u32 i=idxStartSearch; i= Items.size()) + return; + + Items[idx].AutoChecking = autoChecking; +} + +//! does the element change the checked status on clicking +bool CGUIContextMenu::getItemAutoChecking(u32 idx) const +{ + if (idx >= Items.size()) + return false; + + return Items[idx].AutoChecking; +} + //! Returns if a menu item is enabled bool CGUIContextMenu::isItemEnabled(u32 idx) const @@ -231,8 +288,17 @@ bool CGUIContextMenu::OnEvent(const SEvent& event) if (event.GUIEvent.Caller == this && !isMyChild(event.GUIEvent.Element) && AllowFocus) { // set event parent of submenus - setEventParent(Parent); - remove(); + setEventParent(EventParent ? EventParent : Parent); + + if ( CloseHandling & ECMC_HIDE ) + { + setVisible(false); + } + if ( CloseHandling & ECMC_REMOVE ) + { + remove(); + } + return false; } break; @@ -326,16 +392,20 @@ u32 CGUIContextMenu::sendClick(const core::position2d& p) Items[HighLighted].SubMenu) return 2; + if ( Items[HighLighted].AutoChecking ) + { + Items[HighLighted].Checked = Items[HighLighted].Checked ? false : true; + } + SEvent event; event.EventType = EET_GUI_EVENT; event.GUIEvent.Caller = this; event.GUIEvent.Element = 0; event.GUIEvent.EventType = EGET_MENU_ITEM_SELECTED; - if (Parent) - Parent->OnEvent(event); - else if (EventParent) - EventParent->OnEvent(event); + EventParent->OnEvent(event); + else if (Parent) + Parent->OnEvent(event); return 1; } @@ -644,6 +714,8 @@ void CGUIContextMenu::serializeAttributes(io::IAttributes* out, io::SAttributeRe out->addInt("ParentItem", i); } + out->addInt("CloseHandling", (s32)CloseHandling); + // write out the item list out->addInt("ItemCount", Items.size()); @@ -662,6 +734,10 @@ void CGUIContextMenu::serializeAttributes(io::IAttributes* out, io::SAttributeRe out->addInt(tmp.c_str(), Items[i].CommandId); tmp = "Enabled"; tmp += i; out->addBool(tmp.c_str(), Items[i].Enabled); + tmp = "Checked"; tmp += i; + out->addBool(tmp.c_str(), Items[i].Checked); + tmp = "AutoChecking"; tmp += i; + out->addBool(tmp.c_str(), Items[i].AutoChecking); } } } @@ -678,6 +754,7 @@ void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeR if (Parent && ( Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) ) ((CGUIContextMenu*)Parent)->setSubMenu(in->getAttributeAsInt("ParentItem"),this); + CloseHandling = (ECONTEXT_MENU_CLOSE)in->getAttributeAsInt("CloseHandling"); removeAllItems(); @@ -688,28 +765,37 @@ void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeR { core::stringc tmp; core::stringw txt; - s32 commandid; - bool enabled; - bool checked; + s32 commandid=-1; + bool enabled=true; + bool checked=false; + bool autochecking=false; tmp = "IsSeparator"; tmp += i; - if ( in->getAttributeAsBool(tmp.c_str()) ) + if ( in->existsAttribute(tmp.c_str()) && in->getAttributeAsBool(tmp.c_str()) ) addSeparator(); else { tmp = "Text"; tmp += i; - txt = in->getAttributeAsStringW(tmp.c_str()); + if ( in->existsAttribute(tmp.c_str()) ) + txt = in->getAttributeAsStringW(tmp.c_str()); tmp = "CommandID"; tmp += i; - commandid = in->getAttributeAsInt(tmp.c_str()); + if ( in->existsAttribute(tmp.c_str()) ) + commandid = in->getAttributeAsInt(tmp.c_str()); tmp = "Enabled"; tmp += i; - enabled = in->getAttributeAsBool(tmp.c_str()); + if ( in->existsAttribute(tmp.c_str()) ) + enabled = in->getAttributeAsBool(tmp.c_str()); tmp = "Checked"; tmp += i; - checked = in->getAttributeAsBool(tmp.c_str()); + if ( in->existsAttribute(tmp.c_str()) ) + checked = in->getAttributeAsBool(tmp.c_str()); - addItem(core::stringw(txt.c_str()).c_str(), commandid, enabled, false, checked); + tmp = "AutoChecking"; tmp += i; + if ( in->existsAttribute(tmp.c_str()) ) + autochecking = in->getAttributeAsBool(tmp.c_str()); + + addItem(core::stringw(txt.c_str()).c_str(), commandid, enabled, false, checked, autochecking); } } diff --git a/source/Irrlicht/CGUIContextMenu.h b/source/Irrlicht/CGUIContextMenu.h index a71dc12d..e78e64d0 100644 --- a/source/Irrlicht/CGUIContextMenu.h +++ b/source/Irrlicht/CGUIContextMenu.h @@ -31,12 +31,25 @@ namespace gui //! destructor virtual ~CGUIContextMenu(); + //! set behaviour when menus are closed + virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose); + + //! get current behaviour when the menue will be closed + virtual ECONTEXT_MENU_CLOSE getCloseHandling() const; + //! Returns amount of menu items virtual u32 getItemCount() const; //! Adds a menu item. virtual u32 addItem(const wchar_t* text, s32 commandid, - bool enabled, bool hasSubMenu, bool checked); + bool enabled, bool hasSubMenu, bool checked, bool autoChecking); + + //! Insert a menu item at specified position. + virtual u32 insertItem(u32 idx, const wchar_t* text, s32 commandId, bool enabled, + bool hasSubMenu, bool checked, bool autoChecking); + + //! Find a item which has the given CommandId starting from given index + virtual s32 findItemWithCommandId(s32 commandId, u32 idxStartSearch) const; //! Adds a separator item to the menu virtual void addSeparator(); @@ -81,6 +94,12 @@ namespace gui //! Sets the visible state of this element. virtual void setVisible(bool visible); + //! should the element change the checked status on clicking + virtual void setItemAutoChecking(u32 idx, bool autoChecking); + + //! does the element change the checked status on clicking + virtual bool getItemAutoChecking(u32 idx) const; + //! Returns command id of a menu item virtual s32 getItemCommandId(u32 idx) const; @@ -90,6 +109,9 @@ namespace gui //! Adds a sub menu from an element that already exists. virtual void setSubMenu(u32 index, CGUIContextMenu* menu); + //! When an eventparent is set it receives events instead of the usual parent element + virtual void setEventParent(IGUIElement *parent); + //! Writes attributes of the element. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; @@ -107,6 +129,7 @@ namespace gui bool IsSeparator; bool Enabled; bool Checked; + bool AutoChecking; core::dimension2d Dim; s32 PosY; CGUIContextMenu* SubMenu; @@ -130,12 +153,12 @@ namespace gui //! Gets drawing rect of Item virtual core::rect getRect(const SItem& i, const core::rect& absolute) const; - void setEventParent(IGUIElement *parent); core::array Items; core::position2d Pos; IGUIElement* EventParent; IGUIFont *LastFont; + ECONTEXT_MENU_CLOSE CloseHandling; s32 HighLighted; u32 ChangeTime; bool AllowFocus; diff --git a/source/Irrlicht/CGUIEnvironment.cpp b/source/Irrlicht/CGUIEnvironment.cpp index 1d61e4a0..97e43b92 100644 --- a/source/Irrlicht/CGUIEnvironment.cpp +++ b/source/Irrlicht/CGUIEnvironment.cpp @@ -978,7 +978,7 @@ IGUIElement* CGUIEnvironment::addModalScreen(IGUIElement* parent) //! Adds a message box. IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t* text, - bool modal, s32 flag, IGUIElement* parent, s32 id) + bool modal, s32 flag, IGUIElement* parent, s32 id, video::ITexture* image) { if (!CurrentSkin) return 0; @@ -990,8 +990,8 @@ IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t screenDim.Width = parent->getAbsolutePosition().getWidth(); screenDim.Height = parent->getAbsolutePosition().getHeight(); - msgBoxDim.Width = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_WIDTH); - msgBoxDim.Height = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_HEIGHT); + msgBoxDim.Width = 2; + msgBoxDim.Height = 2; rect.UpperLeftCorner.X = (screenDim.Width - msgBoxDim.Width) / 2; rect.UpperLeftCorner.Y = (screenDim.Height - msgBoxDim.Height) / 2; @@ -1005,7 +1005,7 @@ IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t } IGUIWindow* win = new CGUIMessageBox(this, caption, text, flag, - parent, id, rect); + parent, id, rect, image); win->drop(); return win; diff --git a/source/Irrlicht/CGUIEnvironment.h b/source/Irrlicht/CGUIEnvironment.h index ba0deab4..c307ac98 100644 --- a/source/Irrlicht/CGUIEnvironment.h +++ b/source/Irrlicht/CGUIEnvironment.h @@ -96,7 +96,7 @@ public: //! Adds a message box. virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, - bool modal = true, s32 flag = EMBF_OK, IGUIElement* parent=0, s32 id=-1); + bool modal = true, s32 flag = EMBF_OK, IGUIElement* parent=0, s32 id=-1, video::ITexture* image=0); //! adds a scrollbar. The returned pointer must not be dropped. virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect& rectangle, diff --git a/source/Irrlicht/CGUIFileOpenDialog.cpp b/source/Irrlicht/CGUIFileOpenDialog.cpp index 34bbb19c..38f33ff3 100644 --- a/source/Irrlicht/CGUIFileOpenDialog.cpp +++ b/source/Irrlicht/CGUIFileOpenDialog.cpp @@ -327,7 +327,9 @@ void CGUIFileOpenDialog::fillListBox() FileList = FileSystem->createFileList(); core::stringw s; +#if !defined(_IRR_WINDOWS_CE_PLATFORM_) setlocale(LC_ALL,""); +#endif if (FileList) { @@ -339,7 +341,7 @@ void CGUIFileOpenDialog::fillListBox() int len = mbstowcs(ws,cs,strlen(cs)); ws[len] = 0; s = ws; - delete ws; + delete [] ws; #else s = FileList->getFileName(i).c_str(); #endif diff --git a/source/Irrlicht/CGUIMessageBox.cpp b/source/Irrlicht/CGUIMessageBox.cpp index 4f76a26a..d9ec6940 100644 --- a/source/Irrlicht/CGUIMessageBox.cpp +++ b/source/Irrlicht/CGUIMessageBox.cpp @@ -9,6 +9,7 @@ #include "IGUIEnvironment.h" #include "IGUIButton.h" #include "IGUIFont.h" +#include "ITexture.h" namespace irr { @@ -18,9 +19,10 @@ namespace gui //! constructor CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption, const wchar_t* text, s32 flags, - IGUIElement* parent, s32 id, core::rect rectangle) + IGUIElement* parent, s32 id, core::rect rectangle, video::ITexture* image) : CGUIWindow(environment, parent, id, rectangle), OkButton(0), CancelButton(0), YesButton(0), NoButton(0), StaticText(0), + Icon(0), IconTexture(image), Flags(flags), MessageText(text), Pressed(false) { #ifdef _DEBUG @@ -43,6 +45,9 @@ CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* capt Environment->setFocus(this); + if ( IconTexture ) + IconTexture->grab(); + refreshControls(); } @@ -64,62 +69,134 @@ CGUIMessageBox::~CGUIMessageBox() if (NoButton) NoButton->drop(); + + if (Icon) + Icon->drop(); + + if ( IconTexture ) + IconTexture->drop(); } +void CGUIMessageBox::setButton(IGUIButton*& button, bool isAvailable, const core::rect & btnRect, const wchar_t * text, IGUIElement*& focusMe) +{ + // add/remove ok button + if (isAvailable) + { + if (!button) + { + button = Environment->addButton(btnRect, this); + button->setSubElement(true); + button->grab(); + } + else + button->setRelativePosition(btnRect); + + button->setText(text); + + focusMe = button; + } + else if (button) + { + button->drop(); + button->remove(); + button =0; + } +} void CGUIMessageBox::refreshControls() { + // Layout can be seen as 4 boxes (a layoutmanager would be nice) + // One box at top over the whole width for title + // Two boxes with same height at the middle beside each other for icon and for text + // One box at the bottom for the buttons + const IGUISkin* skin = Environment->getSkin(); - IGUIElement* focusMe = 0; const s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT); const s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH); - const s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2; + const s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2; // titlebar has no own constant const s32 buttonDistance = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); + const s32 borderWidth = skin->getSize(EGDS_MESSAGE_BOX_GAP_SPACE); - // add static multiline text - - core::dimension2d dim(AbsoluteClippingRect.getWidth() - buttonWidth, - AbsoluteClippingRect.getHeight() - (buttonHeight * 2)); - const core::position2d pos((AbsoluteClippingRect.getWidth() - dim.Width) / 2, - buttonHeight / 2 + titleHeight); - + // add the static text for the message + core::rect staticRect; + staticRect.UpperLeftCorner.X = borderWidth; + staticRect.UpperLeftCorner.Y = titleHeight + borderWidth; + staticRect.LowerRightCorner.X = staticRect.UpperLeftCorner.X + skin->getSize(EGDS_MESSAGE_BOX_MAX_TEST_WIDTH); + staticRect.LowerRightCorner.Y = staticRect.UpperLeftCorner.Y + skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT); if (!StaticText) { - StaticText = Environment->addStaticText(MessageText.c_str(), - core::rect(pos, dim), false, false, this); + StaticText = Environment->addStaticText(MessageText.c_str(), staticRect, false, false, this); + StaticText->setWordWrap(true); StaticText->setSubElement(true); StaticText->grab(); } else { - StaticText->setRelativePosition(core::rect(pos, dim)); + StaticText->setRelativePosition(staticRect); StaticText->setText(MessageText.c_str()); } - // adjust static text height + s32 textHeight = StaticText->getTextHeight(); + s32 textWidth = StaticText->getTextWidth() + 6; // +6 because the static itself needs that + const s32 iconHeight = IconTexture ? IconTexture->getOriginalSize().Height : 0; - const s32 textHeight = StaticText->getTextHeight(); - core::rect tmp = StaticText->getRelativePosition(); - tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + textHeight; - StaticText->setRelativePosition(tmp); - dim.Height = dim.Height - buttonHeight < tmp.getHeight() ? tmp.getHeight() : dim.Height - buttonHeight; + if ( textWidth < skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH) ) + textWidth = skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH) + 6; + // no neeed to check for max because it couldn't get larger due to statictextbox. + if ( textHeight < skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT) ) + textHeight = skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT); + if ( textHeight > skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT) ) + textHeight = skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT); - // adjust message box height if required + // content is text + icons + borders (but not titlebar) + s32 contentHeight = textHeight > iconHeight ? textHeight : iconHeight; + contentHeight += borderWidth; + s32 contentWidth = 0; - tmp = getRelativePosition(); - s32 msgBoxHeight = textHeight + core::floor32(2.5f * buttonHeight) + titleHeight; - msgBoxHeight = tmp.getHeight() < msgBoxHeight ? msgBoxHeight : tmp.getHeight(); + // add icon + if ( IconTexture ) + { + core::position2d iconPos; + iconPos.Y = titleHeight + borderWidth; + if ( iconHeight < textHeight ) + iconPos.Y += (textHeight-iconHeight) / 2; + iconPos.X = borderWidth; - // adjust message box position + if (!Icon) + { + Icon = Environment->addImage(IconTexture, iconPos, true, this); + Icon->setSubElement(true); + Icon->grab(); + } + else + { + core::rect iconRect( iconPos.X, iconPos.Y, iconPos.X + IconTexture->getOriginalSize().Width, iconPos.Y + IconTexture->getOriginalSize().Height ); + Icon->setRelativePosition(iconRect); + } - tmp.UpperLeftCorner.Y = (Parent->getAbsolutePosition().getHeight() - msgBoxHeight) / 2; - tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + msgBoxHeight; - setRelativePosition(tmp); + contentWidth += borderWidth + IconTexture->getOriginalSize().Width; + } + else if ( Icon ) + { + Icon->drop(); + Icon->remove(); + Icon = 0; + } - // add buttons + // position text + core::rect textRect; + textRect.UpperLeftCorner.X = contentWidth + borderWidth; + textRect.UpperLeftCorner.Y = titleHeight + borderWidth; + if ( textHeight < iconHeight ) + textRect.UpperLeftCorner.Y += (iconHeight-textHeight) / 2; + textRect.LowerRightCorner.X = textRect.UpperLeftCorner.X + textWidth; + textRect.LowerRightCorner.Y = textRect.UpperLeftCorner.Y + textHeight; + contentWidth += 2*borderWidth + textWidth; + StaticText->setRelativePosition( textRect ); + // find out button size needs s32 countButtons = 0; if (Flags & EMBF_OK) ++countButtons; @@ -130,123 +207,44 @@ void CGUIMessageBox::refreshControls() if (Flags & EMBF_NO) ++countButtons; + s32 buttonBoxWidth = countButtons * buttonWidth + 2 * borderWidth; + if ( countButtons > 1 ) + buttonBoxWidth += (countButtons-1) * buttonDistance; + s32 buttonBoxHeight = buttonHeight + 2 * borderWidth; + + // calc new message box sizes + core::rect tmp = getRelativePosition(); + s32 msgBoxHeight = titleHeight + contentHeight + buttonBoxHeight; + s32 msgBoxWidth = contentWidth > buttonBoxWidth ? contentWidth : buttonBoxWidth; + + // adjust message box position + tmp.UpperLeftCorner.Y = (Parent->getAbsolutePosition().getHeight() - msgBoxHeight) / 2; + tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + msgBoxHeight; + tmp.UpperLeftCorner.X = (Parent->getAbsolutePosition().getWidth() - msgBoxWidth) / 2; + tmp.LowerRightCorner.X = tmp.UpperLeftCorner.X + msgBoxWidth; + setRelativePosition(tmp); + + // add buttons + core::rect btnRect; - btnRect.UpperLeftCorner.Y = pos.Y + dim.Height + buttonHeight / 2; + btnRect.UpperLeftCorner.Y = titleHeight + contentHeight + borderWidth; btnRect.LowerRightCorner.Y = btnRect.UpperLeftCorner.Y + buttonHeight; - btnRect.UpperLeftCorner.X = (AbsoluteClippingRect.getWidth() - - (buttonWidth*countButtons + (buttonDistance*countButtons+1))) / 2 + - buttonDistance / 2; + btnRect.UpperLeftCorner.X = borderWidth; + if ( contentWidth > buttonBoxWidth ) + btnRect.UpperLeftCorner.X += (contentWidth - buttonBoxWidth) / 2; // center buttons btnRect.LowerRightCorner.X = btnRect.UpperLeftCorner.X + buttonWidth; - // add/remove ok button - if (Flags & EMBF_OK) - { - if (!OkButton) - { - OkButton = Environment->addButton(btnRect, this); - OkButton->setSubElement(true); - OkButton->grab(); - } - else - OkButton->setRelativePosition(btnRect); - - OkButton->setText(skin->getDefaultText(EGDT_MSG_BOX_OK)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - - focusMe = OkButton; - } - else if (OkButton) - { - OkButton->drop(); - OkButton->remove(); - OkButton = 0; - } - - // add cancel button - if (Flags & EMBF_CANCEL) - { - if (!CancelButton) - { - CancelButton = Environment->addButton(btnRect, this); - CancelButton->setSubElement(true); - CancelButton->grab(); - } - else - CancelButton->setRelativePosition(btnRect); - - CancelButton->setText(skin->getDefaultText(EGDT_MSG_BOX_CANCEL)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - - if (!focusMe) - focusMe = CancelButton; - - } - else if (CancelButton) - { - CancelButton->drop(); - CancelButton->remove(); - CancelButton = 0; - } - - - // add/remove yes button - if (Flags & EMBF_YES) - { - if (!YesButton) - { - YesButton = Environment->addButton(btnRect, this); - YesButton->setSubElement(true); - YesButton->grab(); - } - else - YesButton->setRelativePosition(btnRect); - - YesButton->setText(skin->getDefaultText(EGDT_MSG_BOX_YES)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - - if (!focusMe) - focusMe = YesButton; - } - else if (YesButton) - { - YesButton->drop(); - YesButton->remove(); - YesButton = 0; - } - - // add no button - if (Flags & EMBF_NO) - { - if (!NoButton) - { - NoButton = Environment->addButton(btnRect, this); - NoButton->setSubElement(true); - NoButton->grab(); - } - else - NoButton->setRelativePosition(btnRect); - - NoButton->setText(skin->getDefaultText(EGDT_MSG_BOX_NO)); - - btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; - btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; - - if (!focusMe) - focusMe = NoButton; - - } - else if (NoButton) - { - NoButton->drop(); - NoButton->remove(); - NoButton = 0; - } + IGUIElement* focusMe = 0; + setButton(OkButton, (Flags & EMBF_OK) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_OK), focusMe); + if ( Flags & EMBF_OK ) + btnRect += core::position2d(buttonWidth + buttonDistance, 0); + setButton(CancelButton, (Flags & EMBF_CANCEL) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_CANCEL), focusMe); + if ( Flags & EMBF_CANCEL ) + btnRect += core::position2d(buttonWidth + buttonDistance, 0); + setButton(YesButton, (Flags & EMBF_YES) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_YES), focusMe); + if ( Flags & EMBF_YES ) + btnRect += core::position2d(buttonWidth + buttonDistance, 0); + setButton(NoButton, (Flags & EMBF_NO) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_NO), focusMe); if (Environment->hasFocus(this) && focusMe) Environment->setFocus(focusMe); @@ -409,6 +407,7 @@ void CGUIMessageBox::serializeAttributes(io::IAttributes* out, io::SAttributeRea out->addBool ("CancelButton", (Flags & EMBF_CANCEL) != 0 ); out->addBool ("YesButton", (Flags & EMBF_YES) != 0 ); out->addBool ("NoButton", (Flags & EMBF_NO) != 0 ); + out->addTexture ("Texture", IconTexture); out->addString ("MessageText", MessageText.c_str()); } @@ -424,6 +423,15 @@ void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeRe Flags |= in->getAttributeAsBool("YesButton") ? EMBF_YES : 0; Flags |= in->getAttributeAsBool("NoButton") ? EMBF_NO : 0; + if ( IconTexture ) + { + IconTexture->drop(); + IconTexture = NULL; + } + IconTexture = in->getAttributeAsTexture("Texture"); + if ( IconTexture ) + IconTexture->grab(); + MessageText = in->getAttributeAsStringW("MessageText").c_str(); CGUIWindow::deserializeAttributes(in,options); diff --git a/source/Irrlicht/CGUIMessageBox.h b/source/Irrlicht/CGUIMessageBox.h index 5686e028..3885c8c8 100644 --- a/source/Irrlicht/CGUIMessageBox.h +++ b/source/Irrlicht/CGUIMessageBox.h @@ -10,6 +10,7 @@ #include "CGUIWindow.h" #include "IGUIStaticText.h" +#include "IGUIImage.h" #include "irrArray.h" namespace irr @@ -23,7 +24,7 @@ namespace gui //! constructor CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption, const wchar_t* text, s32 flag, - IGUIElement* parent, s32 id, core::rect rectangle); + IGUIElement* parent, s32 id, core::rect rectangle, video::ITexture* image=0); //! destructor virtual ~CGUIMessageBox(); @@ -40,12 +41,15 @@ namespace gui private: void refreshControls(); + void setButton(IGUIButton*& button, bool isAvailable, const core::rect & btnRect, const wchar_t * text, IGUIElement*& focusMe); IGUIButton* OkButton; IGUIButton* CancelButton; IGUIButton* YesButton; IGUIButton* NoButton; IGUIStaticText* StaticText; + IGUIImage * Icon; + video::ITexture * IconTexture; s32 Flags; core::stringw MessageText; diff --git a/source/Irrlicht/CGUISkin.cpp b/source/Irrlicht/CGUISkin.cpp index 0a700db4..024b472c 100644 --- a/source/Irrlicht/CGUISkin.cpp +++ b/source/Irrlicht/CGUISkin.cpp @@ -104,6 +104,12 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver) Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 2; } + Sizes[EGDS_MESSAGE_BOX_GAP_SPACE] = 15; + Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH] = 0; + Sizes[EGDS_MESSAGE_BOX_MAX_TEST_WIDTH] = 500; + Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT] = 0; + Sizes[EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT] = 99999; + Texts[EGDT_MSG_BOX_OK] = L"OK"; Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel"; Texts[EGDT_MSG_BOX_YES] = L"Yes"; diff --git a/source/Irrlicht/CGUIToolBar.cpp b/source/Irrlicht/CGUIToolBar.cpp index 9c7c4e1a..d2b9a54a 100644 --- a/source/Irrlicht/CGUIToolBar.cpp +++ b/source/Irrlicht/CGUIToolBar.cpp @@ -121,13 +121,27 @@ IGUIButton* CGUIToolBar::addButton(s32 id, const wchar_t* text,const wchar_t* to { ButtonX += 3; - core::rect rectangle(ButtonX,2,0,0); + core::rect rectangle(ButtonX,2,ButtonX+1,3); if ( img ) { const core::dimension2du &size = img->getOriginalSize(); rectangle.LowerRightCorner.X = rectangle.UpperLeftCorner.X + size.Width + 8; rectangle.LowerRightCorner.Y = rectangle.UpperLeftCorner.Y + size.Height + 6; } + + if ( text ) + { + IGUISkin* skin = Environment->getSkin(); + IGUIFont * font = skin->getFont(EGDF_BUTTON); + if ( font ) + { + core::dimension2d dim = font->getDimension(text); + if ( (s32)dim.Width > rectangle.getWidth() ) + rectangle.LowerRightCorner.X = rectangle.UpperLeftCorner.X + dim.Width + 8; + if ( (s32)dim.Height > rectangle.getHeight() ) + rectangle.LowerRightCorner.Y = rectangle.UpperLeftCorner.Y + dim.Height + 6; + } + } ButtonX += rectangle.getWidth(); diff --git a/source/Irrlicht/CIrrDeviceConsole.cpp b/source/Irrlicht/CIrrDeviceConsole.cpp index 4e817fa1..984fa802 100644 --- a/source/Irrlicht/CIrrDeviceConsole.cpp +++ b/source/Irrlicht/CIrrDeviceConsole.cpp @@ -38,7 +38,7 @@ BOOL WINAPI ConsoleHandler(DWORD CEvent) DeviceToClose->closeDevice(); return TRUE; } -#else +#elif defined(_IRR_POSIX_API_) // sigterm handler #include @@ -64,7 +64,7 @@ const u16 ASCIIArtCharsCount = 32; //! constructor CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params) - : CIrrDeviceStub(params), IsDeviceRunning(true), IsWindowFocused(true), ConsoleFont(0), OutFile(stdout) + : CIrrDeviceStub(params), IsWindowFocused(true), ConsoleFont(0), OutFile(stdout) { DeviceToClose = this; @@ -94,9 +94,9 @@ CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params) // catch windows close/break signals SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE); -#else +#elif defined(_IRR_POSIX_API_) // catch other signals - signal(SIGABRT, &sighandler); + signal(SIGABRT, &sighandler); signal(SIGTERM, &sighandler); signal(SIGINT, &sighandler); @@ -305,7 +305,7 @@ bool CIrrDeviceConsole::run() // todo: keyboard input from terminal in raw mode #endif - return IsDeviceRunning; + return !Close; } //! Cause the device to temporarily pause execution and let other processes to run @@ -346,8 +346,7 @@ void CIrrDeviceConsole::sleep(u32 timeMs, bool pauseTimer) void CIrrDeviceConsole::setWindowCaption(const wchar_t* text) { #ifdef _IRR_WINDOWS_NT_CONSOLE_ - core::stringc txt(text); - SetConsoleTitle(txt.c_str()); + SetConsoleTitleW(text); #endif } @@ -413,7 +412,7 @@ bool CIrrDeviceConsole::present(video::IImage* surface, void* windowId, core::re void CIrrDeviceConsole::closeDevice() { // return false next time we run() - IsDeviceRunning = false; + Close = true; } diff --git a/source/Irrlicht/CIrrDeviceConsole.h b/source/Irrlicht/CIrrDeviceConsole.h index 557800ce..6177e7c8 100644 --- a/source/Irrlicht/CIrrDeviceConsole.h +++ b/source/Irrlicht/CIrrDeviceConsole.h @@ -223,8 +223,7 @@ namespace irr core::stringc Text; }; - bool IsDeviceRunning, - IsWindowFocused; + bool IsWindowFocused; core::array OutputBuffer; gui::IGUIFont *ConsoleFont; @@ -328,3 +327,4 @@ namespace gui #endif // _IRR_COMPILE_WITH_CONSOLE_DEVICE_ #endif // __C_IRR_DEVICE_CONSOLE_H_INCLUDED__ + diff --git a/source/Irrlicht/CIrrDeviceLinux.cpp b/source/Irrlicht/CIrrDeviceLinux.cpp index 4e67c8a8..bcf66ba0 100644 --- a/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/source/Irrlicht/CIrrDeviceLinux.cpp @@ -26,6 +26,10 @@ #include #include +#ifdef __FREE_BSD_ +#include +#else + // linux/joystick.h includes linux/input.h, which #defines values for various KEY_FOO keys. // These override the irr::KEY_FOO equivalents, which stops key handling from working. // As a workaround, defining _INPUT_H stops linux/input.h from being included; it @@ -34,6 +38,8 @@ #include // Would normally be included in linux/input.h #include #undef _INPUT_H +#endif + #endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ namespace irr @@ -73,7 +79,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param) #endif #endif Width(param.WindowSize.Width), Height(param.WindowSize.Height), - Close(false), WindowHasFocus(false), WindowMinimized(false), + WindowHasFocus(false), WindowMinimized(false), UseXVidMode(false), UseXRandR(false), UseGLXWindow(false), ExternalWindow(false), AutorepeatSupport(0) { @@ -128,6 +134,8 @@ CIrrDeviceLinux::~CIrrDeviceLinux() #ifdef _IRR_COMPILE_WITH_X11_ if (StdHints) XFree(StdHints); + // Disable cursor and free it later on + CursorControl->setVisible(false); if (display) { #ifdef _IRR_COMPILE_WITH_OPENGL_ @@ -149,21 +157,8 @@ CIrrDeviceLinux::~CIrrDeviceLinux() } #endif // #ifdef _IRR_COMPILE_WITH_OPENGL_ - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (UseXVidMode && CreationParams.Fullscreen) - { - XF86VidModeSwitchToMode(display, screennr, &oldVideoMode); - XF86VidModeSetViewPort(display, screennr, 0, 0); - } - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (UseXRandR && CreationParams.Fullscreen) - { - XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); - XRRSetScreenConfig(display,config,DefaultRootWindow(display),oldRandrMode,oldRandrRotation,CurrentTime); - XRRFreeScreenConfigInfo(config); - } - #endif + // Reset fullscreen resolution change + switchToFullscreen(true); if (SoftwareImage) XDestroyImage(SoftwareImage); @@ -207,6 +202,109 @@ int IrrPrintXError(Display *display, XErrorEvent *event) #endif +bool CIrrDeviceLinux::switchToFullscreen(bool reset) +{ + if (!CreationParams.Fullscreen) + return true; + if (reset) + { +#ifdef _IRR_LINUX_X11_VIDMODE_ + if (UseXVidMode && CreationParams.Fullscreen) + { + XF86VidModeSwitchToMode(display, screennr, &oldVideoMode); + XF86VidModeSetViewPort(display, screennr, 0, 0); + } + #endif + #ifdef _IRR_LINUX_X11_RANDR_ + if (UseXRandR && CreationParams.Fullscreen) + { + XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); + XRRSetScreenConfig(display,config,DefaultRootWindow(display),oldRandrMode,oldRandrRotation,CurrentTime); + XRRFreeScreenConfigInfo(config); + } + #endif + return true; + } + + getVideoModeList(); + #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_) + s32 eventbase, errorbase; + s32 bestMode = -1; + #endif + + #ifdef _IRR_LINUX_X11_VIDMODE_ + if (XF86VidModeQueryExtension(display, &eventbase, &errorbase)) + { + // enumerate video modes + s32 modeCount; + XF86VidModeModeInfo** modes; + + XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes); + + // find fitting mode + for (s32 i = 0; ihdisplay >= Width && modes[i]->vdisplay >= Height) + bestMode = i; + else if (bestMode!=-1 && + modes[i]->hdisplay >= Width && + modes[i]->vdisplay >= Height && + modes[i]->hdisplay < modes[bestMode]->hdisplay && + modes[i]->vdisplay < modes[bestMode]->vdisplay) + bestMode = i; + } + if (bestMode != -1) + { + os::Printer::log("Starting fullscreen mode...", ELL_INFORMATION); + XF86VidModeSwitchToMode(display, screennr, modes[bestMode]); + XF86VidModeSetViewPort(display, screennr, 0, 0); + UseXVidMode=true; + } + else + { + os::Printer::log("Could not find specified video mode, running windowed.", ELL_WARNING); + CreationParams.Fullscreen = false; + } + + XFree(modes); + } + else + #endif + #ifdef _IRR_LINUX_X11_RANDR_ + if (XRRQueryExtension(display, &eventbase, &errorbase)) + { + s32 modeCount; + XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); + XRRScreenSize *modes=XRRConfigSizes(config,&modeCount); + for (s32 i = 0; i= Width && (u32)modes[i].height >= Height) + bestMode = i; + else if (bestMode!=-1 && + (u32)modes[i].width >= Width && + (u32)modes[i].height >= Height && + modes[i].width < modes[bestMode].width && + modes[i].height < modes[bestMode].height) + bestMode = i; + } + if (bestMode != -1) + { + XRRSetScreenConfig(display,config,DefaultRootWindow(display),bestMode,oldRandrRotation,CurrentTime); + UseXRandR=true; + } + XRRFreeScreenConfigInfo(config); + } + else + #endif + { + os::Printer::log("VidMode or RandR extension must be installed to allow Irrlicht " + "to switch to fullscreen mode. Running in windowed mode instead.", ELL_WARNING); + CreationParams.Fullscreen = false; + } + return CreationParams.Fullscreen; +} + + bool CIrrDeviceLinux::createWindow() { #ifdef _IRR_COMPILE_WITH_X11_ @@ -228,86 +326,7 @@ bool CIrrDeviceLinux::createWindow() screennr = DefaultScreen(display); - // query extension - - if (CreationParams.Fullscreen) - { - getVideoModeList(); - #if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_) - s32 eventbase, errorbase; - s32 bestMode = -1; - #endif - - #ifdef _IRR_LINUX_X11_VIDMODE_ - if (XF86VidModeQueryExtension(display, &eventbase, &errorbase)) - { - // enumerate video modes - s32 modeCount; - XF86VidModeModeInfo** modes; - - XF86VidModeGetAllModeLines(display, screennr, &modeCount, &modes); - - // find fitting mode - for (s32 i = 0; ihdisplay >= Width && modes[i]->vdisplay >= Height) - bestMode = i; - else if (bestMode!=-1 && - modes[i]->hdisplay >= Width && - modes[i]->vdisplay >= Height && - modes[i]->hdisplay < modes[bestMode]->hdisplay && - modes[i]->vdisplay < modes[bestMode]->vdisplay) - bestMode = i; - } - if (bestMode != -1) - { - os::Printer::log("Starting fullscreen mode...", ELL_INFORMATION); - XF86VidModeSwitchToMode(display, screennr, modes[bestMode]); - XF86VidModeSetViewPort(display, screennr, 0, 0); - UseXVidMode=true; - } - else - { - os::Printer::log("Could not find specified video mode, running windowed.", ELL_WARNING); - CreationParams.Fullscreen = false; - } - - XFree(modes); - } - else - #endif - #ifdef _IRR_LINUX_X11_RANDR_ - if (XRRQueryExtension(display, &eventbase, &errorbase)) - { - s32 modeCount; - XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display)); - XRRScreenSize *modes=XRRConfigSizes(config,&modeCount); - for (s32 i = 0; i= Width && (u32)modes[i].height >= Height) - bestMode = i; - else if (bestMode!=-1 && - (u32)modes[i].width >= Width && - (u32)modes[i].height >= Height && - modes[i].width < modes[bestMode].width && - modes[i].height < modes[bestMode].height) - bestMode = i; - } - if (bestMode != -1) - { - XRRSetScreenConfig(display,config,DefaultRootWindow(display),bestMode,oldRandrRotation,CurrentTime); - UseXRandR=true; - } - XRRFreeScreenConfigInfo(config); - } - else - #endif - { - os::Printer::log("VidMode or RandR extension must be installed to allow Irrlicht " - "to switch to fullscreen mode. Running in windowed mode instead.", ELL_WARNING); - CreationParams.Fullscreen = false; - } - } + switchToFullscreen(); #ifdef _IRR_COMPILE_WITH_OPENGL_ @@ -563,7 +582,7 @@ bool CIrrDeviceLinux::createWindow() attributes.colormap = colormap; attributes.border_pixel = 0; - attributes.event_mask = StructureNotifyMask | FocusChangeMask; + attributes.event_mask = StructureNotifyMask | FocusChangeMask | ExposureMask; if (!CreationParams.IgnoreInput) attributes.event_mask |= PointerMotionMask | ButtonPressMask | KeyPressMask | @@ -571,44 +590,27 @@ bool CIrrDeviceLinux::createWindow() if (!CreationParams.WindowId) { - // create Window, either for Fullscreen or windowed mode + // create new Window + // Remove window manager decoration in fullscreen + attributes.override_redirect = CreationParams.Fullscreen; + window = XCreateWindow(display, + RootWindow(display, visual->screen), + 0, 0, Width, Height, 0, visual->depth, + InputOutput, visual->visual, + CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, + &attributes); + XMapRaised(display, window); + CreationParams.WindowId = (void*)window; + Atom wmDelete; + wmDelete = XInternAtom(display, wmDeleteWindow, True); + XSetWMProtocols(display, window, &wmDelete, 1); if (CreationParams.Fullscreen) { - attributes.override_redirect = True; - - window = XCreateWindow(display, - RootWindow(display, visual->screen), - 0, 0, Width, Height, 0, visual->depth, - InputOutput, visual->visual, - CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, - &attributes); - CreationParams.WindowId = (void*)window; - - XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0); - XMapRaised(display, window); XGrabKeyboard(display, window, True, GrabModeAsync, GrabModeAsync, CurrentTime); XGrabPointer(display, window, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, window, None, CurrentTime); - } - else - { // we want windowed mode - attributes.event_mask |= ExposureMask; - attributes.event_mask |= FocusChangeMask; - - window = XCreateWindow(display, - RootWindow(display, visual->screen), - 0, 0, Width, Height, 0, visual->depth, - InputOutput, visual->visual, - CWBorderPixel | CWColormap | CWEventMask, - &attributes); - - CreationParams.WindowId = (void*)window; - - Atom wmDelete; - wmDelete = XInternAtom(display, wmDeleteWindow, True); - XSetWMProtocols(display, window, &wmDelete, 1); - XMapRaised(display, window); + XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0); } } else @@ -1558,15 +1560,26 @@ bool CIrrDeviceLinux::activateJoysticks(core::array & joystickInf devName = "/dev/input/js"; devName += joystick; info.fd = open(devName.c_str(), O_RDONLY); + if(-1 == info.fd) + { + // and BSD here + devName = "/dev/joy"; + devName += joystick; + info.fd = open(devName.c_str(), O_RDONLY); + } } if(-1 == info.fd) continue; +#ifdef __FREE_BSD_ + info.axes=2; + info.buttons=2; +#else ioctl( info.fd, JSIOCGAXES, &(info.axes) ); ioctl( info.fd, JSIOCGBUTTONS, &(info.buttons) ); - fcntl( info.fd, F_SETFL, O_NONBLOCK ); +#endif (void)memset(&info.persistentData, 0, sizeof(info.persistentData)); info.persistentData.EventType = irr::EET_JOYSTICK_INPUT_EVENT; @@ -1583,9 +1596,11 @@ bool CIrrDeviceLinux::activateJoysticks(core::array & joystickInf returnInfo.Axes = info.axes; returnInfo.Buttons = info.buttons; +#ifndef __FREE_BSD_ char name[80]; ioctl( info.fd, JSIOCGNAME(80), name); returnInfo.Name = name; +#endif joystickInfo.push_back(returnInfo); } @@ -1612,11 +1627,19 @@ void CIrrDeviceLinux::pollJoysticks() if(0 == ActiveJoysticks.size()) return; - u32 joystick; - for(joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) + u32 j; + for(j= 0; j< ActiveJoysticks.size(); ++j) { - JoystickInfo & info = ActiveJoysticks[joystick]; + JoystickInfo & info = ActiveJoysticks[j]; +#ifdef __FREE_BSD_ + struct joystick js; + if( read( info.fd, &js, JS_RETURN ) == JS_RETURN ) + { + info.persistentData.JoystickEvent.ButtonStates = js.buttons; /* should be a two-bit field */ + info.persistentData.JoystickEvent.Axis[0] = js.x; /* X axis */ + info.persistentData.JoystickEvent.Axis[1] = js.y; /* Y axis */ +#else struct js_event event; while(sizeof(event) == read(info.fd, &event, sizeof(event))) { @@ -1637,6 +1660,7 @@ void CIrrDeviceLinux::pollJoysticks() break; } } +#endif // Send an irrlicht joystick event once per ::run() even if no new data were received. (void)postEventFromUser(info.persistentData); diff --git a/source/Irrlicht/CIrrDeviceLinux.h b/source/Irrlicht/CIrrDeviceLinux.h index c1973ae7..8fe330df 100644 --- a/source/Irrlicht/CIrrDeviceLinux.h +++ b/source/Irrlicht/CIrrDeviceLinux.h @@ -135,6 +135,8 @@ namespace irr void initXAtoms(); + bool switchToFullscreen(bool reset=false); + //! Implementation of the linux cursor control class CCursorControl : public gui::ICursorControl { @@ -354,7 +356,6 @@ namespace irr #endif #endif u32 Width, Height; - bool Close; bool WindowHasFocus; bool WindowMinimized; bool UseXVidMode; diff --git a/source/Irrlicht/CIrrDeviceSDL.cpp b/source/Irrlicht/CIrrDeviceSDL.cpp index 14690f0b..2ffab63f 100644 --- a/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/source/Irrlicht/CIrrDeviceSDL.cpp @@ -59,8 +59,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_ANYFORMAT), MouseX(0), MouseY(0), MouseButtonStates(0), Width(param.WindowSize.Width), Height(param.WindowSize.Height), - Close(0), Resizable(false), - WindowHasFocus(false), WindowMinimized(false) + Resizable(false), WindowHasFocus(false), WindowMinimized(false) { #ifdef _DEBUG setDebugName("CIrrDeviceSDL"); @@ -75,7 +74,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) SDL_INIT_NOPARACHUTE ) < 0) { os::Printer::log( "Unable to initialize SDL!", SDL_GetError()); - Close = 1; + Close = true; } #if defined(_IRR_WINDOWS_) diff --git a/source/Irrlicht/CIrrDeviceSDL.h b/source/Irrlicht/CIrrDeviceSDL.h index 94dd5dca..ac34e0f0 100644 --- a/source/Irrlicht/CIrrDeviceSDL.h +++ b/source/Irrlicht/CIrrDeviceSDL.h @@ -203,7 +203,6 @@ namespace irr u32 Width, Height; - bool Close; bool Resizable; bool WindowHasFocus; bool WindowMinimized; diff --git a/source/Irrlicht/CIrrDeviceStub.cpp b/source/Irrlicht/CIrrDeviceStub.cpp index f79b34bd..89630f6e 100644 --- a/source/Irrlicht/CIrrDeviceStub.cpp +++ b/source/Irrlicht/CIrrDeviceStub.cpp @@ -19,7 +19,8 @@ namespace irr CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters& params) : IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0), Timer(0), CursorControl(0), UserReceiver(params.EventReceiver), Logger(0), Operator(0), - FileSystem(0), InputReceivingSceneManager(0), CreationParams(params) + FileSystem(0), InputReceivingSceneManager(0), CreationParams(params), + Close(false) { Timer = new CTimer(); if (os::Printer::Logger) diff --git a/source/Irrlicht/CIrrDeviceStub.h b/source/Irrlicht/CIrrDeviceStub.h index 26109727..47a54161 100644 --- a/source/Irrlicht/CIrrDeviceStub.h +++ b/source/Irrlicht/CIrrDeviceStub.h @@ -147,8 +147,6 @@ namespace irr IOSOperator* Operator; io::IFileSystem* FileSystem; scene::ISceneManager* InputReceivingSceneManager; - video::CVideoModeList VideoModeList; - SIrrlichtCreationParameters CreationParams; struct SMouseMultiClicks { @@ -162,6 +160,9 @@ namespace irr core::position2di LastClick; }; SMouseMultiClicks MouseMultiClicks; + video::CVideoModeList VideoModeList; + SIrrlichtCreationParameters CreationParams; + bool Close; }; } // end namespace irr diff --git a/source/Irrlicht/CIrrDeviceWin32.cpp b/source/Irrlicht/CIrrDeviceWin32.cpp index f096ce6d..faa45229 100644 --- a/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/source/Irrlicht/CIrrDeviceWin32.cpp @@ -258,6 +258,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return 0; break; + case WM_ACTIVATE: + // we need to take care for screen changes, e.g. Alt-Tab + dev = getDeviceFromHWnd(hWnd); + if (dev) + { + if ((wParam&0xFF)==WA_INACTIVE) + dev->switchToFullScreen(true); + else + dev->switchToFullScreen(); + } + break; + case WM_USER: event.EventType = irr::EET_USER_EVENT; event.UserEvent.UserData1 = (irr::s32)wParam; @@ -298,17 +310,17 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params) // create the window if we need to and we do not use the null device if (!CreationParams.WindowId && CreationParams.DriverType != video::EDT_NULL) { - const c8* ClassName = "CIrrDeviceWin32"; + const fschar_t* ClassName = __TEXT("CIrrDeviceWin32"); // Register Class WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; - wcex.hIcon = NULL; + wcex.hIcon = NULL; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = 0; @@ -316,7 +328,7 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params) wcex.hIconSm = 0; // if there is an icon, load it - wcex.hIcon = (HICON)LoadImage(hInstance, "irrlicht.ico", IMAGE_ICON, 0,0, LR_LOADFROMFILE); + wcex.hIcon = (HICON)LoadImage(hInstance, __TEXT("irrlicht.ico"), IMAGE_ICON, 0,0, LR_LOADFROMFILE); RegisterClassEx(&wcex); @@ -349,7 +361,7 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params) // create window - HWnd = CreateWindow( ClassName, "", style, windowLeft, windowTop, + HWnd = CreateWindow( ClassName, __TEXT(""), style, windowLeft, windowTop, realWidth, realHeight, NULL, NULL, hInstance, NULL); CreationParams.WindowId = HWnd; @@ -414,8 +426,7 @@ CIrrDeviceWin32::~CIrrDeviceWin32() } } - if (ChangedToFullScreen) - ChangeDisplaySettings(NULL,0); + switchToFullScreen(true); } @@ -463,9 +474,7 @@ void CIrrDeviceWin32::createDriver() case video::EDT_OPENGL: #ifdef _IRR_COMPILE_WITH_OPENGL_ - - if (CreationParams.Fullscreen) - switchToFullScreen(CreationParams.WindowSize.Width, CreationParams.WindowSize.Height, CreationParams.Bits); + switchToFullScreen(); VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this); if (!VideoDriver) @@ -501,8 +510,7 @@ void CIrrDeviceWin32::createDriver() case video::EDT_SOFTWARE: #ifdef _IRR_COMPILE_WITH_SOFTWARE_ - if (CreationParams.Fullscreen) - switchToFullScreen(CreationParams.WindowSize.Width, CreationParams.WindowSize.Height, CreationParams.Bits); + switchToFullScreen(); VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); #else @@ -513,8 +521,7 @@ void CIrrDeviceWin32::createDriver() case video::EDT_BURNINGSVIDEO: #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - if (CreationParams.Fullscreen) - switchToFullScreen(CreationParams.WindowSize.Width, CreationParams.WindowSize.Height, CreationParams.Bits); + switchToFullScreen(); VideoDriver = video::createSoftwareDriver2(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); #else @@ -541,8 +548,6 @@ bool CIrrDeviceWin32::run() MSG msg; - bool quit = false; - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); @@ -553,17 +558,17 @@ bool CIrrDeviceWin32::run() DispatchMessage(&msg); if (msg.message == WM_QUIT) - quit = true; + Close = true; } - if (!quit) + if (!Close) resizeIfNecessary(); - if(!quit) + if(!Close) pollJoysticks(); _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return !quit; + return !Close; } @@ -701,6 +706,7 @@ void CIrrDeviceWin32::closeDevice() PostQuitMessage(0); PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); DestroyWindow(HWnd); + Close=true; } @@ -735,16 +741,26 @@ bool CIrrDeviceWin32::isWindowMinimized() const //! switches to fullscreen -bool CIrrDeviceWin32::switchToFullScreen(s32 width, s32 height, s32 bits) +bool CIrrDeviceWin32::switchToFullScreen(bool reset) { + if (!CreationParams.Fullscreen) + return true; + if (reset) + { + if (ChangedToFullScreen) + return (ChangeDisplaySettings(NULL,0)==DISP_CHANGE_SUCCESSFUL); + else + return true; + } + DEVMODE dm; memset(&dm, 0, sizeof(dm)); dm.dmSize = sizeof(dm); // use default values from current setting EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm); - dm.dmPelsWidth = width; - dm.dmPelsHeight = height; - dm.dmBitsPerPel = bits; + dm.dmPelsWidth = CreationParams.WindowSize.Width; + dm.dmPelsHeight = CreationParams.WindowSize.Height; + dm.dmBitsPerPel = CreationParams.Bits; dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; LONG res = ChangeDisplaySettings(&dm, CDS_FULLSCREEN); @@ -881,17 +897,17 @@ void CIrrDeviceWin32::getWindowsVersion(core::stringc& out) DWORD dwBufLen; RegOpenKeyEx( HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\ProductOptions", + __TEXT("SYSTEM\\CurrentControlSet\\Control\\ProductOptions"), 0, KEY_QUERY_VALUE, &hKey ); - RegQueryValueEx( hKey, "ProductType", NULL, NULL, + RegQueryValueEx( hKey, __TEXT("ProductType"), NULL, NULL, (LPBYTE) szProductType, &dwBufLen); RegCloseKey( hKey ); - if (lstrcmpi( "WINNT", szProductType) == 0 ) + if (_strcmpi( "WINNT", szProductType) == 0 ) out.append("Professional "); - if (lstrcmpi( "LANMANNT", szProductType) == 0) + if (_strcmpi( "LANMANNT", szProductType) == 0) out.append("Server "); - if (lstrcmpi( "SERVERNT", szProductType) == 0) + if (_strcmpi( "SERVERNT", szProductType) == 0) out.append("Advanced Server "); } diff --git a/source/Irrlicht/CIrrDeviceWin32.h b/source/Irrlicht/CIrrDeviceWin32.h index faf39adb..6913c34d 100644 --- a/source/Irrlicht/CIrrDeviceWin32.h +++ b/source/Irrlicht/CIrrDeviceWin32.h @@ -101,14 +101,18 @@ namespace irr return CIrrDeviceStub::checkSuccessiveClicks(mouseX, mouseY); } + //! switchs to fullscreen + bool switchToFullScreen(bool reset=false); + //! Implementation of the win32 cursor control class CCursorControl : public gui::ICursorControl { public: CCursorControl(const core::dimension2d& wsize, HWND hwnd, bool fullscreen) - : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), IsVisible(true), - HWnd(hwnd), BorderX(0), BorderY(0), UseReferenceRect(false) + : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), + HWnd(hwnd), BorderX(0), BorderY(0), + UseReferenceRect(false), IsVisible(true) { if (WindowSize.Width!=0) InvWindowSize.Width = 1.0f / WindowSize.Width; @@ -172,9 +176,9 @@ namespace irr virtual void setPosition(f32 x, f32 y) { if (!UseReferenceRect) - setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height)); + setPosition(core::round32(x*WindowSize.Width), core::round32(y*WindowSize.Height)); else - setPosition((s32)(x*ReferenceRect.getWidth()), (s32)(y*ReferenceRect.getHeight())); + setPosition(core::round32(x*ReferenceRect.getWidth()), core::round32(y*ReferenceRect.getHeight())); } //! Sets the new position of the cursor. @@ -247,6 +251,7 @@ namespace irr /** Used to notify the cursor that the window was resized. */ virtual void OnResize(const core::dimension2d& size) { + WindowSize = size; if (size.Width!=0) InvWindowSize.Width = 1.0f / size.Width; else @@ -297,12 +302,12 @@ namespace irr core::position2d CursorPos; core::dimension2d WindowSize; core::dimension2d InvWindowSize; - bool IsVisible; HWND HWnd; s32 BorderX, BorderY; - bool UseReferenceRect; core::rect ReferenceRect; + bool UseReferenceRect; + bool IsVisible; }; //! returns the win32 cursor control @@ -313,9 +318,6 @@ namespace irr //! create the driver void createDriver(); - //! switchs to fullscreen - bool switchToFullScreen(s32 width, s32 height, s32 bits); - void getWindowsVersion(core::stringc& version); void resizeIfNecessary(); @@ -344,4 +346,3 @@ namespace irr #endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_ #endif // __C_IRR_DEVICE_WIN32_H_INCLUDED__ - diff --git a/source/Irrlicht/CIrrDeviceWinCE.cpp b/source/Irrlicht/CIrrDeviceWinCE.cpp index dbfb7a49..f71f2203 100644 --- a/source/Irrlicht/CIrrDeviceWinCE.cpp +++ b/source/Irrlicht/CIrrDeviceWinCE.cpp @@ -552,8 +552,6 @@ bool CIrrDeviceWinCE::run() MSG msg; - bool quit = false; - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); @@ -564,14 +562,14 @@ bool CIrrDeviceWinCE::run() DispatchMessage(&msg); if (msg.message == WM_QUIT) - quit = true; + Close = true; } - if (!quit) + if (!Close) resizeIfNecessary(); _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return !quit; + return !Close; } @@ -713,6 +711,7 @@ void CIrrDeviceWinCE::closeDevice() PostQuitMessage(0); PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); DestroyWindow(HWnd); + Close=true; } diff --git a/source/Irrlicht/CIrrDeviceWinCE.h b/source/Irrlicht/CIrrDeviceWinCE.h index fcb349e8..83c43ae3 100644 --- a/source/Irrlicht/CIrrDeviceWinCE.h +++ b/source/Irrlicht/CIrrDeviceWinCE.h @@ -90,8 +90,9 @@ namespace irr public: CCursorControl(const core::dimension2d& wsize, HWND hwnd, bool fullscreen) - : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), IsVisible(true), - HWnd(hwnd), BorderX(0), BorderY(0), UseReferenceRect(false) + : WindowSize(wsize), InvWindowSize(0.0f, 0.0f), + HWnd(hwnd), BorderX(0), BorderY(0), + UseReferenceRect(false), IsVisible(true) { if (WindowSize.Width!=0) InvWindowSize.Width = 1.0f / WindowSize.Width; @@ -129,9 +130,9 @@ namespace irr virtual void setPosition(f32 x, f32 y) { if (!UseReferenceRect) - setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height)); + setPosition(core::round32(x*WindowSize.Width), core::round32(y*WindowSize.Height)); else - setPosition((s32)(x*ReferenceRect.getWidth()), (s32)(y*ReferenceRect.getHeight())); + setPosition(core::round32(x*ReferenceRect.getWidth()), core::round32(y*ReferenceRect.getHeight())); } //! Sets the new position of the cursor. @@ -205,6 +206,7 @@ namespace irr /** Used to notify the cursor that the window was resized. */ virtual void OnResize(const core::dimension2d& size) { + WindowSize = size; if (size.Width!=0) InvWindowSize.Width = 1.0f / size.Width; else @@ -255,12 +257,12 @@ namespace irr core::position2d CursorPos; core::dimension2d WindowSize; core::dimension2d InvWindowSize; - bool IsVisible; HWND HWnd; s32 BorderX, BorderY; - bool UseReferenceRect; core::rect ReferenceRect; + bool UseReferenceRect; + bool IsVisible; }; diff --git a/source/Irrlicht/CLWOMeshFileLoader.cpp b/source/Irrlicht/CLWOMeshFileLoader.cpp index 6576f824..8a8dbe75 100644 --- a/source/Irrlicht/CLWOMeshFileLoader.cpp +++ b/source/Irrlicht/CLWOMeshFileLoader.cpp @@ -217,6 +217,7 @@ IAnimatedMesh* CLWOMeshFileLoader::createMesh(io::IReadFile* file) const u16 uvTag = Materials[tag]->Texture[0].UVTag; const u16 duvTag = Materials[tag]->Texture[0].DUVTag; video::S3DVertex vertex; + vertex.Color=0xffffffff; const u32 vertCount=mb->Vertices.size(); for (u32 i=0; iMeshbuffer->Vertices.size())); #endif if (!Materials[i]->Meshbuffer->Vertices.size()) + { + Materials[i]->Meshbuffer->drop(); + delete Materials[i]; continue; + } for (u32 j=0; jMeshbuffer->Vertices.size(); ++j) Materials[i]->Meshbuffer->Vertices[j].Color=Materials[i]->Meshbuffer->Material.DiffuseColor; Materials[i]->Meshbuffer->recalculateBoundingBox(); @@ -343,17 +348,17 @@ IAnimatedMesh* CLWOMeshFileLoader::createMesh(io::IReadFile* file) } } // get the resolution for this axis - f32 resolutionS = 1.f/Materials[i]->Texture[0].Size.Z; - f32 resolutionT = 1.f/Materials[i]->Texture[0].Size.Y; + f32 resolutionS = core::reciprocal(Materials[i]->Texture[0].Size.Z); + f32 resolutionT = core::reciprocal(Materials[i]->Texture[0].Size.Y); if (Materials[i]->Texture[0].Axis==1) { - resolutionS = 1.f/Materials[i]->Texture[0].Size.X; - resolutionT = 1.f/Materials[i]->Texture[0].Size.Z; + resolutionS = core::reciprocal(Materials[i]->Texture[0].Size.X); + resolutionT = core::reciprocal(Materials[i]->Texture[0].Size.Z); } else if (Materials[i]->Texture[0].Axis==2) { - resolutionS = 1.f/Materials[i]->Texture[0].Size.X; - resolutionT = 1.f/Materials[i]->Texture[0].Size.Y; + resolutionS = core::reciprocal(Materials[i]->Texture[0].Size.X); + resolutionT = core::reciprocal(Materials[i]->Texture[0].Size.Y); } // use the two-way planar mapping SceneManager->getMeshManipulator()->makePlanarTextureMapping(Materials[i]->Meshbuffer, resolutionS, resolutionT, Materials[i]->Texture[0].Axis, Materials[i]->Texture[0].Center); @@ -362,17 +367,19 @@ IAnimatedMesh* CLWOMeshFileLoader::createMesh(io::IReadFile* file) // add bump maps if (Materials[i]->Meshbuffer->Material.MaterialType==video::EMT_NORMAL_MAP_SOLID) { - SMesh tmpmesh; - tmpmesh.addMeshBuffer(Materials[i]->Meshbuffer); - SceneManager->getMeshManipulator()->createMeshWithTangents(&tmpmesh, true, true); - Mesh->addMeshBuffer(tmpmesh.getMeshBuffer(0)); + SMesh* tmpmesh = new SMesh(); + tmpmesh->addMeshBuffer(Materials[i]->Meshbuffer); + SceneManager->getMeshManipulator()->createMeshWithTangents(tmpmesh, true, true); + Mesh->addMeshBuffer(tmpmesh->getMeshBuffer(0)); + tmpmesh->getMeshBuffer(0)->drop(); + tmpmesh->drop(); } else { SceneManager->getMeshManipulator()->recalculateNormals(Materials[i]->Meshbuffer); Mesh->addMeshBuffer(Materials[i]->Meshbuffer); } - Mesh->getMeshBuffer(Mesh->getMeshBufferCount()-1)->drop(); + Materials[i]->Meshbuffer->drop(); // clear the material array elements delete Materials[i]; } @@ -607,6 +614,7 @@ void CLWOMeshFileLoader::readObj1(u32 size) u16 numVerts, vertIndex; s16 material; video::S3DVertex vertex; + vertex.Color=0xffffffff; while (size!=0) { diff --git a/source/Irrlicht/CMeshManipulator.cpp b/source/Irrlicht/CMeshManipulator.cpp index e5e2794c..115b1b96 100644 --- a/source/Irrlicht/CMeshManipulator.cpp +++ b/source/Irrlicht/CMeshManipulator.cpp @@ -909,9 +909,9 @@ IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh, bool recalculateNor v[idx[i+2]].TCoords); if (recalculateNormals) - v[idx[i+0]].Tangent += localTangent * weight.X; + v[idx[i+0]].Normal += localNormal * weight.X; + v[idx[i+0]].Tangent += localTangent * weight.X; v[idx[i+0]].Binormal += localBinormal * weight.X; - v[idx[i+0]].Normal += localNormal * weight.X; calculateTangents( localNormal, @@ -925,9 +925,9 @@ IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh, bool recalculateNor v[idx[i+0]].TCoords); if (recalculateNormals) - v[idx[i+1]].Tangent += localTangent * weight.Y; + v[idx[i+1]].Normal += localNormal * weight.Y; + v[idx[i+1]].Tangent += localTangent * weight.Y; v[idx[i+1]].Binormal += localBinormal * weight.Y; - v[idx[i+1]].Normal += localNormal * weight.Y; calculateTangents( localNormal, @@ -941,9 +941,9 @@ IMesh* CMeshManipulator::createMeshWithTangents(IMesh* mesh, bool recalculateNor v[idx[i+1]].TCoords); if (recalculateNormals) - v[idx[i+2]].Tangent += localTangent * weight.Z; + v[idx[i+2]].Normal += localNormal * weight.Z; + v[idx[i+2]].Tangent += localTangent * weight.Z; v[idx[i+2]].Binormal += localBinormal * weight.Z; - v[idx[i+2]].Normal += localNormal * weight.Z; } // Normalize the tangents and binormals @@ -1104,7 +1104,6 @@ IMesh* CMeshManipulator::createMeshWith1TCoords(IMesh* mesh) const SMeshBuffer* buffer = new SMeshBuffer(); buffer->Material = mesh->getMeshBuffer(b)->getMaterial(); - buffer->Material.MaterialType = video::EMT_SOLID; // copy vertices diff --git a/source/Irrlicht/CMeshSceneNode.cpp b/source/Irrlicht/CMeshSceneNode.cpp index 841beb10..45bcbee5 100644 --- a/source/Irrlicht/CMeshSceneNode.cpp +++ b/source/Irrlicht/CMeshSceneNode.cpp @@ -178,6 +178,7 @@ void CMeshSceneNode::render() { video::SMaterial m; m.Lighting = false; + m.AntiAliasing=0; driver->setMaterial(m); if (DebugDataVisible & scene::EDS_BBOX) diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp index 7987e265..fcfb03eb 100644 --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@ -585,56 +585,6 @@ void CNullDriver::draw2DVertexPrimitiveList(const void* vertices, u32 vertexCoun } -//! draws an indexed triangle list -void CNullDriver::drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT); -} - - -//! draws an indexed triangle list -void CNullDriver::drawIndexedTriangleList(const S3DVertex2TCoords* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES, EIT_16BIT); -} - - -//! Draws an indexed triangle list. -void CNullDriver::drawIndexedTriangleList(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES, EIT_16BIT); -} - - - -//! Draws an indexed triangle fan. -void CNullDriver::drawIndexedTriangleFan(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT); -} - - - -//! Draws an indexed triangle fan. -void CNullDriver::drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN, EIT_16BIT); -} - - - -//! Draws an indexed triangle fan. -void CNullDriver::drawIndexedTriangleFan(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount) -{ - drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN, EIT_16BIT); -} - - - //! Draws a 3d line. void CNullDriver::draw3DLine(const core::vector3df& start, const core::vector3df& end, SColor color) @@ -642,17 +592,27 @@ void CNullDriver::draw3DLine(const core::vector3df& start, } - //! Draws a 3d triangle. void CNullDriver::draw3DTriangle(const core::triangle3df& triangle, SColor color) { - draw3DLine(triangle.pointA, triangle.pointB, color); - draw3DLine(triangle.pointB, triangle.pointC, color); - draw3DLine(triangle.pointC, triangle.pointA, color); + S3DVertex vertices[3]; + vertices[0].Pos=triangle.pointA; + vertices[0].Color=color; + vertices[0].Normal=triangle.getNormal().normalize(); + vertices[0].TCoords.set(0.f,0.f); + vertices[1].Pos=triangle.pointB; + vertices[1].Color=color; + vertices[1].Normal=vertices[0].Normal; + vertices[1].TCoords.set(0.5f,1.f); + vertices[2].Pos=triangle.pointC; + vertices[2].Color=color; + vertices[2].Normal=vertices[0].Normal; + vertices[2].TCoords.set(1.f,0.f); + const u16 indexList[] = {0,1,2}; + drawVertexPrimitiveList(vertices, 3, indexList, 1, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT); } - //! Draws a 3d axis aligned box. void CNullDriver::draw3DBox(const core::aabbox3d& box, SColor color) { @@ -1442,6 +1402,18 @@ void CNullDriver::setFog(SColor color, E_FOG_TYPE fogType, f32 start, f32 end, RangeFog = rangeFog; } +//! Gets the fog mode. +void CNullDriver::getFog(SColor& color, E_FOG_TYPE& fogType, f32& start, f32& end, + f32& density, bool& pixelFog, bool& rangeFog) +{ + color = FogColor; + fogType = FogType; + start = FogStart; + end = FogEnd; + density = FogDensity; + pixelFog = PixelFog; + rangeFog = RangeFog; +} //! Draws a mesh buffer void CNullDriver::drawMeshBuffer(const scene::IMeshBuffer* mb) @@ -2101,5 +2073,12 @@ SOverrideMaterial& CNullDriver::getOverrideMaterial() return OverrideMaterial; } + +core::dimension2du CNullDriver::getMaxTextureSize() const +{ + return core::dimension2du(0x10000,0x10000); // maybe large enough +} + + } // end namespace } // end namespace diff --git a/source/Irrlicht/CNullDriver.h b/source/Irrlicht/CNullDriver.h index 3d9c198f..b11ec158 100644 --- a/source/Irrlicht/CNullDriver.h +++ b/source/Irrlicht/CNullDriver.h @@ -107,34 +107,12 @@ namespace video //! draws a vertex primitive list virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); + E_VERTEX_TYPE vType=EVT_STANDARD, scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES, E_INDEX_TYPE iType=EIT_16BIT); //! draws a vertex primitive list in 2d virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! draws an indexed triangle list - virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle list. - virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle fan. - virtual void drawIndexedTriangleFan(const S3DVertex* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle list. - virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); - - //! Draws an indexed triangle fan. - virtual void drawIndexedTriangleFan(const S3DVertexTangents* vertices, - u32 vertexCount, const u16* indexList, u32 triangleCount); + E_VERTEX_TYPE vType=EVT_STANDARD, scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES, E_INDEX_TYPE iType=EIT_16BIT); //! Draws a 3d line. virtual void draw3DLine(const core::vector3df& start, @@ -238,6 +216,10 @@ namespace video f32 start=50.0f, f32 end=100.0f, f32 density=0.01f, bool pixelFog=false, bool rangeFog=false); + virtual void getFog(SColor& color, E_FOG_TYPE& fogType, + f32& start, f32& end, f32& density, + bool& pixelFog, bool& rangeFog); + //! get color format of the current color buffer virtual ECOLOR_FORMAT getColorFormat() const; @@ -579,6 +561,9 @@ namespace video virtual void setAllowZWriteOnTransparent(bool flag) { AllowZWriteOnTransparent=flag; } + //! Returns the maximum texture size supported. + virtual core::dimension2du getMaxTextureSize() const; + //! deprecated method virtual ITexture* createRenderTargetTexture(const core::dimension2d& size, const c8* name=0); diff --git a/source/Irrlicht/COBJMeshFileLoader.cpp b/source/Irrlicht/COBJMeshFileLoader.cpp index 033b2ee0..b98aaf30 100644 --- a/source/Irrlicht/COBJMeshFileLoader.cpp +++ b/source/Irrlicht/COBJMeshFileLoader.cpp @@ -423,13 +423,20 @@ const c8* COBJMeshFileLoader::readTextures(const c8* bufPtr, const c8* const buf texname.replace('\\', '/'); video::ITexture * texture = 0; + bool newTexture=false; if (texname.size()) { if (FileSystem->existFile(texname)) + { + newTexture = SceneManager->getVideoDriver()->findTexture(texname) == 0; texture = SceneManager->getVideoDriver()->getTexture(texname); + } else + { + newTexture = SceneManager->getVideoDriver()->findTexture(relPath + texname) == 0; // try to read in the relative path, the .obj is loaded from texture = SceneManager->getVideoDriver()->getTexture( relPath + texname ); + } } if ( texture ) { @@ -437,7 +444,8 @@ const c8* COBJMeshFileLoader::readTextures(const c8* bufPtr, const c8* const buf currMaterial->Meshbuffer->Material.setTexture(0, texture); else if (type==1) { - SceneManager->getVideoDriver()->makeNormalMapTexture(texture, bumpiness); + if (newTexture) + SceneManager->getVideoDriver()->makeNormalMapTexture(texture, bumpiness); currMaterial->Meshbuffer->Material.setTexture(1, texture); currMaterial->Meshbuffer->Material.MaterialType=video::EMT_PARALLAX_MAP_SOLID; currMaterial->Meshbuffer->Material.MaterialTypeParam=0.035f; diff --git a/source/Irrlicht/COSOperator.cpp b/source/Irrlicht/COSOperator.cpp index 5c14a26a..9fb1d4d0 100644 --- a/source/Irrlicht/COSOperator.cpp +++ b/source/Irrlicht/COSOperator.cpp @@ -132,7 +132,7 @@ bool COSOperator::getProcessorSpeedMHz(u32* MHz) const HKEY Key; Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", + __TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0, KEY_READ, &Key); if(Error != ERROR_SUCCESS) @@ -140,7 +140,7 @@ bool COSOperator::getProcessorSpeedMHz(u32* MHz) const DWORD Speed = 0; DWORD Size = sizeof(Speed); - Error = RegQueryValueEx(Key, "~MHz", NULL, NULL, (LPBYTE)&Speed, &Size); + Error = RegQueryValueEx(Key, __TEXT("~MHz"), NULL, NULL, (LPBYTE)&Speed, &Size); RegCloseKey(Key); diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index 71c47964..5a21112c 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -77,7 +77,7 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi if (AntiAlias > 1) { // Create a window to test antialiasing support - const c8* ClassName = "GLCIrrDeviceWin32"; + const fschar_t* ClassName = __TEXT("GLCIrrDeviceWin32"); HINSTANCE lhInstance = GetModuleHandle(0); // Register Class @@ -116,7 +116,7 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params, CIrrDevi const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; - HWND temporary_wnd=CreateWindow(ClassName, "", style, windowLeft, windowTop, + HWND temporary_wnd=CreateWindow(ClassName, __TEXT(""), style, windowLeft, windowTop, realWidth, realHeight, NULL, NULL, lhInstance, NULL); if (!temporary_wnd) @@ -1435,7 +1435,17 @@ void COpenGLDriver::draw2DVertexPrimitiveList(const void* vertices, u32 vertexCo // draw everything this->setActiveTexture(0, Material.getTexture(0)); - setRenderStates2DMode(false, (Material.getTexture(0) != 0), false); + if (Material.MaterialType==EMT_ONETEXTURE_BLEND) + { + E_BLEND_FACTOR srcFact; + E_BLEND_FACTOR dstFact; + E_MODULATE_FUNC modulo; + u32 alphaSource; + unpack_texureBlendFunc ( srcFact, dstFact, modulo, alphaSource, Material.MaterialTypeParam); + setRenderStates2DMode(alphaSource&video::EAS_VERTEX_COLOR, (Material.getTexture(0) != 0), alphaSource&video::EAS_TEXTURE); + } + else + setRenderStates2DMode(Material.MaterialType==EMT_TRANSPARENT_VERTEX_ALPHA, (Material.getTexture(0) != 0), Material.MaterialType==EMT_TRANSPARENT_ALPHA_CHANNEL); if (MultiTextureExtension) extGlClientActiveTexture(GL_TEXTURE0_ARB); @@ -3500,6 +3510,11 @@ void COpenGLDriver::enableClipPlane(u32 index, bool enable) } +core::dimension2du COpenGLDriver::getMaxTextureSize() const +{ + return core::dimension2du(MaxTextureSize, MaxTextureSize); +} + } // end namespace } // end namespace diff --git a/source/Irrlicht/COpenGLDriver.h b/source/Irrlicht/COpenGLDriver.h index e2d4022a..a2da0cfc 100644 --- a/source/Irrlicht/COpenGLDriver.h +++ b/source/Irrlicht/COpenGLDriver.h @@ -315,6 +315,9 @@ namespace video //! Returns the graphics card vendor name. virtual core::stringc getVendorInfo() {return vendorName;} + //! Returns the maximum texture size supported. + virtual core::dimension2du getMaxTextureSize() const; + ITexture* createDepthTexture(ITexture* texture, bool shared=true); void removeDepthTexture(ITexture* texture); diff --git a/source/Irrlicht/COpenGLMaterialRenderer.h b/source/Irrlicht/COpenGLMaterialRenderer.h index 5851d825..197f007f 100644 --- a/source/Irrlicht/COpenGLMaterialRenderer.h +++ b/source/Irrlicht/COpenGLMaterialRenderer.h @@ -177,7 +177,7 @@ public: { return true; } - + private: u32 getGLBlend ( E_BLEND_FACTOR factor ) const @@ -405,7 +405,7 @@ public: { glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5f); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } } @@ -466,7 +466,7 @@ public: glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); if (material.MaterialType == EMT_LIGHTMAP_ADD) - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD); else glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); diff --git a/source/Irrlicht/COpenGLNormalMapRenderer.cpp b/source/Irrlicht/COpenGLNormalMapRenderer.cpp index 6135ee45..c4201255 100644 --- a/source/Irrlicht/COpenGLNormalMapRenderer.cpp +++ b/source/Irrlicht/COpenGLNormalMapRenderer.cpp @@ -47,9 +47,6 @@ const char OPENGL_NORMAL_MAP_VSH[] = "PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.\n"\ "TEMP Temp;\n"\ "TEMP TempColor;\n"\ - "TEMP TempNormal;\n"\ - "TEMP TempTangent;\n"\ - "TEMP TempBinormal;\n"\ "TEMP TempLightVector1;\n"\ "TEMP TempLightVector2;\n"\ "TEMP TempTransLightV1;\n"\ @@ -63,40 +60,19 @@ const char OPENGL_NORMAL_MAP_VSH[] = "MOV OutPos.z, Temp.z;\n"\ "MOV result.fogcoord.x, Temp.z;\n"\ "\n"\ - "# transform normal \n"\ - "DP3 TempNormal.x, InNormal.x, program.local[0];\n"\ - "DP3 TempNormal.y, InNormal.y, program.local[1]; \n"\ - "DP3 TempNormal.z, InNormal.z, program.local[2];\n"\ - "\n"\ - "# transform tangent \n"\ - "DP3 TempTangent.x, InTangent.x, program.local[0];\n"\ - "DP3 TempTangent.y, InTangent.y, program.local[1]; \n"\ - "DP3 TempTangent.z, InTangent.z, program.local[2];\n"\ - "\n"\ - "# transform binormal \n"\ - "DP3 TempBinormal.x, InBinormal.x, program.local[0];\n"\ - "DP3 TempBinormal.y, InBinormal.y, program.local[1]; \n"\ - "DP3 TempBinormal.z, InBinormal.z, program.local[2];\n"\ - "\n"\ - "# vertex into world position \n"\ - "DP4 Temp.x, InPos, program.local[0];\n"\ - "DP4 Temp.y, InPos, program.local[1];\n"\ - "DP4 Temp.z, InPos, program.local[2];\n"\ - "DP4 Temp.w, InPos, program.local[3];\n"\ - "\n"\ "# vertex - lightpositions \n"\ - "SUB TempLightVector1, program.local[12], Temp; \n"\ - "SUB TempLightVector2, program.local[14], Temp; \n"\ + "SUB TempLightVector1, program.local[12], InPos; \n"\ + "SUB TempLightVector2, program.local[14], InPos; \n"\ "\n"\ "# transform the light vector 1 with U, V, W \n"\ - "DP3 TempTransLightV1.x, TempTangent, TempLightVector1; \n"\ - "DP3 TempTransLightV1.y, TempBinormal, TempLightVector1; \n"\ - "DP3 TempTransLightV1.z, TempNormal, TempLightVector1; \n"\ + "DP3 TempTransLightV1.x, InTangent, TempLightVector1; \n"\ + "DP3 TempTransLightV1.y, InBinormal, TempLightVector1; \n"\ + "DP3 TempTransLightV1.z, InNormal, TempLightVector1; \n"\ "\n"\ "# transform the light vector 2 with U, V, W \n"\ - "DP3 TempTransLightV2.x, TempTangent, TempLightVector2; \n"\ - "DP3 TempTransLightV2.y, TempBinormal, TempLightVector2; \n"\ - "DP3 TempTransLightV2.z, TempNormal, TempLightVector2; \n"\ + "DP3 TempTransLightV2.x, InTangent, TempLightVector2; \n"\ + "DP3 TempTransLightV2.y, InBinormal, TempLightVector2; \n"\ + "DP3 TempTransLightV2.z, InNormal, TempLightVector2; \n"\ "\n"\ "# normalize light vector 1 \n"\ "DP3 TempTransLightV1.w, TempTransLightV1, TempTransLightV1; \n"\ @@ -277,6 +253,10 @@ void COpenGLNormalMapRenderer::OnSetConstants(IMaterialRendererServices* service u32 cnt = driver->getDynamicLightCount(); + // Load the inverse world matrix. + core::matrix4 invWorldMat; + driver->getTransform(video::ETS_WORLD).getInverse(invWorldMat); + for (u32 i=0; i<2; ++i) { video::SLight light; @@ -291,6 +271,9 @@ void COpenGLNormalMapRenderer::OnSetConstants(IMaterialRendererServices* service light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation + // Transform the light by the inverse world matrix to get it into object space. + invWorldMat.transformVect(light.Position); + services->setVertexShaderConstant( reinterpret_cast(&light.Position), 12+(i*2), 1); diff --git a/source/Irrlicht/COpenGLParallaxMapRenderer.cpp b/source/Irrlicht/COpenGLParallaxMapRenderer.cpp index 70be541c..3c3b0e71 100644 --- a/source/Irrlicht/COpenGLParallaxMapRenderer.cpp +++ b/source/Irrlicht/COpenGLParallaxMapRenderer.cpp @@ -49,9 +49,6 @@ const char OPENGL_PARALLAX_MAP_VSH[] = "PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.\n"\ "TEMP Temp;\n"\ "TEMP TempColor;\n"\ - "TEMP TempNormal;\n"\ - "TEMP TempTangent;\n"\ - "TEMP TempBinormal;\n"\ "TEMP TempLightVector1;\n"\ "TEMP TempLightVector2;\n"\ "TEMP TempEyeVector;\n"\ @@ -66,48 +63,27 @@ const char OPENGL_PARALLAX_MAP_VSH[] = "MOV OutPos.z, Temp.z;\n"\ "MOV result.fogcoord.x, Temp.z;\n"\ "\n"\ - "# transform normal \n"\ - "DP3 TempNormal.x, InNormal.x, program.local[0];\n"\ - "DP3 TempNormal.y, InNormal.y, program.local[1]; \n"\ - "DP3 TempNormal.z, InNormal.z, program.local[2];\n"\ - "\n"\ - "# transform tangent \n"\ - "DP3 TempTangent.x, InTangent.x, program.local[0];\n"\ - "DP3 TempTangent.y, InTangent.y, program.local[1]; \n"\ - "DP3 TempTangent.z, InTangent.z, program.local[2];\n"\ - "\n"\ - "# transform binormal \n"\ - "DP3 TempBinormal.x, InBinormal.x, program.local[0];\n"\ - "DP3 TempBinormal.y, InBinormal.y, program.local[1]; \n"\ - "DP3 TempBinormal.z, InBinormal.z, program.local[2];\n"\ - "\n"\ - "# vertex into world position \n"\ - "DP4 Temp.x, InPos, program.local[0];\n"\ - "DP4 Temp.y, InPos, program.local[1];\n"\ - "DP4 Temp.z, InPos, program.local[2];\n"\ - "DP4 Temp.w, InPos, program.local[3];\n"\ - "\n"\ "# vertex - lightpositions \n"\ - "SUB TempLightVector1, program.local[12], Temp; \n"\ - "SUB TempLightVector2, program.local[14], Temp; \n"\ + "SUB TempLightVector1, program.local[12], InPos; \n"\ + "SUB TempLightVector2, program.local[14], InPos; \n"\ "\n"\ "# eye vector \n"\ - "SUB Temp, program.local[16], Temp; \n"\ + "SUB Temp, program.local[16], InPos; \n"\ "\n"\ "# transform the light vector 1 with U, V, W \n"\ - "DP3 TempTransLightV1.x, TempTangent, TempLightVector1; \n"\ - "DP3 TempTransLightV1.y, TempBinormal, TempLightVector1; \n"\ - "DP3 TempTransLightV1.z, TempNormal, TempLightVector1; \n"\ + "DP3 TempTransLightV1.x, InTangent, TempLightVector1; \n"\ + "DP3 TempTransLightV1.y, InBinormal, TempLightVector1; \n"\ + "DP3 TempTransLightV1.z, InNormal, TempLightVector1; \n"\ "\n"\ "# transform the light vector 2 with U, V, W \n"\ - "DP3 TempTransLightV2.x, TempTangent, TempLightVector2; \n"\ - "DP3 TempTransLightV2.y, TempBinormal, TempLightVector2; \n"\ - "DP3 TempTransLightV2.z, TempNormal, TempLightVector2; \n"\ + "DP3 TempTransLightV2.x, InTangent, TempLightVector2; \n"\ + "DP3 TempTransLightV2.y, InBinormal, TempLightVector2; \n"\ + "DP3 TempTransLightV2.z, InNormal, TempLightVector2; \n"\ "\n"\ "# transform the eye vector with U, V, W \n"\ - "DP3 TempEyeVector.x, TempTangent, Temp; \n"\ - "DP3 TempEyeVector.y, TempBinormal, Temp; \n"\ - "DP3 TempEyeVector.z, TempNormal, Temp; \n"\ + "DP3 TempEyeVector.x, InTangent, Temp; \n"\ + "DP3 TempEyeVector.y, InBinormal, Temp; \n"\ + "DP3 TempEyeVector.z, InNormal, Temp; \n"\ "\n"\ "# normalize light vector 1 \n"\ "DP3 TempTransLightV1.w, TempTransLightV1, TempTransLightV1; \n"\ @@ -311,17 +287,6 @@ void COpenGLParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* servi const core::matrix4& tWorld = driver->getTransform(video::ETS_WORLD).getTransposed(); services->setVertexShaderConstant(tWorld.pointer(), 0, 4); - // The viewpoint is at (0., 0., 0.) in eye space. - // Turning this into a vector [0 0 0 1] and multiply it by - // the inverse of the view matrix, the resulting vector is the - // object space location of the camera. - - f32 floats[4] = {0.0f,0.0f,0.0f,1.0f}; - core::matrix4 minv(driver->getTransform(video::ETS_VIEW)); - minv.makeInverse(); - minv.multiplyWith1x4Matrix(floats); - services->setVertexShaderConstant(floats, 16, 1); - // set transposed worldViewProj matrix core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); worldViewProj *= driver->getTransform(video::ETS_VIEW); @@ -334,6 +299,10 @@ void COpenGLParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* servi u32 cnt = driver->getDynamicLightCount(); + // Load the inverse world matrix. + core::matrix4 invWorldMat; + driver->getTransform(video::ETS_WORLD).getInverse(invWorldMat); + for (u32 i=0; i<2; ++i) { video::SLight light; @@ -348,6 +317,9 @@ void COpenGLParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* servi light.DiffuseColor.a = 1.0f/(light.Radius*light.Radius); // set attenuation + // Transform the light by the inverse world matrix to get it into object space. + invWorldMat.transformVect(light.Position); + services->setVertexShaderConstant( reinterpret_cast(&light.Position), 12+(i*2), 1); @@ -355,6 +327,15 @@ void COpenGLParallaxMapRenderer::OnSetConstants(IMaterialRendererServices* servi reinterpret_cast(&light.DiffuseColor), 13+(i*2), 1); } + // Obtain the view position by transforming 0,0,0 by the inverse view matrix + // and then multiply this by the inverse world matrix. + core::vector3df viewPos(0.0f, 0.0f, 0.0f); + core::matrix4 inverseView; + driver->getTransform(video::ETS_VIEW).getInverse(inverseView); + inverseView.transformVect(viewPos); + invWorldMat.transformVect(viewPos); + services->setVertexShaderConstant(reinterpret_cast(&viewPos.X), 16, 1); + // set scale factor f32 factor = 0.02f; // default value if (CurrentScale != 0.0f) diff --git a/source/Irrlicht/CPLYMeshFileLoader.cpp b/source/Irrlicht/CPLYMeshFileLoader.cpp index f6a3354f..9cff36b3 100644 --- a/source/Irrlicht/CPLYMeshFileLoader.cpp +++ b/source/Irrlicht/CPLYMeshFileLoader.cpp @@ -34,7 +34,7 @@ CPLYMeshFileLoader::~CPLYMeshFileLoader() // (we do, but this could be disabled to increase the speed of loading hundreds of meshes) if (Buffer) { - delete Buffer; + delete [] Buffer; Buffer = 0; } @@ -270,7 +270,7 @@ IAnimatedMesh* CPLYMeshFileLoader::createMesh(io::IReadFile* file) // free the buffer - delete Buffer; + delete [] Buffer; Buffer = 0; File->drop(); File = 0; @@ -557,7 +557,7 @@ c8* CPLYMeshFileLoader::getNextLine() // begin at the start of the next line c8* pos = StartPointer; - while (*pos && pos < EndPointer && *pos != '\r' && *pos != '\n') + while (pos < EndPointer && *pos && *pos != '\r' && *pos != '\n') ++pos; if ( pos < EndPointer && ( *(pos+1) == '\r' || *(pos+1) == '\n') ) diff --git a/source/Irrlicht/CPakReader.cpp b/source/Irrlicht/CPakReader.cpp index 00388a43..34477bdc 100644 --- a/source/Irrlicht/CPakReader.cpp +++ b/source/Irrlicht/CPakReader.cpp @@ -15,20 +15,34 @@ namespace irr namespace io { +namespace +{ + +inline bool isHeaderValid(const SPAKFileHeader& header) +{ + const c8* tag = header.tag; + return tag[0] == 'P' && + tag[1] == 'A' && + tag[2] == 'C' && + tag[3] == 'K'; +} + +} // end namespace + //! Constructor CArchiveLoaderPAK::CArchiveLoaderPAK( io::IFileSystem* fs) : FileSystem(fs) { - #ifdef _DEBUG +#ifdef _DEBUG setDebugName("CArchiveLoaderPAK"); - #endif +#endif } //! returns true if the file maybe is able to be loaded by this class bool CArchiveLoaderPAK::isALoadableFileFormat(const io::path& filename) const { - return core::hasFileExtension ( filename, "pak" ); + return core::hasFileExtension(filename, "pak"); } //! Check to see if the loader can create archives of this type. @@ -47,7 +61,7 @@ IFileArchive* CArchiveLoaderPAK::createArchive(const io::path& filename, bool ig if (file) { - archive = createArchive ( file, ignoreCase, ignorePaths ); + archive = createArchive(file, ignoreCase, ignorePaths); file->drop (); } @@ -76,9 +90,9 @@ bool CArchiveLoaderPAK::isALoadableFileFormat(io::IReadFile* file) const { SPAKFileHeader header; - file->read( &header.tag, 4 ); + file->read(&header, sizeof(header)); - return header.tag[0] == 'P' && header.tag[1] == 'A'; + return isHeaderValid(header); } @@ -88,17 +102,14 @@ bool CArchiveLoaderPAK::isALoadableFileFormat(io::IReadFile* file) const CPakReader::CPakReader(IReadFile* file, bool ignoreCase, bool ignorePaths) : CFileList(file ? file->getFileName() : "", ignoreCase, ignorePaths), File(file) { - #ifdef _DEBUG +#ifdef _DEBUG setDebugName("CPakReader"); - #endif +#endif if (File) { File->grab(); - - // scan local headers scanLocalHeader(); - sort(); } } @@ -116,48 +127,43 @@ const IFileList* CPakReader::getFileList() const return this; } -//! scans for a local header, returns false if there is no more local file header. bool CPakReader::scanLocalHeader() { + SPAKFileHeader header; + + // Read and validate the header + File->read(&header, sizeof(header)); + if (!isHeaderValid(header)) + return false; - c8 tmp[1024]; - io::path PakFileName; - - memset(&header, 0, sizeof(SPAKFileHeader)); - File->read(&header, sizeof(SPAKFileHeader)); - - if (header.tag[0] != 'P' && header.tag[1] != 'A') - return false; // local file headers end here. - + // Seek to the table of contents +#ifdef __BIG_ENDIAN__ + header.offset = os::Byteswap::byteswap(header.offset); + header.length = os::Byteswap::byteswap(header.length); +#endif File->seek(header.offset); - const int count = header.length / ((sizeof(u32) * 2) + 56); + const int numberOfFiles = header.length / sizeof(SPAKFileEntry); - for(int i = 0; i < count; i++) + Offsets.reallocate(numberOfFiles); + // Loop through each entry in the table of contents + for(int i = 0; i < numberOfFiles; i++) { - // read filename - PakFileName.reserve(56+2); - File->read(tmp, 56); - tmp[56] = 0x0; - PakFileName = tmp; + // read an entry + SPAKFileEntry entry; + File->read(&entry, sizeof(entry)); - #ifdef _DEBUG - os::Printer::log(PakFileName.c_str()); - #endif - - s32 offset; - s32 size; - - File->read(&offset, sizeof(u32)); - File->read(&size, sizeof(u32)); - -#ifdef __BIG_ENDIAN__ - os::Byteswap::byteswap(offset); - os::Byteswap::byteswap(size); +#ifdef _DEBUG + os::Printer::log(entry.name); #endif - addItem(PakFileName, size, false, Offsets.size()); - Offsets.push_back(offset); +#ifdef __BIG_ENDIAN__ + entry.offset = os::Byteswap::byteswap(entry.offset); + entry.length = os::Byteswap::byteswap(entry.length); +#endif + + addItem(io::path(entry.name), entry.length, false, Offsets.size()); + Offsets.push_back(entry.offset); } return true; } diff --git a/source/Irrlicht/CPakReader.h b/source/Irrlicht/CPakReader.h index 22a81586..621afe90 100644 --- a/source/Irrlicht/CPakReader.h +++ b/source/Irrlicht/CPakReader.h @@ -20,13 +20,24 @@ namespace irr { namespace io { + //! File header containing location and size of the table of contents struct SPAKFileHeader { + // Don't change the order of these fields! They must match the order stored on disk. c8 tag[4]; u32 offset; u32 length; }; + //! An entry in the PAK file's table of contents. + struct SPAKFileEntry + { + // Don't change the order of these fields! They must match the order stored on disk. + c8 name[56]; + u32 offset; + u32 length; + }; + //! Archiveloader capable of loading PAK Archives class CArchiveLoaderPAK : public IArchiveLoader { @@ -79,7 +90,6 @@ namespace io // file archive methods //! return the id of the file Archive - virtual const io::path& getArchiveName() const { return File->getFileName(); @@ -99,16 +109,11 @@ namespace io private: - //! scans for a local header, returns false if there is no more local file header. + //! scans for a local header, returns false if the header is invalid bool scanLocalHeader(); - //! splits filename from zip file into useful filenames and paths - //void extractFilename(SPakFileEntry* entry); - IReadFile* File; - SPAKFileHeader header; - //! Contains offsets of the files from the start of the archive file core::array Offsets; }; diff --git a/source/Irrlicht/CSTLMeshFileLoader.cpp b/source/Irrlicht/CSTLMeshFileLoader.cpp index 28382934..720d6812 100644 --- a/source/Irrlicht/CSTLMeshFileLoader.cpp +++ b/source/Irrlicht/CSTLMeshFileLoader.cpp @@ -43,7 +43,9 @@ IAnimatedMesh* CSTLMeshFileLoader::createMesh(io::IReadFile* file) const u32 WORD_BUFFER_LENGTH = 512; SMesh* mesh = new SMesh(); - mesh->addMeshBuffer( new SMeshBuffer() ); + SMeshBuffer* meshBuffer = new SMeshBuffer(); + mesh->addMeshBuffer(meshBuffer); + meshBuffer->drop(); core::vector3df vertex[3]; core::vector3df normal; diff --git a/source/Irrlicht/CSceneManager.cpp b/source/Irrlicht/CSceneManager.cpp index 58ec488a..f5b8501f 100644 --- a/source/Irrlicht/CSceneManager.cpp +++ b/source/Irrlicht/CSceneManager.cpp @@ -662,65 +662,64 @@ IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* pare //! the camera will move too. //! \return Returns pointer to interface to camera ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent, - const core::vector3df& position, const core::vector3df& lookat, s32 id) + const core::vector3df& position, const core::vector3df& lookat, s32 id, + bool makeActive) { if (!parent) parent = this; ICameraSceneNode* node = new CCameraSceneNode(parent, this, id, position, lookat); - node->drop(); - setActiveCamera(node); + if (makeActive) + setActiveCamera(node); + node->drop(); return node; } -//! Adds a camera scene node which is able to be controlld with the mouse similar +//! Adds a camera scene node which is able to be controlled with the mouse similar //! to in the 3D Software Maya by Alias Wavefront. //! The returned pointer must not be dropped. ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent, - f32 rotateSpeed, f32 zoomSpeed, f32 translationSpeed, s32 id) + f32 rotateSpeed, f32 zoomSpeed, f32 translationSpeed, s32 id, + bool makeActive) { - if (!parent) - parent = this; + ICameraSceneNode* node = addCameraSceneNode(parent, core::vector3df(), + core::vector3df(0,0,100), id, makeActive); + if (node) + { + ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraMaya(CursorControl, + rotateSpeed, zoomSpeed, translationSpeed); - ICameraSceneNode* node = new CCameraSceneNode(parent, this, id); - ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraMaya(CursorControl, - rotateSpeed, zoomSpeed, translationSpeed); - - node->addAnimator(anm); - setActiveCamera(node); - - anm->drop(); - node->drop(); + node->addAnimator(anm); + anm->drop(); + } return node; } -//! Adds a camera scene node which is able to be controled with the mouse and keys +//! Adds a camera scene node which is able to be controlled with the mouse and keys //! like in most first person shooters (FPS): ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent, - f32 rotateSpeed, f32 moveSpeed, s32 id, - SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement, f32 jumpSpeed, bool invertMouseY) + f32 rotateSpeed, f32 moveSpeed, s32 id, SKeyMap* keyMapArray, + s32 keyMapSize, bool noVerticalMovement, f32 jumpSpeed, + bool invertMouseY, bool makeActive) { - if (!parent) - parent = this; + ICameraSceneNode* node = addCameraSceneNode(parent, core::vector3df(), + core::vector3df(0,0,100), id, makeActive); + if (node) + { + ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraFPS(CursorControl, + rotateSpeed, moveSpeed, jumpSpeed, + keyMapArray, keyMapSize, noVerticalMovement, invertMouseY); - ICameraSceneNode* node = new CCameraSceneNode(parent, this, id); - ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraFPS(CursorControl, - rotateSpeed, moveSpeed, jumpSpeed, - keyMapArray, keyMapSize, noVerticalMovement, invertMouseY); - - // Bind the node's rotation to its target. This is consistent with 1.4.2 and below. - node->bindTargetAndRotation(true); - - node->addAnimator(anm); - setActiveCamera(node); - - anm->drop(); - node->drop(); + // Bind the node's rotation to its target. This is consistent with 1.4.2 and below. + node->bindTargetAndRotation(true); + node->addAnimator(anm); + anm->drop(); + } return node; } @@ -1099,8 +1098,8 @@ ICameraSceneNode* CSceneManager::getActiveCamera() const //! \param camera: The new camera which should be active. void CSceneManager::setActiveCamera(ICameraSceneNode* camera) { - if (camera) - camera->grab(); + if (camera) + camera->grab(); if (ActiveCamera) ActiveCamera->drop(); @@ -1346,7 +1345,7 @@ void CSceneManager::drawAll() camWorldPos.set(0,0,0); if ( ActiveCamera ) { - ActiveCamera->OnRegisterSceneNode(); + ActiveCamera->render(); camWorldPos = ActiveCamera->getAbsolutePosition(); } @@ -2488,6 +2487,22 @@ void CSceneManager::serializeAttributes(io::IAttributes* out, io::SAttributeRead out->addString ("Name", Name.c_str()); out->addInt ("Id", ID ); out->addColorf ("AmbientLight", AmbientLight); + + // fog attributes from video driver + video::SColor color; + video::E_FOG_TYPE fogType; + f32 start, end, density; + bool pixelFog, rangeFog; + + Driver->getFog(color, fogType, start, end, density, pixelFog, rangeFog); + + out->addEnum("FogType", fogType, video::FogTypeNames); + out->addColorf("FogColor", color); + out->addFloat("FogStart", start); + out->addFloat("FogEnd", end); + out->addFloat("FogDensity", density); + out->addBool("FogPixel", pixelFog); + out->addBool("FogRange", rangeFog); } //! Reads attributes of the scene node. @@ -2497,6 +2512,23 @@ void CSceneManager::deserializeAttributes(io::IAttributes* in, io::SAttributeRea ID = in->getAttributeAsInt("Id"); AmbientLight = in->getAttributeAsColorf("AmbientLight"); + // fog attributes + video::SColor color; + video::E_FOG_TYPE fogType; + f32 start, end, density; + bool pixelFog, rangeFog; + if (in->existsAttribute("FogType")) + { + fogType = (video::E_FOG_TYPE) in->getAttributeAsEnumeration("FogType", video::FogTypeNames); + color = in->getAttributeAsColorf("FogColor").toSColor(); + start = in->getAttributeAsFloat("FogStart"); + end = in->getAttributeAsFloat("FogEnd"); + density = in->getAttributeAsFloat("FogDensity"); + pixelFog = in->getAttributeAsBool("FogPixel"); + rangeFog = in->getAttributeAsBool("FogRange"); + Driver->setFog(color, fogType, start, end, density, pixelFog, rangeFog); + } + RelativeTranslation.set(0,0,0); RelativeRotation.set(0,0,0); RelativeScale.set(1,1,1); @@ -2526,7 +2558,11 @@ const video::SColorf& CSceneManager::getAmbientLight() const //! Get a skinned mesh, which is not available as header-only code ISkinnedMesh* CSceneManager::createSkinnedMesh() { +#ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_ return new CSkinnedMesh(); +#else + return 0; +#endif } //! Returns a mesh writer implementation if available diff --git a/source/Irrlicht/CSceneManager.h b/source/Irrlicht/CSceneManager.h index 3082fa82..171ed2e2 100644 --- a/source/Irrlicht/CSceneManager.h +++ b/source/Irrlicht/CSceneManager.h @@ -133,20 +133,24 @@ namespace scene //! \return Pointer to interface to camera virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, const core::vector3df& position = core::vector3df(0,0,0), - const core::vector3df& lookat = core::vector3df(0,0,100), s32 id=-1); + const core::vector3df& lookat = core::vector3df(0,0,100), + s32 id=-1, bool makeActive=true); //! Adds a camera scene node which is able to be controlle with the mouse similar //! like in the 3D Software Maya by Alias Wavefront. //! The returned pointer must not be dropped. virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, - f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 1500.0f, s32 id=-1); + f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, + f32 translationSpeed = 1500.0f, s32 id=-1, + bool makeActive=true); //! Adds a camera scene node which is able to be controled with the mouse and keys //! like in most first person shooters (FPS): virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1, - SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, - f32 jumpSpeed = 0.f, bool invertMouseY=false); + SKeyMap* keyMapArray=0, s32 keyMapSize=0, + bool noVerticalMovement=false, f32 jumpSpeed = 0.f, + bool invertMouseY=false, bool makeActive=true); //! Adds a dynamic light scene node. The light will cast dynamic light on all //! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING diff --git a/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp b/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp index 1842c08e..a2d34e16 100644 --- a/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp +++ b/source/Irrlicht/CSceneNodeAnimatorCameraMaya.cpp @@ -110,6 +110,11 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) { OldTarget = camera->getTarget(); OldCamera = camera; + LastCameraTarget = OldTarget; + } + else + { + OldTarget += camera->getTarget() - LastCameraTarget; } core::vector3df target = camera->getTarget(); @@ -227,6 +232,7 @@ void CSceneNodeAnimatorCameraMaya::animateNode(ISceneNode *node, u32 timeMs) camera->setPosition(Pos); camera->setTarget(target); camera->setUpVector(upVector); + LastCameraTarget = camera->getTarget(); } diff --git a/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h b/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h index 4350770f..e91c5fdf 100644 --- a/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h +++ b/source/Irrlicht/CSceneNodeAnimatorCameraMaya.h @@ -99,6 +99,7 @@ namespace scene f32 CurrentZoom; f32 RotX, RotY; core::vector3df OldTarget; + core::vector3df LastCameraTarget; // to find out if the camera target was moved outside this animator scene::ICameraSceneNode* OldCamera; core::position2df MousePos; diff --git a/source/Irrlicht/CSceneNodeAnimatorRotation.cpp b/source/Irrlicht/CSceneNodeAnimatorRotation.cpp index 785a241d..3f5592b1 100644 --- a/source/Irrlicht/CSceneNodeAnimatorRotation.cpp +++ b/source/Irrlicht/CSceneNodeAnimatorRotation.cpp @@ -33,11 +33,11 @@ void CSceneNodeAnimatorRotation::animateNode(ISceneNode* node, u32 timeMs) // precision problems with huge floats. core::vector3df rot = node->getRotation() + Rotation*(diffTime*0.1f); if (rot.X>360.f) - fmodf(rot.X, 360.f); + rot.X=fmodf(rot.X, 360.f); if (rot.Y>360.f) - fmodf(rot.Y, 360.f); + rot.Y=fmodf(rot.Y, 360.f); if (rot.Z>360.f) - fmodf(rot.Z, 360.f); + rot.Z=fmodf(rot.Z, 360.f); node->setRotation(rot); StartTime=timeMs; } diff --git a/source/Irrlicht/CSkinnedMesh.cpp b/source/Irrlicht/CSkinnedMesh.cpp index 1ee487aa..0a8f152b 100644 --- a/source/Irrlicht/CSkinnedMesh.cpp +++ b/source/Irrlicht/CSkinnedMesh.cpp @@ -62,7 +62,6 @@ IMesh* CSkinnedMesh::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 return this; animateMesh((f32)frame, 1.0f); - buildAll_LocalAnimatedMatrices(); skinMesh(); return this; } @@ -117,18 +116,18 @@ void CSkinnedMesh::animateMesh(f32 frame, f32 blend) joint->Animatedscale = core::lerp(oldScale, scale, blend); joint->Animatedrotation.slerp(oldRotation, rotation, blend); } - - //Note: - //_LocalAnimatedMatrix needs to be built at some point, but this function may be called lots of times for - //one render (to play two animations at the same time) _LocalAnimatedMatrix only needs to be built once. - //a call to buildAllLocalAnimatedMatrices is needed before skinning the mesh, and before the user gets the joints to move - - //---------------- - // Temp! - buildAll_LocalAnimatedMatrices(); - //----------------- } + //Note: + //_LocalAnimatedMatrix needs to be built at some point, but this function may be called lots of times for + //one render (to play two animations at the same time) _LocalAnimatedMatrix only needs to be built once. + //a call to buildAllLocalAnimatedMatrices is needed before skinning the mesh, and before the user gets the joints to move + + //---------------- + // Temp! + buildAll_LocalAnimatedMatrices(); + //----------------- + updateBoundingBox(); } @@ -462,6 +461,7 @@ void CSkinnedMesh::skinMesh() for (i=0; isize(); ++i) (*SkinningBuffers)[i]->setDirty(EBT_VERTEX); } + updateBoundingBox(); } diff --git a/source/Irrlicht/CSoftwareDriver2.cpp b/source/Irrlicht/CSoftwareDriver2.cpp index f3f79086..6d9a97cc 100644 --- a/source/Irrlicht/CSoftwareDriver2.cpp +++ b/source/Irrlicht/CSoftwareDriver2.cpp @@ -2125,6 +2125,12 @@ void CBurningVideoDriver::drawStencilShadow(bool clearStencilBuffer, video::SCol } +core::dimension2du CBurningVideoDriver::getMaxTextureSize() const +{ + return core::dimension2du(SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE, SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE); +} + + } // end namespace video } // end namespace irr @@ -2149,3 +2155,4 @@ IVideoDriver* createSoftwareDriver2(const core::dimension2d& windowSize, bo } // end namespace video } // end namespace irr + diff --git a/source/Irrlicht/CSoftwareDriver2.h b/source/Irrlicht/CSoftwareDriver2.h index c5df9b9d..09679b01 100644 --- a/source/Irrlicht/CSoftwareDriver2.h +++ b/source/Irrlicht/CSoftwareDriver2.h @@ -154,6 +154,9 @@ namespace video //! Returns the graphics card vendor name. virtual core::stringc getVendorInfo(); + //! Returns the maximum texture size supported. + virtual core::dimension2du getMaxTextureSize() const; + protected: diff --git a/source/Irrlicht/CTRGouraud2.cpp b/source/Irrlicht/CTRGouraud2.cpp index aad5e9b6..61702585 100644 --- a/source/Irrlicht/CTRGouraud2.cpp +++ b/source/Irrlicht/CTRGouraud2.cpp @@ -265,9 +265,9 @@ void CTRGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4D const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRGouraudAlpha2.cpp b/source/Irrlicht/CTRGouraudAlpha2.cpp index 95c72098..dab272b4 100644 --- a/source/Irrlicht/CTRGouraudAlpha2.cpp +++ b/source/Irrlicht/CTRGouraudAlpha2.cpp @@ -276,9 +276,9 @@ void CTRGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,cons const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp b/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp index a17302e4..50c52ef1 100644 --- a/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp +++ b/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp @@ -278,9 +278,9 @@ void CTRGouraudAlphaNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,c const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureBlend.cpp b/source/Irrlicht/CTRTextureBlend.cpp index 19412bcc..736796e6 100644 --- a/source/Irrlicht/CTRTextureBlend.cpp +++ b/source/Irrlicht/CTRTextureBlend.cpp @@ -2004,9 +2004,9 @@ void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureDetailMap2.cpp b/source/Irrlicht/CTRTextureDetailMap2.cpp index a9131651..0f334588 100644 --- a/source/Irrlicht/CTRTextureDetailMap2.cpp +++ b/source/Irrlicht/CTRTextureDetailMap2.cpp @@ -282,9 +282,9 @@ void CTRTextureDetailMap2::drawTriangle ( const s4DVertex *a,const s4DVertex *b, const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureGouraud2.cpp b/source/Irrlicht/CTRTextureGouraud2.cpp index 42707489..5bf84556 100644 --- a/source/Irrlicht/CTRTextureGouraud2.cpp +++ b/source/Irrlicht/CTRTextureGouraud2.cpp @@ -294,9 +294,9 @@ void CTRTextureGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,co const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureGouraudAdd2.cpp b/source/Irrlicht/CTRTextureGouraudAdd2.cpp index a42c7879..0ec81e8b 100644 --- a/source/Irrlicht/CTRTextureGouraudAdd2.cpp +++ b/source/Irrlicht/CTRTextureGouraudAdd2.cpp @@ -302,9 +302,9 @@ void CTRTextureGouraudAdd2::drawTriangle ( const s4DVertex *a,const s4DVertex *b const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); // find if the major edge is left or right aligned f32 temp[4]; diff --git a/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp b/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp index a7639609..02770668 100644 --- a/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp +++ b/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp @@ -270,9 +270,9 @@ void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureGouraudAlpha.cpp b/source/Irrlicht/CTRTextureGouraudAlpha.cpp index deb2c5a2..1e651f53 100644 --- a/source/Irrlicht/CTRTextureGouraudAlpha.cpp +++ b/source/Irrlicht/CTRTextureGouraudAlpha.cpp @@ -363,9 +363,9 @@ void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp b/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp index 6538ec4d..394f41ed 100644 --- a/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp +++ b/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp @@ -363,9 +363,9 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle ( const s4DVertex *a,const s4DVerte const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureGouraudNoZ2.cpp b/source/Irrlicht/CTRTextureGouraudNoZ2.cpp index 01c83c79..a05af5a2 100644 --- a/source/Irrlicht/CTRTextureGouraudNoZ2.cpp +++ b/source/Irrlicht/CTRTextureGouraudNoZ2.cpp @@ -266,9 +266,9 @@ void CTRTextureGouraudNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp b/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp index 92cda9e8..02a953ca 100644 --- a/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp +++ b/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp @@ -309,9 +309,9 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex * const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureLightMap2_Add.cpp b/source/Irrlicht/CTRTextureLightMap2_Add.cpp index 89360c0a..b7b7244c 100644 --- a/source/Irrlicht/CTRTextureLightMap2_Add.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_Add.cpp @@ -290,9 +290,9 @@ void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureLightMap2_M1.cpp b/source/Irrlicht/CTRTextureLightMap2_M1.cpp index 7fc0a73f..f1b262b9 100644 --- a/source/Irrlicht/CTRTextureLightMap2_M1.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_M1.cpp @@ -260,9 +260,9 @@ void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex * const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureLightMap2_M2.cpp b/source/Irrlicht/CTRTextureLightMap2_M2.cpp index 4d4fc350..2591502b 100644 --- a/source/Irrlicht/CTRTextureLightMap2_M2.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_M2.cpp @@ -260,9 +260,9 @@ void CTRTextureLightMap2_M2::drawTriangle ( const s4DVertex *a,const s4DVertex * const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureLightMap2_M4.cpp b/source/Irrlicht/CTRTextureLightMap2_M4.cpp index 8cbf465f..80a245e7 100644 --- a/source/Irrlicht/CTRTextureLightMap2_M4.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_M4.cpp @@ -588,14 +588,13 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex *a,const s4DVert const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; - // find if the major edge is left or right aligned f32 temp[4]; @@ -962,9 +961,9 @@ void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex * const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp b/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp index 2da69b99..4097d9de 100644 --- a/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp +++ b/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp @@ -304,9 +304,9 @@ void CTRGTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f; - scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f; - scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f; + scan.invDeltaY[0] = core::reciprocal( ca ); + scan.invDeltaY[1] = core::reciprocal( ba ); + scan.invDeltaY[2] = core::reciprocal( cb ); if ( F32_LOWER_0 ( scan.invDeltaY[0] ) ) return; diff --git a/source/Irrlicht/CTarReader.cpp b/source/Irrlicht/CTarReader.cpp index 04d92222..13604dce 100644 --- a/source/Irrlicht/CTarReader.cpp +++ b/source/Irrlicht/CTarReader.cpp @@ -10,7 +10,9 @@ #include "CLimitReadFile.h" #include "os.h" #include "coreutil.h" +#if !defined(_IRR_WINDOWS_CE_PLATFORM_) #include "errno.h" +#endif namespace irr { @@ -202,8 +204,10 @@ u32 CTarReader::populateFileList() } u32 size = strtoul(sSize.c_str(), NULL, 8); +#if !defined(_IRR_WINDOWS_CE_PLATFORM_) if (errno == ERANGE) os::Printer::log("File too large", fullPath, ELL_WARNING); +#endif // save start position u32 offset = pos + 512; diff --git a/source/Irrlicht/CTerrainSceneNode.cpp b/source/Irrlicht/CTerrainSceneNode.cpp index ca12be07..a7f77089 100644 --- a/source/Irrlicht/CTerrainSceneNode.cpp +++ b/source/Irrlicht/CTerrainSceneNode.cpp @@ -1101,10 +1101,10 @@ namespace scene for (s32 x = 1; x < TerrainData.Size - 1; ++x) { mb->getVertexBuffer()[x + yd].Pos.Y = - (mb->getVertexBuffer()[x-1 + yd].Pos.Y + - mb->getVertexBuffer()[x+1 + yd].Pos.Y + - mb->getVertexBuffer()[x + yd - TerrainData.Size].Pos.Y + - mb->getVertexBuffer()[x + yd - TerrainData.Size].Pos.Y) * 0.25f; + (mb->getVertexBuffer()[x-1 + yd].Pos.Y + //left + mb->getVertexBuffer()[x+1 + yd].Pos.Y + //right + mb->getVertexBuffer()[x + yd - TerrainData.Size].Pos.Y + //above + mb->getVertexBuffer()[x + yd + TerrainData.Size].Pos.Y) * 0.25f; //below } yd += TerrainData.Size; } diff --git a/source/Irrlicht/Irrlicht7.1.vcproj b/source/Irrlicht/Irrlicht7.1.vcproj index 8c25d151..b6c203fc 100644 --- a/source/Irrlicht/Irrlicht7.1.vcproj +++ b/source/Irrlicht/Irrlicht7.1.vcproj @@ -1667,12 +1667,6 @@ - - - - @@ -1972,30 +1966,30 @@ - - - - - - - - + + + + + + + + diff --git a/source/Irrlicht/Irrlicht8.0.vcproj b/source/Irrlicht/Irrlicht8.0.vcproj index a9766994..775216b4 100644 --- a/source/Irrlicht/Irrlicht8.0.vcproj +++ b/source/Irrlicht/Irrlicht8.0.vcproj @@ -1613,6 +1613,10 @@ RelativePath=".\glext.h" > + + + + @@ -2229,10 +2237,6 @@ RelativePath=".\CPLYMeshFileLoader.h" > - - @@ -2738,22 +2742,6 @@ RelativePath=".\CMemoryFile.h" > - - - - - - - - @@ -2762,6 +2750,18 @@ RelativePath="CMountPointReader.h" > + + + + + + @@ -2770,6 +2770,14 @@ RelativePath="CReadFile.h" > + + + + diff --git a/source/Irrlicht/Makefile b/source/Irrlicht/Makefile index 5cc7fb9c..d8d61e4d 100644 --- a/source/Irrlicht/Makefile +++ b/source/Irrlicht/Makefile @@ -54,7 +54,7 @@ OGLESINCLUDES = -I$(HOME)/irrlicht/SDKPackage-ogles1/Builds/OGLES/Include -I$(HO OGLESLINK = -L$(HOME)/irrlicht/SDKPackage-ogles1/Builds/OGLES/LinuxPC/Lib -lGLES_CM CXXINCS = -I../../include -Izlib -Ijpeglib -Ilibpng CPPFLAGS = $(CXXINCS) $(OGLESINCLUDES) -DIRRLICHT_EXPORTS=1 -CXXFLAGS = -Wall -pipe -fno-exceptions -fno-rtti -fstrict-aliasing +CXXFLAGS += -Wall -pipe -fno-exceptions -fno-rtti -fstrict-aliasing ifndef NDEBUG CXXFLAGS += -g -D_DEBUG else @@ -65,8 +65,8 @@ CXXFLAGS += -pg endif CFLAGS := -fexpensive-optimizations -O3 -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES -sharedlib sharedlib_osx: CXXFLAGS += -fpic -sharedlib sharedlib_osx: CFLAGS += -fpic +sharedlib sharedlib_osx: CXXFLAGS += -fPIC +sharedlib sharedlib_osx: CFLAGS += -fPIC #multilib handling ifeq ($(HOSTTYPE), x86_64) @@ -76,11 +76,10 @@ endif #Linux specific options staticlib sharedlib install: SYSTEM = Linux STATIC_LIB = libIrrlicht.a -IRRLICHT_DLL := ../../bin/Win32-gcc/Irrlicht.dll LIB_PATH = ../../lib/$(SYSTEM) INSTALL_DIR = /usr/local/lib sharedlib install: SHARED_LIB = libIrrlicht.so -staticlib sharedlib: LDFLAGS = --no-export-all-symbols --add-stdcall-alias +staticlib sharedlib: LDFLAGS += --no-export-all-symbols --add-stdcall-alias sharedlib: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm staticlib sharedlib: CXXINCS += -I/usr/X11R6/include @@ -89,12 +88,13 @@ staticlib_osx sharedlib_osx install_osx: SYSTEM = MacOSX staticlib_osx sharedlib_osx: IRROTHEROBJ += MacOSX/CIrrDeviceMacOSX.o MacOSX/OSXClipboard.o MacOSX/AppDelegate.o staticlib_osx sharedlib_osx: CXXINCS += -IMacOSX -I/usr/X11R6/include sharedlib_osx install_osx: SHARED_LIB = libIrrlicht.dylib -staticlib_osx sharedlib_osx: LDFLAGS = --no-export-all-symbols --add-stdcall-alias +staticlib_osx sharedlib_osx: LDFLAGS += --no-export-all-symbols --add-stdcall-alias sharedlib_osx: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm #Windows specific options +IRRLICHT_DLL := ../../bin/Win32-gcc/Irrlicht.dll sharedlib_win32 staticlib_win32: SYSTEM = Win32-gcc -sharedlib_win32: LDFLAGS = -lgdi32 -lopengl32 -ld3dx9d -lwinmm +sharedlib_win32: LDFLAGS += -lgdi32 -lopengl32 -ld3dx9d -lwinmm sharedlib_win32 staticlib_win32: CPPFLAGS += -DIRR_COMPILE_WITH_DX9_DEV_PACK -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_ @@ -104,7 +104,7 @@ all linux: staticlib # Builds Irrlicht as shared lib (libIrrlicht.so.versionNumber) and copies it into /lib/Linux sharedlib: $(LINKOBJ) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -Wl,-soname,$(SHARED_LIB).$(VERSION_MAJOR).$(VERSION_MINOR) -fPIC -o $(SHARED_LIB).$(VERSION) $^ $(LDFLAGS) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -Wl,-soname,$(SHARED_LIB).$(VERSION_MAJOR).$(VERSION_MINOR) -o $(SHARED_LIB).$(VERSION) $^ $(LDFLAGS) cp $(SHARED_LIB).$(VERSION) $(LIB_PATH) # Builds Irrlicht as static lib (libIrrlicht.a) @@ -126,25 +126,17 @@ staticlib_win32: $(STATIC_LIB) # Builds Irrlicht as shared lib (libIrrlicht.so.versionNumber) and copies it into /lib/MacOSX sharedlib_osx: $(LINKOBJ) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -dynamiclib -Wl,-install_name,$(SHARED_LIB).$(VERSION_MAJOR).$(VERSION_MINOR) -fPIC -o $(SHARED_LIB).$(VERSION) $^ $(LDFLAGS) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -dynamiclib -Wl,-install_name,$(SHARED_LIB).$(VERSION_MAJOR).$(VERSION_MINOR) -o $(SHARED_LIB).$(VERSION) $^ $(LDFLAGS) cp $(SHARED_LIB).$(VERSION) $(LIB_PATH) # Installs Irrlicht if it was created as shared lib -install: +install install_osx: $(RM) -r $(INSTALL_DIR)/../include/irrlicht mkdir -p $(INSTALL_DIR)/../include/irrlicht cp ../../include/*.h $(INSTALL_DIR)/../include/irrlicht/ cp $(LIB_PATH)/$(SHARED_LIB).$(VERSION) $(INSTALL_DIR) - cd $(INSTALL_DIR) && ln -s -f libIrrlicht.so.$(VERSION) $(SHARED_LIB) - ldconfig -n $(INSTALL_DIR) - -install_osx: - $(RM) -r $(INSTALL_DIR)/../include/irrlicht - mkdir -p $(INSTALL_DIR)/../include/irrlicht - cp ../../include/*.h $(INSTALL_DIR)/../include/irrlicht - cp $(LIB_PATH)/$(SHARED_LIB).$(VERSION) $(INSTALL_DIR) - cd $(INSTALL_DIR) && ln -s libIrrlicht.dylib.$(VERSION) $(SHARED_LIB) - ldconfig -n $(INSTALL_DIR) + cd $(INSTALL_DIR) && ln -s -f $(SHARED_LIB).$(VERSION) $(SHARED_LIB) +# ldconfig -n $(INSTALL_DIR) TAGS: ctags *.cpp ../../include/*.h *.h diff --git a/source/Irrlicht/SoftwareDriver2_helper.h b/source/Irrlicht/SoftwareDriver2_helper.h index 16ec3461..770648af 100644 --- a/source/Irrlicht/SoftwareDriver2_helper.h +++ b/source/Irrlicht/SoftwareDriver2_helper.h @@ -931,7 +931,7 @@ inline s32 intervall_intersect_test( const sIntervall& a, const sIntervall& b) } -} // namespace +} // end namespace irr #endif diff --git a/source/Irrlicht/os.cpp b/source/Irrlicht/os.cpp index 7fdf6fd5..deeb6ffb 100644 --- a/source/Irrlicht/os.cpp +++ b/source/Irrlicht/os.cpp @@ -69,8 +69,8 @@ namespace os tmp += L"\n"; OutputDebugStringW(tmp.c_str()); #else - OutputDebugString(message); - OutputDebugString("\n"); + OutputDebugStringA(message); + OutputDebugStringA("\n"); printf("%s\n", message); #endif } diff --git a/tests/b3dAnimation.cpp b/tests/b3dAnimation.cpp index 27a53872..272059fa 100644 --- a/tests/b3dAnimation.cpp +++ b/tests/b3dAnimation.cpp @@ -40,6 +40,7 @@ bool b3dAnimation(void) node1->setMaterialFlag(EMF_LIGHTING, false); node1->setAnimationSpeed(0.f); node1->setCurrentFrame(10.f); + node1->setDebugDataVisible(irr::scene::EDS_BBOX_BUFFERS); } node2 = smgr->addAnimatedMeshSceneNode(mesh); @@ -50,13 +51,14 @@ bool b3dAnimation(void) node2->setMaterialFlag(EMF_LIGHTING, false); node2->setAnimationSpeed(0.f); node2->setCurrentFrame(62.f); + node2->setDebugDataVisible(irr::scene::EDS_BBOX_BUFFERS); } (void)smgr->addCameraSceneNode(); // Just jump to the last frame since that's all we're interested in. device->run(); - driver->beginScene(true, true, SColor(255, 255, 255, 0)); + driver->beginScene(true, true, SColor(255, 60, 60, 60)); smgr->drawAll(); driver->endScene(); diff --git a/tests/lightMaps.cpp b/tests/lightMaps.cpp new file mode 100644 index 00000000..3a0d1f5f --- /dev/null +++ b/tests/lightMaps.cpp @@ -0,0 +1,65 @@ +// Copyright (C) 2008-2009 Christian Stehno, Colin MacDonald +// No rights reserved: this software is in the public domain. + +#include "testUtils.h" + +using namespace irr; +using namespace core; +using namespace scene; +using namespace video; +using namespace io; +using namespace gui; + +//! Tests lightmaps under all drivers that support them +static bool runTestWithDriver(E_DRIVER_TYPE driverType) +{ + IrrlichtDevice *device = createDevice( driverType, dimension2d(160, 120), 32); + if (!device) + return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs + + IVideoDriver* driver = device->getVideoDriver(); + ISceneManager * smgr = device->getSceneManager(); + + bool result = true; + bool added = device->getFileSystem()->addZipFileArchive("../media/map-20kdm2.pk3"); + assert(added); + + if(added) + { + ISceneNode * node = smgr->addOctTreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024); + assert(node); + + if (node) + { + node->setMaterialFlag(EMF_LIGHTING, false); + node->setPosition(core::vector3df(-1300,-820,-1249)); + node->setScale(core::vector3df(1, 5, 1)); + + (void)smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(40,100,30)); + + driver->beginScene(true, true, video::SColor(255,255,255,0)); + smgr->drawAll(); + driver->endScene(); + + result = takeScreenshotAndCompareAgainstReference(driver, "-lightmaps.png", 96); + } + } + + device->drop(); + + return result; +} + + +bool lightMaps(void) +{ + bool passed = true; + + passed &= runTestWithDriver(EDT_BURNINGSVIDEO); + passed &= runTestWithDriver(EDT_DIRECT3D9); + passed &= runTestWithDriver(EDT_DIRECT3D8); + passed &= runTestWithDriver(EDT_OPENGL); + + return passed; +} + diff --git a/tests/main.cpp b/tests/main.cpp index 78e72986..4540abfe 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -58,6 +58,7 @@ int main(int argumentCount, char * arguments[]) TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory. TEST(filesystem); TEST(zipReader); + TEST(pakReader); TEST(exports); TEST(sceneCollisionManager); TEST(testVector3d); @@ -91,6 +92,8 @@ int main(int argumentCount, char * arguments[]) TEST(enumerateImageManipulators); TEST(testGeometryCreator); TEST(makeColorKeyTexture); + TEST(lightMaps); + TEST(testXML); const unsigned int numberOfTests = tests.size(); diff --git a/tests/media/Burning's Video-b3dAnimation.png b/tests/media/Burning's Video-b3dAnimation.png index 100d2bba..52feb695 100644 Binary files a/tests/media/Burning's Video-b3dAnimation.png and b/tests/media/Burning's Video-b3dAnimation.png differ diff --git a/tests/media/Burning's Video-lightmaps.png b/tests/media/Burning's Video-lightmaps.png new file mode 100644 index 00000000..f53a7e36 Binary files /dev/null and b/tests/media/Burning's Video-lightmaps.png differ diff --git a/tests/media/Direct3D 9.0-lightmaps.png b/tests/media/Direct3D 9.0-lightmaps.png new file mode 100644 index 00000000..f53a7e36 Binary files /dev/null and b/tests/media/Direct3D 9.0-lightmaps.png differ diff --git a/tests/media/OpenGL-lightmaps.png b/tests/media/OpenGL-lightmaps.png new file mode 100644 index 00000000..f53a7e36 Binary files /dev/null and b/tests/media/OpenGL-lightmaps.png differ diff --git a/tests/media/sample_pakfile.pak b/tests/media/sample_pakfile.pak new file mode 100644 index 00000000..68e489a0 Binary files /dev/null and b/tests/media/sample_pakfile.pak differ diff --git a/tests/media/test.xml b/tests/media/test.xml new file mode 100644 index 00000000..d311c1aa --- /dev/null +++ b/tests/media/test.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/pakReader.cpp b/tests/pakReader.cpp new file mode 100644 index 00000000..6de6e85b --- /dev/null +++ b/tests/pakReader.cpp @@ -0,0 +1,52 @@ +#include "testUtils.h" + +using namespace irr; +using namespace core; +using namespace io; + +bool pakReader(void) +{ + IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d(1, 1)); + assert(device); + if(!device) + return false; + + io::IFileSystem * fs = device->getFileSystem (); + if ( !fs ) + return false; + + if ( !fs->addFileArchive(io::path("media/sample_pakfile.pak"), /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) ) + return false; + + // log what we got + io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1); + const io::IFileList* fileList = archive->getFileList(); + for ( u32 f=0; f < fileList->getFileCount(); ++f) + { + logTestString("File name: %s\n", fileList->getFileName(f).c_str()); + logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str()); + } + + bool result = true; + io::path filename("test/test.txt"); + result &= fs->existFile(filename); + if (!result ) + { + logTestString("existFile failed"); + } + IReadFile* readFile = fs->createAndOpenFile(filename); + if ( !readFile ) + { + result = false; + logTestString("createAndOpenFilefailed"); + } + + char tmp[123] = {'\0'}; + readFile->read(tmp, sizeof(tmp)); + if (strncmp(tmp, "Hello world!", sizeof(tmp))) + { + result = false; + logTestString("Read bad data from pak file.\n"); + } + return result; +} diff --git a/tests/terrainSceneNode.cpp b/tests/terrainSceneNode.cpp index 1319e013..c34bfec7 100644 --- a/tests/terrainSceneNode.cpp +++ b/tests/terrainSceneNode.cpp @@ -45,7 +45,7 @@ bool terrainSceneNode(void) driver->endScene(); // Note that this has to be a slightly fuzzier than usual compare to satisfy multiple OpenGL environments - bool result = takeScreenshotAndCompareAgainstReference(driver, "-terrainSceneNode-1.png", 98.24f); + bool result = takeScreenshotAndCompareAgainstReference(driver, "-terrainSceneNode-1.png", 98.22f); if(!result) { logTestString("Small camera up rotation caused bad recalc.\n"); @@ -60,7 +60,7 @@ bool terrainSceneNode(void) smgr->drawAll(); driver->endScene(); - result &= takeScreenshotAndCompareAgainstReference(driver, "-terrainSceneNode-2.png", 98.84f); + result &= takeScreenshotAndCompareAgainstReference(driver, "-terrainSceneNode-2.png", 98.83f); if(!result) { logTestString("Large camera up rotation caused bad recalc.\n"); diff --git a/tests/testUtils.cpp b/tests/testUtils.cpp index a816e32b..8ddce54e 100644 --- a/tests/testUtils.cpp +++ b/tests/testUtils.cpp @@ -142,14 +142,14 @@ static float fuzzyCompareImages(irr::video::IImage * image1, image1->unlock(); image2->unlock(); - const u32 totalColours = pixels * 775; + const u32 totalColours = pixels * 255*3; return 100.f * (totalColours - mismatchedColours) / totalColours; } bool takeScreenshotAndCompareAgainstReference(irr::video::IVideoDriver * driver, - const char * fileName, - irr::f32 requiredMatch) + const char * fileName, + irr::f32 requiredMatch) { irr::video::IImage * screenshot = driver->createScreenShot(); if(!screenshot) @@ -206,7 +206,7 @@ bool takeScreenshotAndCompareAgainstReference(irr::video::IVideoDriver * driver, irr::core::stringc mismatchFilename = "results/"; mismatchFilename += driverName; mismatchFilename += fileName; - logTestString("Writing mismatched image to '%s\n", mismatchFilename.c_str()); + logTestString("Writing mismatched image to '%s'\n", mismatchFilename.c_str()); (void)driver->writeImageToFile(screenshot, mismatchFilename.c_str()); } @@ -265,3 +265,4 @@ void logTestString(const char * format, ...) OutputDebugStringA(logString); #endif // #if defined(TESTING_ON_WINDOWS) } + diff --git a/tests/testVector2d.cpp b/tests/testVector2d.cpp index 458bd9c8..0aa5fab4 100644 --- a/tests/testVector2d.cpp +++ b/tests/testVector2d.cpp @@ -52,7 +52,7 @@ static bool doTests() vec.set(5, 5); vec.normalize(); - compareVectors(vec, vector2d((T)0.70710681378841400, (T)0.70710681378841400)); + COMPARE_VECTORS(vec, vector2d((T)0.70710681378841400, (T)0.70710681378841400)); vec.set(5, 5); otherVec.set(10, 20); @@ -162,6 +162,16 @@ static bool doTests() return false; } + core::vector2d zeroZero(0, 0); + core::vector2d oneOne(1, 1); + // Check if comparing (0.0, 0.0) with (1.0, 1.0) returns false. + if(zeroZero == oneOne) + { + logTestString("\nERROR: vector2d %.16f, %.16f == vector2d %.16f, %.16f\n", + (f64)zeroZero.X, (f64)zeroZero.Y, (f64)oneOne.X, (f64)oneOne.Y); + return false; + } + return true; } diff --git a/tests/testVector3d.cpp b/tests/testVector3d.cpp index a4ef608c..1206f8dc 100644 --- a/tests/testVector3d.cpp +++ b/tests/testVector3d.cpp @@ -126,6 +126,17 @@ static bool doTests() if ( is_nan(vec) ) return false; + core::vector3d zeroZero(0, 0, 0); + core::vector3d oneOne(1, 1, 1); + // Check if comparing (0.0, 0.0, 0.0) with (1.0, 1.0, 1.0) returns false. + if(zeroZero == oneOne) + { + logTestString("\nERROR: vector3d %.16f, %.16f, %.16f == vector3d %.16f, %.16f, %.16f\n", + (f64)zeroZero.X, (f64)zeroZero.Y, (f64)zeroZero.Z, + (f64)oneOne.X, (f64)oneOne.Y, (f64)oneOne.Z); + return false; + } + return true; } diff --git a/tests/testXML.cpp b/tests/testXML.cpp new file mode 100644 index 00000000..19a15c4d --- /dev/null +++ b/tests/testXML.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2009 Christian Stehno +// No rights reserved: this software is in the public domain. + +#include "testUtils.h" + +using namespace irr; +using namespace core; + +/** Tests for XML handling */ +bool testXML(void) +{ + IrrlichtDevice *device = createDevice(video::EDT_NULL, dimension2du(400, 200)); + + io::IXMLReaderUTF8* reader = device->getFileSystem()->createXMLReaderUTF8("media/test.xml"); + if (!reader) + { + logTestString("Could not create XML reader.\n"); + return false; + } + + const core::stringc expected[] = { + "a", "b", "c" + }; + + bool retVal = true; + u32 i=0; + while(reader->read()) + { + if (reader->getNodeType() == io::EXN_ELEMENT) + { + if (expected[i++] != reader->getNodeName()) + { + logTestString("Did not find expected string in XML element name.\n"); + retVal = false; + break; + } + } + } + + reader->drop(); + return retVal; +} + diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 44fe6c6e..8d848c37 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,2 +1,2 @@ -Test suite pass at GMT Wed Sep 9 14:11:32 2009 +Test suite pass at GMT Wed Oct 28 15:55:33 2009 diff --git a/tests/tests.cbp b/tests/tests.cbp index 171a70e1..b633a42c 100644 --- a/tests/tests.cbp +++ b/tests/tests.cbp @@ -14,6 +14,9 @@ + + + + + diff --git a/tests/textureRenderStates.cpp b/tests/textureRenderStates.cpp index e7b138a4..8bd2cb2a 100644 --- a/tests/textureRenderStates.cpp +++ b/tests/textureRenderStates.cpp @@ -49,11 +49,11 @@ bool textureRenderStates(void) { bool passed = true; + passed &= runTestWithDriver(EDT_OPENGL); passed &= runTestWithDriver(EDT_SOFTWARE); passed &= runTestWithDriver(EDT_BURNINGSVIDEO); passed &= runTestWithDriver(EDT_DIRECT3D9); passed &= runTestWithDriver(EDT_DIRECT3D8); - passed &= runTestWithDriver(EDT_OPENGL); return passed; } diff --git a/tools/GUIEditor/CGUIEditWindow.cpp b/tools/GUIEditor/CGUIEditWindow.cpp index b5283ba5..05b2b5be 100644 --- a/tools/GUIEditor/CGUIEditWindow.cpp +++ b/tools/GUIEditor/CGUIEditWindow.cpp @@ -45,7 +45,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect rec TabControl->setSubElement(true); TabControl->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - IGUITab* ToolsTab = TabControl->addTab(L"Tools"); + TabControl->addTab(L"Tools"); //L"Texture Cache Browser" //L"Font Browser" //L"Font Generator" diff --git a/tools/GUIEditor/CGUIPanel.cpp b/tools/GUIEditor/CGUIPanel.cpp index 9f981a14..7cd95957 100644 --- a/tools/GUIEditor/CGUIPanel.cpp +++ b/tools/GUIEditor/CGUIPanel.cpp @@ -275,6 +275,7 @@ void CGUIPanel::resizeInnerPane() { HScrollBar->setVisible(true); HScrollBar->setMax(totalRect.getWidth() - outerRect.getWidth()); + bringToFront(HScrollBar); } else HScrollBar->setVisible(false); @@ -284,6 +285,7 @@ void CGUIPanel::resizeInnerPane() { VScrollBar->setVisible(true); VScrollBar->setMax(totalRect.getHeight() - outerRect.getHeight()); + bringToFront(VScrollBar); } else VScrollBar->setVisible(false); diff --git a/tools/GUIEditor/main.cpp b/tools/GUIEditor/main.cpp index 1e4292cc..413cdc04 100644 --- a/tools/GUIEditor/main.cpp +++ b/tools/GUIEditor/main.cpp @@ -74,8 +74,6 @@ int main() now we add the GUI Editor Workspace */ - env->loadGUI("guiTest.xml"); - env->addGUIElement("GUIEditor"); while(device->run())