PixelLightAPI  .
RendererApplication.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: RendererApplication.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 __PLRENDERER_APPLICATION_H__
00024 #define __PLRENDERER_APPLICATION_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Frontend/FrontendApplication.h>
00032 #include "PLRenderer/Renderer/SurfaceWindowHandler.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLRenderer {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Forward declarations                                  ]
00043 //[-------------------------------------------------------]
00044 class SurfacePainter;
00045 class RendererContext;
00046 
00047 
00048 //[-------------------------------------------------------]
00049 //[ Classes                                               ]
00050 //[-------------------------------------------------------]
00051 /**
00052 *  @brief
00053 *    Renderer application class
00054 *
00055 *  @remarks
00056 *    An application class for programs that open a single widget to render into.
00057 */
00058 class RendererApplication : public PLCore::FrontendApplication, public PLRenderer::SurfaceWindowHandler {
00059 
00060 
00061     //[-------------------------------------------------------]
00062     //[ RTTI interface                                        ]
00063     //[-------------------------------------------------------]
00064     pl_class(PLRENDERER_RTTI_EXPORT, RendererApplication, "PLRenderer", PLCore::FrontendApplication, "Renderer application class")
00065         #ifdef PLRENDERER_EXPORTS   // The following is only required when compiling PLRenderer
00066             // Constructors
00067             pl_constructor_1(ParameterConstructor,  PLCore::Frontend&,  "Parameter constructor. Frontend this application instance is running in as first parameter.",  "")
00068             // Methods
00069             pl_method_0(GetPainter, pl_ret_type(PLRenderer::SurfacePainter*),                                   "Get the surface painter of the main window. Returns pointer to surface painter of the main window (can be a null pointer).",               "")
00070             pl_method_1(SetPainter, pl_ret_type(void),                          PLRenderer::SurfacePainter*,    "Set the surface painter of the main window. Pointer to surface painter of the main window (can be a null pointer) as first parameter.",    "")
00071         #endif
00072     pl_class_end
00073 
00074 
00075     //[-------------------------------------------------------]
00076     //[ Public functions                                      ]
00077     //[-------------------------------------------------------]
00078     public:
00079         /**
00080         *  @brief
00081         *    Constructor
00082         *
00083         *  @param[in] cFrontend
00084         *    Frontend this application instance is running in
00085         *  @param[in] sSurfacePainter
00086         *    Surface painter class to use
00087         */
00088         PLRENDERER_API RendererApplication(PLCore::Frontend &cFrontend, const PLCore::String &sSurfacePainter = "PLRenderer::SPDefault");
00089 
00090         /**
00091         *  @brief
00092         *    Destructor
00093         */
00094         PLRENDERER_API virtual ~RendererApplication();
00095 
00096         /**
00097         *  @brief
00098         *    Returns the renderer context
00099         *
00100         *  @return
00101         *    The renderer context, a null pointer on error
00102         */
00103         inline PLRenderer::RendererContext *GetRendererContext() const;
00104 
00105         /**
00106         *  @brief
00107         *    Get surface painter of the main window
00108         *
00109         *  @return
00110         *    Pointer to surface painter of the main window, can be a null pointer
00111         */
00112         PLRENDERER_API PLRenderer::SurfacePainter *GetPainter() const;
00113 
00114         /**
00115         *  @brief
00116         *    Set surface painter of the main window
00117         *
00118         *  @param[in] pPainter
00119         *    Pointer to surface painter of the main window, can be a null pointer
00120         */
00121         PLRENDERER_API void SetPainter(PLRenderer::SurfacePainter *pPainter);
00122 
00123 
00124     //[-------------------------------------------------------]
00125     //[ Protected virtual PLCore::AbstractLifecycle functions ]
00126     //[-------------------------------------------------------]
00127     protected:
00128         /**
00129         *  @brief
00130         *    Initialization function that is called prior to OnInit()
00131         *
00132         *  @return
00133         *    'true' if all went fine, else 'false' which will stop the application
00134         *
00135         *  @remarks
00136         *    The default implementation does the following tasks:
00137         *    - Everything that PLCore::CoreApplication::OnStart() does
00138         *    - Call OnCreateRendererContext()
00139         *    - Call OnCreatePainter()
00140         *    - Return and go on with OnInit()
00141         */
00142         PLRENDERER_API virtual bool OnStart() override;
00143 
00144         /**
00145         *  @brief
00146         *    De-initialization function that is called after OnDeInit()
00147         *
00148         *  @remarks
00149         *    The default implementation does the following tasks:
00150         *    - Save renderer related configuration
00151         *    - Destroy renderer context
00152         *    - Everything that FrontendApplication::OnStop() does
00153         */
00154         PLRENDERER_API virtual void OnStop() override;
00155 
00156 
00157     //[-------------------------------------------------------]
00158     //[ Protected virtual PLCore::AbstractFrontend functions  ]
00159     //[-------------------------------------------------------]
00160     protected:
00161         /**
00162         *  @brief
00163         *    Called when the fullscreen mode was changed
00164         *
00165         *  @remarks
00166         *    The default implementation does the following tasks:
00167         *    - Everything that PLCore::FrontendApplication::OnFullscreenMode() does
00168         *    - Update renderer surface
00169         */
00170         PLRENDERER_API virtual void OnFullscreenMode() override;
00171 
00172         /**
00173         *  @brief
00174         *    Called to let the frontend draw into it's window
00175         *
00176         *  @remarks
00177         *    The default implementation does the following tasks:
00178         *    - Everything that PLCore::FrontendApplication::OnDraw() does
00179         *    - Draw renderer surface
00180         */
00181         PLRENDERER_API virtual void OnDraw() override;
00182 
00183         /**
00184         *  @brief
00185         *    Called to let the frontend update it's states
00186         *
00187         *  @remarks
00188         *    The default implementation does the following tasks:
00189         *    - Everything that PLCore::FrontendApplication::OnUpdate() does
00190         *    - Update renderer context
00191         */
00192         PLRENDERER_API virtual void OnUpdate() override;
00193 
00194 
00195     //[-------------------------------------------------------]
00196     //[ Protected virtual RendererApplication functions       ]
00197     //[-------------------------------------------------------]
00198     protected:
00199         /**
00200         *  @brief
00201         *    Function that is called to create the application's renderer context
00202         *
00203         *  @note
00204         *    - Part of the application framework initialization function "OnStart()"
00205         *    - The default implementation is using the "PLRenderer::Config"-configuration to get the settings to use
00206         */
00207         PLRENDERER_API virtual void OnCreateRendererContext();
00208 
00209         /**
00210         *  @brief
00211         *    Function that is called to create the application's surface painter
00212         *
00213         *  @remarks
00214         *    The default implementation does the following tasks:
00215         *    - Sets the default painter
00216         *
00217         *  @note
00218         *    - Part of the application framework initialization function "OnStart()"
00219         */
00220         PLRENDERER_API virtual void OnCreatePainter();
00221 
00222 
00223     //[-------------------------------------------------------]
00224     //[ Protected data                                        ]
00225     //[-------------------------------------------------------]
00226     protected:
00227         PLCore::String               m_sSurfacePainter;     /**< Surface painter class to use */
00228         PLRenderer::RendererContext *m_pRendererContext;    /**< The renderer context, can be a null pointer */
00229         PLRenderer::DisplayMode     *m_pDisplayMode;        /**< Display mode, always valid! */
00230 
00231 
00232     //[-------------------------------------------------------]
00233     //[ Private functions                                     ]
00234     //[-------------------------------------------------------]
00235     private:
00236         /**
00237         *  @brief
00238         *    Reads the current display mode from the configuration
00239         */
00240         void ReadDisplayModeFromConfig();
00241 
00242 
00243 };
00244 
00245 
00246 //[-------------------------------------------------------]
00247 //[ Namespace                                             ]
00248 //[-------------------------------------------------------]
00249 } // PLRenderer
00250 
00251 
00252 //[-------------------------------------------------------]
00253 //[ Implementation                                        ]
00254 //[-------------------------------------------------------]
00255 #include "PLRenderer/Application/RendererApplication.inl"
00256 
00257 
00258 #endif // __PLRENDERER_APPLICATION_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:59
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported