PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SceneApplication.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLSCENE_APPLICATION_H__ 00024 #define __PLSCENE_APPLICATION_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLRenderer/Application/RendererApplication.h> 00032 #include "PLScene/PLScene.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Forward declarations ] 00037 //[-------------------------------------------------------] 00038 namespace PLScene { 00039 class SceneContext; 00040 class SceneContainer; 00041 } 00042 00043 00044 //[-------------------------------------------------------] 00045 //[ Namespace ] 00046 //[-------------------------------------------------------] 00047 namespace PLScene { 00048 00049 00050 //[-------------------------------------------------------] 00051 //[ Classes ] 00052 //[-------------------------------------------------------] 00053 /** 00054 * @brief 00055 * Scene application class 00056 * 00057 * @remarks 00058 * An application class that provides a scene graph for rendering 00059 * 00060 * @note 00061 * - The 'OnCreatePainter()'-implementation creates a 'SPScene' surface painter 00062 */ 00063 class SceneApplication : public PLRenderer::RendererApplication { 00064 00065 00066 //[-------------------------------------------------------] 00067 //[ RTTI interface ] 00068 //[-------------------------------------------------------] 00069 pl_class(PLS_RTTI_EXPORT, SceneApplication, "PLScene", PLRenderer::RendererApplication, "Scene application class") 00070 #ifdef PLSCENE_EXPORTS // The following is only required when compiling PLScene 00071 // Constructors 00072 pl_constructor_1(ParameterConstructor, PLCore::Frontend&, "Parameter constructor. Frontend this application instance is running in as first parameter.", "") 00073 // Methods 00074 pl_method_0(GetRootScene, pl_ret_type(PLScene::SceneContainer*), "Returns the root scene container, can be a null pointer.", "") 00075 #endif 00076 pl_class_end 00077 00078 00079 //[-------------------------------------------------------] 00080 //[ Public functions ] 00081 //[-------------------------------------------------------] 00082 public: 00083 /** 00084 * @brief 00085 * Constructor 00086 * 00087 * @param[in] cFrontend 00088 * Frontend this application instance is running in 00089 * @param[in] sSceneFilename 00090 * Filename of the scene to load 00091 */ 00092 PLS_API SceneApplication(PLCore::Frontend &cFrontend, const PLCore::String &sSceneFilename = ""); 00093 00094 /** 00095 * @brief 00096 * Destructor 00097 */ 00098 PLS_API virtual ~SceneApplication(); 00099 00100 /** 00101 * @brief 00102 * Returns the scene context 00103 * 00104 * @return 00105 * The scene context, a null pointer on error 00106 */ 00107 PLS_API PLScene::SceneContext *GetSceneContext() const; 00108 00109 /** 00110 * @brief 00111 * Returns the root scene 00112 * 00113 * @return 00114 * Pointer to root scene container, can be a null pointer 00115 */ 00116 PLS_API PLScene::SceneContainer *GetRootScene() const; 00117 00118 00119 //[-------------------------------------------------------] 00120 //[ Protected functions ] 00121 //[-------------------------------------------------------] 00122 protected: 00123 /** 00124 * @brief 00125 * Set root scene 00126 * 00127 * @param[in] pSceneContainer 00128 * Pointer to root scene container, can be a null pointer 00129 */ 00130 PLS_API void SetRootScene(PLScene::SceneContainer *pSceneContainer); 00131 00132 00133 //[-------------------------------------------------------] 00134 //[ Protected virtual PLCore::AbstractLifecycle functions ] 00135 //[-------------------------------------------------------] 00136 protected: 00137 /** 00138 * @brief 00139 * Initialization function that is called prior to OnInit() 00140 * 00141 * @return 00142 * 'true' if all went fine, else 'false' which will stop the application 00143 * 00144 * @remarks 00145 * The default implementation does the following tasks: 00146 * - Everything that PLRenderer::RendererApplication::OnStart() does 00147 * - Create scene context 00148 * - Call OnCreateRootScene() 00149 * - Return and go on with OnInit() 00150 */ 00151 PLS_API virtual bool OnStart() override; 00152 00153 /** 00154 * @brief 00155 * De-initialization function that is called after OnDeInit() 00156 * 00157 * @remarks 00158 * The default implementation does the following tasks: 00159 * - Destroy scene context 00160 * - Everything that PLRenderer::RendererApplication::OnStop() does 00161 */ 00162 PLS_API virtual void OnStop() override; 00163 00164 00165 //[-------------------------------------------------------] 00166 //[ Protected virtual PLCore::AbstractFrontend functions ] 00167 //[-------------------------------------------------------] 00168 protected: 00169 /** 00170 * @brief 00171 * Called to let the frontend update it's states 00172 * 00173 * @remarks 00174 * The default implementation does the following tasks: 00175 * - Everything that PLRenderer::RendererApplication::OnUpdate() does 00176 * - Update the scene context 00177 */ 00178 PLS_API virtual void OnUpdate() override; 00179 00180 00181 //[-------------------------------------------------------] 00182 //[ Protected virtual SceneApplication functions ] 00183 //[-------------------------------------------------------] 00184 protected: 00185 /** 00186 * @brief 00187 * Function that is called to create the application's root scene 00188 * 00189 * @note 00190 * - Part of the application framework initialization function "OnStart()" 00191 * - The default implementation creates a standard root scene 00192 */ 00193 PLS_API virtual void OnCreateRootScene(); 00194 00195 00196 //[-------------------------------------------------------] 00197 //[ Protected data ] 00198 //[-------------------------------------------------------] 00199 protected: 00200 PLScene::SceneContext *m_pSceneContext; /**< The scene context, can be a null pointer */ 00201 PLScene::SceneContainer *m_pRootScene; /**< Root scene (can be a null pointer) */ 00202 00203 00204 }; 00205 00206 00207 //[-------------------------------------------------------] 00208 //[ Namespace ] 00209 //[-------------------------------------------------------] 00210 } // PLScene 00211 00212 00213 #endif // __PLSCENE_SCENE_APPLICATION_H__
|