PCMGLXRenderWindow.h

Go to the documentation of this file.
00001 
00002 //
00003 // This source file is a part of ParCompMark
00004 // Parallel Compositing Benchmark Framework
00005 //
00006 // for latest info see http://parcompmark.sourceforge.net
00007 
00008 //
00009 // Copyright (C) 2006 IT2 ParCompMark Dev. Team
00010 // 
00011 // This program is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License
00013 // as published by the Free Software Foundation; either version 2
00014 // of the License, or (at your option) any later version.
00015 // 
00016 // This program is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 // GNU General Public License for more details.
00020 // 
00021 // You should have received a copy of the GNU General Public License
00022 // along with this program; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 
00027 
00028 #ifndef __PCM_GLXRENDERWINDOW_H__
00029 #  define __PCM_GLXRENDERWINDOW_H__
00030 
00031 //
00032 // Inner includes
00033 //
00034 
00035 #  include "PCMPremeditations.h"
00036 
00037 #  include "PCMPointer.h"
00038 
00039 #  include "PCMLogger.h"
00040 
00041 #  include "PCMGLXGLContext.h"
00042 
00043 #  include "PCMXDisplay.h"
00044 
00045 #  include "PCMTimer.h"
00046 
00047 //
00048 // Outer includes
00049 //
00050 
00051 #  include <X11/Xlib.h>
00052 
00053 #  include <X11/keysym.h>
00054 
00055 #  include <GL/glew.h>
00056 
00057 #  include <GL/glx.h>
00058 
00059 #  include <string>
00060 
00061 #  include <sstream>
00062 
00063 namespace ParCompMark
00064 {
00065 
00071   class GLXRenderWindow
00072   {
00073 
00074         //
00075         // Unit test class
00076         //
00077 #  ifdef PARCOMPMARK_TEST
00078         friend class ParCompMarkTest::TestGLXRenderWindow;
00079 #  endif
00080 
00081         //
00082         // Typedefs
00083         //
00084 
00085    public:
00086 
00088         typedef Pointer < GLXRenderWindow,
00089         Mutex > Pointer;
00090 
00092         typedef struct
00093 
00094         {                
00096          u32 frameCount;                                                          
00098          Real renderingTime;                                                                                                                                     
00100          Real lastFPS;                                                                                                                                                                                           
00102          Real avgFPS;                                                                                                                                                                                                                                            
00104          Real bestFPS;                                                                                                                                                                                                                                                                                                                     
00106          Real worstFPS;                                                                                                                                                                                                                                                                                                                                                                                                    
00108          Real frameBeginTime;                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
00110          Real frameEndTime;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
00112          Real lastFrameTime;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
00114          Real bestFrameTime;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
00116          Real worstFrameTime;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
00118          Real lastTriangleCount;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
00120          Real avgTriangleCount;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
00122          Real minTriangleCount;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
00123          Real maxTriangleCount;
00124         } WindowStatistics;
00125 
00126         //
00127         // Class constants
00128         //
00129 
00131 
00132 
00133    public:
00134 
00140         static const s32 CENTERED;
00141 
00147         static const u32 MAXIMALSIZE;
00148 
00154         static const Real UNDEFINEDSTATISTICS;
00155 
00161         static const s32 UNDEFINEDXRRCONFIGURATION;
00162 
00168         static const u32 DEFAULTWINDOWWIDTH;
00169 
00175         static const u32 DEFAULTWINDOWHEIGHT;
00176 
00178 
00179         //
00180         // Variables
00181         //
00182 
00184 
00185 
00186    protected:
00187 
00193         XDisplay::Pointer mDisplay;
00194 
00200         GLXGLContext::Pointer mGLXGLContext;
00201 
00207         Process *mProcess;
00208 
00214         ::Window mWindow;
00215 
00221         bool mInitialized;
00222 
00228         bool mVisible;
00229 
00235         bool mFullScreen;
00236 
00242         std::string mCaption;
00243 
00249         s32 mLeft;
00250 
00256         s32 mTop;
00257 
00263         u32 mWidth;
00264 
00270         u32 mHeight;
00271 
00277         u32 mColourDepth;
00278 
00284         u32 mFSAASamples;
00285 
00291         s32 mOriginalXRRConfiguation;
00292 
00298         ::Atom mAtomDeleteWindow;
00299 
00305         WindowStatistics mWindowStatistics;
00306 
00312         Real mRenderingBeginTime;
00313 
00319         Real mFPSMeasuringBeginTime;
00320 
00326         u32 mFPSMeasuringFrameCount;
00327 
00333         Real mSumTriangleCount;
00334 
00340         Real mSumFPS;
00341 
00343 
00344         //
00345         // Constructors & destructor
00346         //
00347 
00349 
00350 
00351    public:
00352 
00366         GLXRenderWindow(XDisplay::Pointer & display, Process * process, const std::string caption =
00367                         "PCM Framework", const bool & fullScreen = true, const u32 & colourDepth =
00368                         0, const u32 & width = GLXRenderWindow::MAXIMALSIZE, const u32 & height =
00369                         GLXRenderWindow::MAXIMALSIZE, const s32 & left =
00370                         GLXRenderWindow::CENTERED, const s32 & top =
00371                         GLXRenderWindow::CENTERED, const u32 & fsaaSamples = 0);
00372 
00376         virtual ~ GLXRenderWindow();
00377 
00379 
00380         //
00381         // Getters & setters
00382         //
00383 
00385 
00386 
00387    public:
00388 
00394         XDisplay::Pointer & getDisplay();
00395 
00401         GLXGLContext::Pointer & getGLXGLContext();
00402 
00408         Process *getProcess() const;
00409 
00415         const::Window & getWindow() const;
00416 
00422         const bool & getInitialized() const;
00423 
00429         const bool & getVisible() const;
00430 
00436         void setVisible(const bool & visible);
00437 
00443         const bool & getFullScreen() const;
00444 
00450         void setFullScreen(const bool & fullscreen);
00451 
00457         const std::string & getCaption() const;
00458 
00464         void setCaption(const std::string & caption);
00465 
00471         const s32 & getLeft() const;
00472 
00478         void setLeft(const s32 & left);
00479 
00485         const s32 & getTop() const;
00486 
00492         void setTop(const s32 & top);
00493 
00499         const u32 & getWidth() const;
00500 
00506         void setWidth(const u32 & width);
00507 
00513         const u32 & getHeight() const;
00514 
00520         void setHeight(const u32 & height);
00521 
00527         const u32 & getColourDepth() const;
00528 
00534         void setColourDepth(const u32 & colourdepth);
00535 
00541         const u32 & getFSAASamples() const;
00542 
00548         void setFSAASamples(const u32 & fsaasamples);
00549 
00555         const GLXRenderWindow::WindowStatistics & getWindowStatistics() const;
00556 
00558 
00559         //
00560         // Methods
00561         //
00562 
00564 
00565 
00566    public:
00567 
00573         virtual void reposition(const s32 & left, const s32 & top);
00574 
00580         virtual void resize(const u32 & width, const u32 & height);
00581 
00585         virtual void startFrame();
00586 
00590         virtual void finishFrame();
00591 
00598         virtual void setCurrent();
00599 
00605         virtual void releaseCurrent();
00606 
00610         virtual void initialize();
00611 
00615         virtual void finalize();
00616 
00622         virtual void resetStatistics();
00623 
00628         virtual void reportTriangles(const u32 & triangleCount);
00629 
00630    protected:
00631 
00635         virtual void createWindow();
00636 
00640         virtual void destroyWindow();
00641 
00645         virtual void updateStatistics();
00646 
00650         virtual void _reposition();
00651 
00655         virtual void _resize();
00656 
00660         virtual void _setCaption();
00661 
00663 
00664   };
00665 
00666   //
00667   // Include header implementation
00668   //
00669 
00670 #  include "PCMGLXRenderWindow_impl.h"
00671 
00672 }
00673 
00674 #endif