00001
00002 #include "main.h"
00003 #include "physxDebugHelper.h"
00004 #include "irrlichtWrapper.h"
00005 #include "physxWrapper.h"
00006
00007
00008
00009 #define SCREEN_WIDTH 1024//1280
00010 #define SCREEN_HEIGHT SCREEN_WIDTH/16*9//768//960
00011
00012
00013
00014 static NxDebugRenderer* nxDebugRenderer = NULL;
00015
00016
00017
00018 ERR_TYPE irrlichtInit()
00019 {
00020
00021
00022 device = createDevice( EDT_DIRECT3D9, dimension2d<s32>(SCREEN_WIDTH, SCREEN_HEIGHT), 32, false, true );
00023 if ( NULL == device )
00024 {
00025
00026 device = createDevice( EDT_OPENGL, dimension2d<s32>(SCREEN_WIDTH, SCREEN_HEIGHT), 32, false, true );
00027 if ( NULL == device )
00028 {
00029
00030 device = createDevice( EDT_BURNINGSVIDEO, dimension2d<s32>(SCREEN_WIDTH, SCREEN_HEIGHT) );
00031 if ( NULL == device )
00032 {
00033 return ERR_IRRLICHT_INIT_FAILED;
00034 }
00035 }
00036 }
00037
00038 driver = device->getVideoDriver();
00039 smgr = device->getSceneManager();
00040 guienv = device->getGUIEnvironment();
00041 logger = device->getLogger();
00042 timer = device->getTimer();
00043
00044
00045 nxDebugRenderer = new NxDebugRenderer();
00046
00047
00048 IGUIStaticText* text = guienv->addStaticText( stringw("loading").c_str(),
00049 rect<s32>( SCREEN_WIDTH/2-16,
00050 SCREEN_HEIGHT/2-6,
00051 SCREEN_WIDTH/2+17,
00052 SCREEN_HEIGHT/2+6),
00053 true,
00054 true,
00055 NULL,
00056 -1,
00057 true );
00058 driver->beginScene( true, true, SColor(0) );
00059 guienv->drawAll();
00060 driver->endScene();
00061 text->remove();
00062
00063
00064 driver->setTextureCreationFlag( ETCF_CREATE_MIP_MAPS, false );
00065
00066 driver->setTextureCreationFlag( ETCF_ALWAYS_32_BIT, true );
00067
00068 return ERR_OK;
00069 }
00070
00071
00072
00073 ERR_TYPE irrlichtUpdate()
00074 {
00075 static s32 lastFPS = 0;
00076 static bool firstCall = true;
00077
00078 if ( device->run() )
00079 {
00080 if ( 1 )
00081 {
00082
00083 if ( true == firstCall )
00084 {
00085 IGUIInOutFader* fader = device->getGUIEnvironment()->addInOutFader();
00086 fader->setColor( SColor(0) );
00087 fader->fadeIn( 4000 );
00088 firstCall = false;
00089 }
00090
00091
00092 driver->beginScene( true, true, SColor(255, 100, 100, 100) );
00093
00094
00095 smgr->drawAll();
00096 guienv->drawAll();
00097
00098
00099
00100 if ( true == getPhysxDebugRenderingEnabled() )
00101 {
00102 nxDebugRenderer->update( 0 );
00103 }
00104
00105 driver->endScene();
00106
00107
00108 s32 fps = driver->getFPS();
00109
00110 if ( lastFPS != fps )
00111 {
00112 stringw str(L"");
00113 str += fps;
00114 str += " FPS";
00115
00116 device->setWindowCaption( str.c_str() );
00117 lastFPS = fps;
00118 }
00119 }
00120 return ERR_OK;
00121 }
00122
00123
00124 return ERR_IRRLICHT_UPDATE_FAILED;
00125 }
00126
00127
00128
00129 ERR_TYPE irrlichtDeinit()
00130 {
00131 if ( nxDebugRenderer )
00132 {
00133 delete nxDebugRenderer;
00134 nxDebugRenderer = NULL;
00135 }
00136
00137 if ( device )
00138 {
00139 device->drop();
00140 device = NULL;
00141 }
00142
00143 return ERR_OK;
00144 }