KeosRenderTarget.h

Go to the documentation of this file.
00001 /*
00002  * This source file is part of KEOS (Free 3D Engine)
00003  * For the latest info, see http://www.keosengine.org/
00004  * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
00005  *
00006  * This program is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU Lesser General Public License as published by the Free Software
00008  * Foundation; either version 2 of the License, or (at your option) any later
00009  * version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00018  * http://www.gnu.org/copyleft/lesser.txt.
00019  *
00020  */
00021 
00022 #ifndef KEOS_RENDERTARGET_H
00023 #define KEOS_RENDERTARGET_H
00024 
00025 #include "KeosPrerequisites.h"
00026 #include "KeosRenderApp.h"
00027 
00028 namespace Keos
00029 {
00030   //-----------------------------------------------------------------------
00036   class KEOS_EXPORT IRenderTarget
00037   {
00038   public:
00039     enum StatFlags
00040     {
00041       SF_NONE           = 0,
00042       SF_FPS            = 1,
00043       SF_AVG_FPS        = 2,
00044       SF_BEST_FPS       = 4,
00045       SF_WORST_FPS      = 8,
00046       SF_TRIANGLE_COUNT = 16,
00047       SF_ALL            = 0xFFFF
00048     };
00049 
00050     struct FrameStats
00051     {
00052       float lastFPS;
00053       float avgFPS;
00054       float bestFPS;
00055       float worstFPS;
00056       unsigned long bestFrameTime;
00057       unsigned long worstFrameTime;
00058       unsigned long lastFrameTime;
00059       size_t triangleCount;
00060     };
00061 
00064     IRenderTarget();
00065 
00068     virtual ~IRenderTarget();
00069 
00073     virtual const String& GetName(void) const;
00074 
00080     virtual void GetMetrics(uint& nWidth, uint& nHeight, uint& nColourDepth);
00081 
00082     virtual unsigned int GetWidth(void) const;
00083     virtual unsigned int GetHeight(void) const;
00084     virtual unsigned int GetColourDepth(void) const;
00085 
00088     virtual void Init(void);
00089 
00092     virtual void Update(void);
00093 
00107     virtual void GetStatistics(float& lastFPS, float& avgFPS,
00108                                float& bestFPS, float& worstFPS) const;
00109 
00112     virtual float GetLastFPS() const;
00113 
00116     virtual float GetAverageFPS() const;
00117 
00120     virtual float GetBestFPS() const;
00121 
00124     virtual float GetWorstFPS() const;
00125 
00128     virtual float GetBestFrameTime() const;
00129 
00132     virtual float GetWorstFrameTime() const;
00133 
00136     virtual float GetLastFrameTime() const;
00137 
00140     virtual void ResetStatistics(void);
00141 
00144     virtual bool IsActive() const;
00145 
00148     virtual void SetActive( bool bState );
00149 
00156     virtual void SetAutoUpdated(bool bAutoUpdate);
00157 
00161     virtual bool IsAutoUpdated(void) const;
00162 
00165     virtual size_t GetTriangleCount(void) const;
00166 
00170     void SetRenderApp(IRenderApp* pRenderApp)
00171     {
00172       m_pRenderApp = pRenderApp;
00173       pRenderApp->m_pRenderTarget = this;
00174     }
00175 
00176   protected:
00177 
00180     void UpdateStats(void);
00181 
00183     String m_strName;
00184 
00186     IRenderApp* m_pRenderApp;
00187 
00189     unsigned int m_nWidth;
00190 
00192     unsigned int m_nHeight;
00193 
00195     unsigned int m_nColourDepth;
00196 
00198     FrameStats m_Stats;
00199 
00201     CTimer* m_pTimer ;
00202 
00203     // Variables for stats claculation
00204     unsigned long m_nLastSecond;
00205     unsigned long m_nLastTime;
00206     size_t m_nFrameCount;
00207 
00209     bool m_bActive;
00211     bool m_bAutoUpdate;
00212 
00213     bool m_bIsDepthBuffered;
00214   };
00215 
00216   //=======================================================================
00217   // IRenderTarget inline functions
00218   //=======================================================================
00219 
00220   //-----------------------------------------------------------------------
00221   inline const String& IRenderTarget::GetName(void) const
00222   {
00223     return m_strName;
00224   }
00225 
00226   //-----------------------------------------------------------------------
00227   inline uint IRenderTarget::GetWidth(void) const
00228   {
00229     return m_nWidth;
00230   }
00231 
00232   //-----------------------------------------------------------------------
00233   inline uint IRenderTarget::GetHeight(void) const
00234   {
00235     return m_nHeight;
00236   }
00237 
00238   //-----------------------------------------------------------------------
00239   inline uint IRenderTarget::GetColourDepth(void) const
00240   {
00241     return m_nColourDepth;
00242   }
00243 
00244   //-----------------------------------------------------------------------
00245   inline bool IRenderTarget::IsActive() const
00246   {
00247     return m_bActive;
00248   }
00249 
00250   //-----------------------------------------------------------------------
00251   inline void IRenderTarget::SetActive( bool bState )
00252   {
00253     m_bActive = bState;
00254   }
00255 
00256   //-----------------------------------------------------------------------
00257   inline void IRenderTarget::SetAutoUpdated(bool bAutoUpdate)
00258   {
00259     m_bAutoUpdate = bAutoUpdate;
00260   }
00261 
00262   //-----------------------------------------------------------------------
00263   inline bool IRenderTarget::IsAutoUpdated(void) const
00264   {
00265     return m_bAutoUpdate;
00266   }
00267 
00268   //-----------------------------------------------------------------------
00269   inline void IRenderTarget::GetStatistics(float& lastFPS, float& avgFPS,
00270       float& bestFPS, float& worstFPS) const
00271   {
00272     // Note - the will have been updated by the last render
00273     lastFPS = m_Stats.lastFPS;
00274     avgFPS = m_Stats.avgFPS;
00275     bestFPS = m_Stats.bestFPS;
00276     worstFPS = m_Stats.worstFPS;
00277   }
00278 
00279   //-----------------------------------------------------------------------
00280   inline float IRenderTarget::GetLastFPS() const
00281   {
00282     return m_Stats.lastFPS;
00283   }
00284 
00285   //-----------------------------------------------------------------------
00286   inline float IRenderTarget::GetAverageFPS() const
00287   {
00288     return m_Stats.avgFPS;
00289   }
00290 
00291   //-----------------------------------------------------------------------
00292   inline float IRenderTarget::GetBestFPS() const
00293   {
00294     return m_Stats.bestFPS;
00295   }
00296 
00297   //-----------------------------------------------------------------------
00298   inline float IRenderTarget::GetWorstFPS() const
00299   {
00300     return m_Stats.worstFPS;
00301   }
00302 
00303   //-----------------------------------------------------------------------
00304   inline size_t IRenderTarget::GetTriangleCount(void) const
00305   {
00306     return m_Stats.triangleCount;
00307   }
00308 
00309   //-----------------------------------------------------------------------
00310   inline float IRenderTarget::GetBestFrameTime() const
00311   {
00312     return m_Stats.bestFrameTime;
00313   }
00314 
00315   //-----------------------------------------------------------------------
00316   inline float IRenderTarget::GetWorstFrameTime() const
00317   {
00318     return m_Stats.worstFrameTime;
00319   }
00320 
00321   //-----------------------------------------------------------------------
00322   inline float IRenderTarget::GetLastFrameTime() const
00323   {
00324     return m_Stats.lastFrameTime;
00325   }
00326 
00327 } // Namespace Keos
00328 
00329 #endif // KEOS_RENDERTARGET_H

Generated on Fri Mar 9 14:29:03 2007 for Keos by  doxygen 1.5.1-p1