Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

# 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             size_t triangleCount;
    00059         };
    00060
    00063         IRenderTarget();
    00064
    00067         virtual ~IRenderTarget();
    00068
    00072         virtual const String& GetName(void) const;
    00073
    00079         virtual void GetMetrics(uint& nWidth, uint& nHeight, uint& nColourDepth);
    00080
    00081         virtual unsigned int GetWidth(void) const;
    00082         virtual unsigned int GetHeight(void) const;
    00083         virtual unsigned int GetColourDepth(void) const;
    00084
    00087         virtual void Init(void);
    00088
    00091         virtual void Update(void);
    00092
    00106         virtual void GetStatistics(float& lastFPS, float& avgFPS,
    00107             float& bestFPS, float& worstFPS) const;
    00108
    00111         virtual float GetLastFPS() const;
    00112
    00115         virtual float GetAverageFPS() const;
    00116
    00119         virtual float GetBestFPS() const;
    00120
    00123         virtual float GetWorstFPS() const;
    00124
    00127         virtual float GetBestFrameTime() const;
    00128
    00131         virtual float GetWorstFrameTime() const;
    00132
    00135         virtual void ResetStatistics(void);
    00136
    00139         virtual bool IsActive() const;
    00140
    00143         virtual void SetActive( bool bState );
    00144
    00151         virtual void SetAutoUpdated(bool bAutoUpdate);
    00152
    00156         virtual bool IsAutoUpdated(void) const;
    00157
    00160                 virtual size_t GetTriangleCount(void) const;
    00161
    00165         void SetRenderApp(IRenderApp* pRenderApp) { m_pRenderApp = pRenderApp; pRenderApp->m_pRenderTarget = this;}
    00166
    00167     protected:
    00168
    00171         void UpdateStats(void);
    00172
    00174         String m_strName;
    00175
    00177         IRenderApp* m_pRenderApp;
    00178
    00180         unsigned int m_nWidth;
    00181
    00183         unsigned int m_nHeight;
    00184
    00186         unsigned int m_nColourDepth;
    00187
    00189                     FrameStats m_Stats;
    00190
    00192         CTimer* m_pTimer ;
    00193
    00194         // Variables for stats claculation
    00195         unsigned long m_nLastSecond;
    00196         unsigned long m_nLastTime;
    00197         size_t m_nFrameCount;
    00198
    00200         bool m_bActive;
    00202         bool m_bAutoUpdate;
    00203
    00204         bool m_bIsDepthBuffered;
    00205     };
    00206
    00207     //=======================================================================
    00208     // IRenderTarget inline functions
    00209     //=======================================================================
    00210
    00211     //-----------------------------------------------------------------------
    00212     inline const String& IRenderTarget::GetName(void) const
    00213     {
    00214         return m_strName;
    00215     }
    00216
    00217     //-----------------------------------------------------------------------
    00218     inline uint IRenderTarget::GetWidth(void) const
    00219     {
    00220         return m_nWidth;
    00221     }
    00222
    00223     //-----------------------------------------------------------------------
    00224     inline uint IRenderTarget::GetHeight(void) const
    00225     {
    00226         return m_nHeight;
    00227     }
    00228
    00229     //-----------------------------------------------------------------------
    00230     inline uint IRenderTarget::GetColourDepth(void) const
    00231     {
    00232         return m_nColourDepth;
    00233     }
    00234
    00235     //-----------------------------------------------------------------------
    00236     inline bool IRenderTarget::IsActive() const
    00237     {
    00238         return m_bActive;
    00239     }
    00240
    00241     //-----------------------------------------------------------------------
    00242     inline void IRenderTarget::SetActive( bool bState )
    00243     {
    00244         m_bActive = bState;
    00245     }
    00246
    00247     //-----------------------------------------------------------------------
    00248     inline void IRenderTarget::SetAutoUpdated(bool bAutoUpdate)
    00249     {
    00250         m_bAutoUpdate = bAutoUpdate;
    00251     }
    00252
    00253     //-----------------------------------------------------------------------
    00254     inline bool IRenderTarget::IsAutoUpdated(void) const
    00255     {
    00256         return m_bAutoUpdate;
    00257     }
    00258
    00259     //-----------------------------------------------------------------------
    00260     inline void IRenderTarget::GetStatistics(float& lastFPS, float& avgFPS,
    00261         float& bestFPS, float& worstFPS) const
    00262     {
    00263         // Note - the will have been updated by the last render
    00264         lastFPS = m_Stats.lastFPS;
    00265         avgFPS = m_Stats.avgFPS;
    00266         bestFPS = m_Stats.bestFPS;
    00267         worstFPS = m_Stats.worstFPS;
    00268     }
    00269
    00270     //-----------------------------------------------------------------------
    00271     inline float IRenderTarget::GetLastFPS() const
    00272     {
    00273         return m_Stats.lastFPS;
    00274     }
    00275
    00276     //-----------------------------------------------------------------------
    00277     inline float IRenderTarget::GetAverageFPS() const
    00278     {
    00279         return m_Stats.avgFPS;
    00280     }
    00281
    00282     //-----------------------------------------------------------------------
    00283     inline float IRenderTarget::GetBestFPS() const
    00284     {
    00285         return m_Stats.bestFPS;
    00286     }
    00287
    00288     //-----------------------------------------------------------------------
    00289     inline float IRenderTarget::GetWorstFPS() const
    00290     {
    00291         return m_Stats.worstFPS;
    00292     }
    00293
    00294     //-----------------------------------------------------------------------
    00295     inline size_t IRenderTarget::GetTriangleCount(void) const
    00296     {
    00297         return m_Stats.triangleCount;
    00298     }
    00299
    00300     //-----------------------------------------------------------------------
    00301     inline float IRenderTarget::GetBestFrameTime() const
    00302     {
    00303         return m_Stats.bestFrameTime;
    00304     }
    00305
    00306     //-----------------------------------------------------------------------
    00307     inline float IRenderTarget::GetWorstFrameTime() const
    00308     {
    00309         return m_Stats.worstFrameTime;
    00310     }
    00311
    00312 } // Namespace Keos
    00313
    00314 #endif // KEOS_RENDERTARGET_H