PixelLightAPI  .
FrontendOpenGL.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: FrontendOpenGL.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 __PLCORE_FRONTEND_OPENGL_H__
00024 #define __PLCORE_FRONTEND_OPENGL_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/Frontend/Frontend.h"
00032 #ifdef WIN32
00033     #include <windows.h>
00034 #endif
00035 #include <GL/gl.h>
00036 #include <GL/glu.h>
00037 
00038 
00039 //[-------------------------------------------------------]
00040 //[ Namespace                                             ]
00041 //[-------------------------------------------------------]
00042 namespace PLCore {
00043 
00044 
00045 //[-------------------------------------------------------]
00046 //[ Classes                                               ]
00047 //[-------------------------------------------------------]
00048 /**
00049 *  @brief
00050 *    Simple test frontend that uses OpenGL
00051 *
00052 *  @remarks
00053 *    This is a test frontend which uses OpenGL to display a spinning colored
00054 *    rectangle. It can be used easily to test the frontend integration when
00055 *    developing a new backend.
00056 */
00057 class FrontendOpenGL : public Frontend {
00058 
00059 
00060     //[-------------------------------------------------------]
00061     //[ RTTI interface                                        ]
00062     //[-------------------------------------------------------]
00063     pl_class(PLCORE_RTTI_EXPORT, FrontendOpenGL, "PLCore", PLCore::Frontend, "Simple test frontend that uses OpenGL")
00064         #ifdef PLCORE_EXPORTS   // The following is only required when compiling PLCore
00065             // Constructors
00066             pl_constructor_2(ParameterConstructor,  const FrontendContext&, FrontendImpl&,  "Parameter constructor. Frontend context this frontend is using as first parameter, frontend implementation this frontend is using as second parameter.",   "")
00067         #endif
00068     pl_class_end
00069 
00070 
00071     //[-------------------------------------------------------]
00072     //[ Public functions                                      ]
00073     //[-------------------------------------------------------]
00074     public:
00075         /**
00076         *  @brief
00077         *    Constructor
00078         *
00079         *  @param[in] cFrontendContext
00080         *    Frontend context to use (just shared, the given instance must stay valid as long as this frontend lives)
00081         *  @param[in] cFrontendImpl
00082         *    Frontend implementation instance
00083         */
00084         PLCORE_API FrontendOpenGL(const FrontendContext &cFrontendContext, FrontendImpl &cFrontendImpl);
00085 
00086         /**
00087         *  @brief
00088         *    Destructor
00089         */
00090         PLCORE_API virtual ~FrontendOpenGL();
00091 
00092 
00093     //[-------------------------------------------------------]
00094     //[ Public virtual Frontend functions                     ]
00095     //[-------------------------------------------------------]
00096     public:
00097         PLCORE_API virtual bool IsRunning() const override;
00098 
00099 
00100     //[-------------------------------------------------------]
00101     //[ Protected virtual AbstractLifecycle functions         ]
00102     //[-------------------------------------------------------]
00103     protected:
00104         PLCORE_API virtual void OnCreate() override;
00105         PLCORE_API virtual void OnRestart() override;
00106         PLCORE_API virtual bool OnStart() override;
00107         PLCORE_API virtual void OnResume() override;
00108         PLCORE_API virtual void OnPause() override;
00109         PLCORE_API virtual void OnStop() override;
00110         PLCORE_API virtual void OnDestroy() override;
00111 
00112 
00113     //[-------------------------------------------------------]
00114     //[ Protected virtual AbstractFrontend functions          ]
00115     //[-------------------------------------------------------]
00116     protected:
00117         PLCORE_API virtual void OnSize() override;
00118         PLCORE_API virtual void OnFullscreenMode() override;
00119         PLCORE_API virtual void OnDraw() override;
00120         PLCORE_API virtual void OnUpdate() override;
00121         PLCORE_API virtual void OnDrop(const Container<String> &lstFiles) override;
00122 
00123 
00124     //[-------------------------------------------------------]
00125     //[ Private functions                                     ]
00126     //[-------------------------------------------------------]
00127     private:
00128         /**
00129         *  @brief
00130         *    Initialize OpenGL
00131         */
00132         void InitGL();
00133 
00134         /**
00135         *  @brief
00136         *    Resize GL scene to fit the current window size
00137         */
00138         void ResizeGL();
00139 
00140         /**
00141         *  @brief
00142         *    Draw scene
00143         */
00144         void DrawGL();
00145 
00146 
00147     //[-------------------------------------------------------]
00148     //[ Private data                                          ]
00149     //[-------------------------------------------------------]
00150     private:
00151         // Platform specific
00152         #ifdef WIN32
00153             HDC   m_hDC;    /**< Device context, can be a null pointer */
00154             HGLRC m_hRC;    /**< OpenGL rendering context, can be a null pointer */
00155         #endif
00156 
00157         // Platform independent
00158         float m_fAngle; /**< Current rotation angle of the rectangle */
00159 
00160 
00161 };
00162 
00163 
00164 //[-------------------------------------------------------]
00165 //[ Namespace                                             ]
00166 //[-------------------------------------------------------]
00167 } // PLCore
00168 
00169 
00170 #endif // __PLCORE_FRONTEND_OPENGL_H__


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