00001
00026 #ifndef _GRAPHICS_
00027 #define _GRAPHICS_
00028
00029 #include <Level2D.h>
00030 #include <string>
00031 #include <iostream>
00032 #include <sstream>
00033 #include <irrlicht.h>
00034 #include <CustomVertexObject.h>
00035 #include <disableWarnings.h>
00036
00037 namespace sonus
00038 {
00039 using namespace irr;
00040
00052 struct GlobalFunction
00053 {
00054 irr::EKEY_CODE key;
00055 void ( *pfunction )();
00056 };
00057
00069 struct GlobalBoolean
00070 {
00071 irr::EKEY_CODE key;
00072 bool* value;
00073 bool setValue;
00074 };
00075
00087 struct ChangingValue
00088 {
00089 const char* name;
00090 int* value;
00091 int step;
00092 };
00093
00105 struct IncrementalValue
00106 {
00107 irr::EKEY_CODE key;
00108 int* value;
00109 int step;
00110 int min;
00111 int max;
00112 };
00113
00114
00138 class Graphics : public irr::IEventReceiver
00139 {
00140
00141 public:
00142
00156 virtual bool Graphics::OnEvent(SEvent event);
00157
00158 static bool fullscreen;
00159 static int resolutionX;
00160 static int resolutionY;
00161
00168 static Graphics* getInstance()
00169 {
00170 if ( instance == NULL )
00171 {
00172 instance = new Graphics();
00173 }
00174
00175 return instance;
00176 }
00177
00182 ~Graphics();
00183
00191 void initLevel( Level2D* level );
00192
00202 void update( Level2D* level );
00203
00208 void beginRender();
00209
00214 void renderViewports();
00215
00222 void renderConsole();
00223
00230 void renderStatus();
00231
00236 void renderBlend();
00237
00243 void endRender();
00244
00253 void addGlobalFunction( irr::EKEY_CODE irrKey, void ( *pfunction )() );
00254
00264 void addGlobalBoolean( irr::EKEY_CODE irrKey, bool* value, bool setValue );
00265
00279 void addIncrementalValue( irr::EKEY_CODE irrKey, int* value, int min, int max, int step );
00280
00290 void setChangingValue( const char* name, int* value, int step );
00291
00292 std::wstringstream consoleText;
00293 scene::ISceneManager* smgr;
00294 IrrlichtDevice* device;
00295 video::IVideoDriver* driver;
00296 gui::IGUIEnvironment* env;
00297 gui::IGUIStaticText* textbox;
00298 gui::IGUIStaticText* status;
00299
00300 int viewportMode;
00301
00302 double portalAnimation;
00303 bool portalAnimationFinished;
00304 int portalBlend;
00305 long portalAnimationStart;
00306
00307 Vector2D* transformationVector;
00308 double scaleFactor;
00309
00310 private:
00311
00320 void addBodyToScene( Body2D<Vector2D>* body );
00321
00322 Graphics();
00323
00324 static Graphics* instance;
00325
00326 scene::ICameraSceneNode* camera1;
00327 scene::ICameraSceneNode* camera2;
00328 scene::ICameraSceneNode* camera3;
00329 scene::ICameraSceneNode* camera4;
00330
00331 std::wstring consoleTextString;
00332 CustomVertexObject* player;
00333 scene::ISceneNode* portal;
00334 scene::ISceneNode* portal2;
00335 scene::ISceneNode* portal3;
00336 scene::ISceneNode* portal4;
00337 core::rect<s32> oldViewPort;
00338
00339 float playerRadius;
00340 long portalScaleT0;
00341 double portalScale;
00342
00343 GlobalFunction globalFunctions[ 10 ];
00344 int globalFunctionsIndex;
00345
00346 GlobalBoolean globalBooleans[ 50 ];
00347 int globalBooleansIndex;
00348
00349 IncrementalValue incrementalValues[ 10 ];
00350 int incrementalValuesIndex;
00351
00352 ChangingValue changingValue;
00353
00354
00355
00356 };
00357
00358 }
00359
00360 #endif