Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_SOFTPIXELDEVICE_H__
00009 #define __SP_SOFTPIXELDEVICE_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spDimension.hpp"
00014 #include "Base/spInputOutput.hpp"
00015 #include "RenderSystem/spRenderSystem.hpp"
00016 #include "RenderSystem/spRenderContext.hpp"
00017 #include "SceneGraph/spSceneManager.hpp"
00018 #include "SceneGraph/spSceneGraph.hpp"
00019 #include "SceneGraph/spSceneGraphSimple.hpp"
00020 #include "SceneGraph/spSceneGraphSimpleStream.hpp"
00021 #include "SceneGraph/spSceneGraphFamilyTree.hpp"
00022 #include "SoundSystem/spSoundDevice.hpp"
00023 #include "Platform/spSoftPixelDeviceFlags.hpp"
00024 #include "Framework/Physics/spPhysicsSimulator.hpp"
00025 #include "Framework/Network/spNetworkStructures.hpp"
00026
00027 #if defined(SP_PLATFORM_ANDROID)
00028 # include "Platform/Android/android_native_app_glue.h"
00029 #endif
00030
00031
00032 namespace sp
00033 {
00034
00035
00036
00037
00038
00039
00040 namespace gui
00041 {
00042 class GUIManager;
00043 }
00044
00045 namespace scene
00046 {
00047 class CollisionGraph;
00048 };
00049
00050 #ifdef SP_COMPILE_WITH_NETWORKSYSTEM
00051 namespace network
00052 {
00053 class NetworkSystem;
00054 }
00055 #endif
00056
00057 #ifdef SP_COMPILE_WITH_CG
00058 namespace video
00059 {
00060 class CgShaderContext;
00061 }
00062 #endif
00063
00064
00066 class SP_EXPORT SoftPixelDevice
00067 {
00068
00069 public:
00070
00071 virtual ~SoftPixelDevice();
00072
00073
00074
00076 video::RenderSystem* getRenderSystem() const;
00081 video::RenderContext* getRenderContext() const;
00082
00084 scene::SceneManager* getSceneManager() const;
00085
00087 io::InputControl* getInputControl() const;
00089 io::OSInformator* getOSInformator() const;
00090
00092 gui::GUIManager* getGUIManager() const;
00093
00095 audio::SoundDevice* createSoundDevice(const audio::ESoundDevices Type = audio::SOUNDDEVICE_AUTODETECT);
00096 void deleteSoundDevice(audio::SoundDevice* SoundDevice);
00097
00098 #ifdef SP_COMPILE_WITH_PHYSICS
00099
00104 physics::PhysicsSimulator* createPhysicsSimulator(const physics::EPhysicsSimulators Type);
00105 void deletePhysicsSimulator(physics::PhysicsSimulator* Simulator);
00106 #endif
00107
00108 #ifdef SP_COMPILE_WITH_NETWORKSYSTEM
00109
00114 network::NetworkSystem* createNetworkSystem(const network::ENetworkSystems Type);
00115 void deleteNetworkSystem(network::NetworkSystem* NetSys);
00116 #endif
00117
00118 #ifdef SP_COMPILE_WITH_CG
00119
00120 video::CgShaderContext* createCgShaderContext();
00121 void deleteCgShaderContext();
00122 #endif
00123
00130 scene::SceneGraph* createSceneGraph(const scene::ESceneGraphs Type = scene::SCENEGRAPH_SIMPLE);
00131 void deleteSceneGraph(scene::SceneGraph* SceneGraph);
00132
00134 template <class T> T* createSceneGraph()
00135 {
00136 T* NewSceneGraph = new T();
00137
00138 SceneGraphList_.push_back(NewSceneGraph);
00139 setActiveSceneGraph(NewSceneGraph);
00140
00141 return NewSceneGraph;
00142 }
00143
00145 scene::CollisionGraph* createCollisionGraph();
00146 void deleteCollisionGraph(scene::CollisionGraph* CollGraph);
00147
00158 video::RenderContext* createRenderContext(
00159 void* ParentWindow, const dim::size2di &Resolution, const io::stringc &Title = ""
00160 );
00161
00167 void deleteRenderContext(video::RenderContext* Context);
00168
00182 virtual bool updateDeviceSettings(
00183 const dim::size2di &Resolution, s32 ColorDepth = DEF_COLORDEPTH, bool isFullscreen = false,
00184 const SDeviceFlags &Flags = SDeviceFlags(), void* ParentWindow = 0
00185 );
00186
00193 virtual bool updateEvents() = 0;
00194
00196 void updateBaseEvents();
00197
00203 void setActiveSceneGraph(scene::SceneGraph* ActiveSceneGraph);
00204 scene::SceneGraph* getActiveSceneGraph() const;
00205
00212 virtual void setFrameRate(u32 FrameRate = DEF_FRAMERATE);
00213
00215 virtual io::stringc getVersion() const;
00216
00218 virtual void beep(u32 Milliseconds = 100, u32 Frequency = 1000);
00219
00224 virtual void manipulateScreenSize(const dim::size2di &ScreenSize);
00225
00232 virtual s32 registerFontResource(const io::stringc &Filename);
00234 virtual void unregisterFontResource(const io::stringc &Filename);
00235
00236
00237
00239 inline dim::size2di getResolution() const
00240 {
00241 return Resolution_;
00242 }
00243
00245 inline SDeviceFlags getFlags() const
00246 {
00247 return Flags_;
00248 }
00249
00250 #ifdef SP_COMPILE_WITH_NETWORKSYSTEM
00251
00252 inline const std::list<network::NetworkSystem*>& getNetworkSystemList() const
00253 {
00254 return NetworkSystemList_;
00255 }
00256
00257 #endif
00258
00259 protected:
00260
00261
00262
00263 SoftPixelDevice(
00264 const video::ERenderSystems RendererType, const dim::size2di &Resolution,
00265 s32 ColorDepth, bool isFullscreen, const SDeviceFlags &Flags
00266 );
00267
00268 virtual void autoDetectRenderSystem();
00269 virtual bool checkRenderSystem(const video::ERenderSystems Type) const;
00270
00271 virtual bool createRenderSystemAndContext();
00272 virtual video::RenderSystem* allocRenderSystem();
00273 virtual video::RenderContext* allocRenderContext();
00274
00275 virtual void deleteResourceDevices();
00276 virtual void releaseGraphicsContext();
00277
00278 virtual void printConsoleHeader();
00279
00280 #ifdef SP_COMPILE_WITH_SOUNDSYSTEM
00281 audio::SoundDevice* allocSoundDevice(audio::ESoundDevices DeviceType) const;
00282 #endif
00283
00284
00285
00286 video::ERenderSystems RendererType_;
00287 dim::size2di Resolution_;
00288 s32 ColorDepth_;
00289 bool isFullscreen_;
00290 SDeviceFlags Flags_;
00291
00292 u32 FrameRate_;
00293
00294 scene::SceneGraph* DefaultSceneManager_;
00295
00296 std::list<video::RenderContext*> RenderContextList_;
00297 std::list<audio::SoundDevice*> SoundDeviceList_;
00298 std::list<scene::SceneGraph*> SceneGraphList_;
00299 std::list<scene::CollisionGraph*> CollGraphList_;
00300
00301 #ifdef SP_COMPILE_WITH_PHYSICS
00302 std::list<physics::PhysicsSimulator*> PhysicsSimulatorList_;
00303 #endif
00304 #ifdef SP_COMPILE_WITH_NETWORKSYSTEM
00305 std::list<network::NetworkSystem*> NetworkSystemList_;
00306 #endif
00307
00308 };
00309
00310
00311
00312
00313
00314
00335 #if defined(SP_PLATFORM_ANDROID)
00336 SP_EXPORT SoftPixelDevice* createGraphicsDevice(
00337 android_app* App, const video::ERenderSystems RendererType, const io::stringc &Title = "",
00338 const bool isFullscreen = false, const u32 SDKVersion = SP_SDK_VERSION
00339 );
00340 #elif defined(SP_PLATFORM_IOS)
00341 SP_EXPORT SoftPixelDevice* createGraphicsDevice(
00342 const video::ERenderSystems RendererType, const io::stringc &Title = "",
00343 const bool isFullscreen = false, const u32 SDKVersion = SP_SDK_VERSION
00344 );
00345 #else
00346 SP_EXPORT SoftPixelDevice* createGraphicsDevice(
00347 const video::ERenderSystems RendererType, const dim::size2di &Resolution,
00348 const s32 ColorDepth = DEF_COLORDEPTH, const io::stringc &Title = "", const bool isFullscreen = false,
00349 const SDeviceFlags &Flags = SDeviceFlags(), void* ParentWindow = 0, const u32 SDKVersion = SP_SDK_VERSION
00350 );
00351 #endif
00352
00354 SP_EXPORT void deleteDevice();
00355
00356
00357 }
00358
00359
00360 #endif
00361
00362
00363
00364