PCMXDisplay.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00027 
00028 #ifndef __PCM_XDISPLAY_H__
00029 #  define __PCM_XDISPLAY_H__
00030 
00031 
00032 
00033 
00034 
00035 #  include "PCMPremeditations.h"
00036 
00037 #  include "PCMContainer.h"
00038 
00039 #  include "PCMPointer.h"
00040 
00041 
00042 
00043 
00044 
00045 #  include <X11/Xlib.h>
00046 
00047 #  include <GL/glew.h>
00048 
00049 #  include <GL/glx.h>
00050 
00051 #  include <GL/glxext.h>
00052 
00053 namespace ParCompMark
00054 {
00055 
00060   class XDisplay
00061   {
00062 
00063         
00064         
00065         
00066 #  ifdef PARCOMPMARK_TEST
00067         friend class ParCompMarkTest::TestXDisplay;
00068 #  endif
00069 
00070         
00071         
00072         
00073 
00074    public:
00075 
00077         typedef Pointer < XDisplay,
00078         Mutex > Pointer;
00079 
00080    protected:
00081 
00083         typedef struct
00084         {                       
00085          int id;
00086          int klass;
00087          int depth;
00088          int redMask,
00089           greenMask,
00090           blueMask;
00091          int colormapSize;
00092          int bitsPerRGB;        
00093          int supportsGL;
00094          int transparentType;
00095          int transparentRedValue;
00096          int transparentGreenValue;
00097          int transparentBlueValue;
00098          int transparentAlphaValue;
00099          int transparentIndexValue;
00100          int bufferSize;
00101          int level;
00102          int rgba;
00103          int doubleBuffer;
00104          int stereo;
00105          int auxBuffers;
00106          int redSize,
00107           greenSize,
00108           blueSize,
00109           alphaSize;
00110          int depthSize;
00111          int stencilSize;
00112          int accumRedSize,
00113           accumGreenSize,
00114           accumBlueSize,
00115           accumAlphaSize;
00116          int numSamples,
00117           numMultisample;
00118          int visualCaveat;
00119         } VisualAttribs;
00120 
00121         
00122         
00123         
00124 
00126 
00127 
00128    public:
00129 
00135         static const s32 IGNOREMULTISAMPLE;
00136 
00142         static const s32 UNKNOWNDIMENSION;
00143 
00145 
00146         
00147         
00148         
00149 
00151 
00152 
00153    protected:
00154 
00160         static bool mXMTInitialized;
00161 
00167         static bool mXMTSupported;
00168 
00174         static Mutex mErrorHandlerMutex;
00175 
00181         static bool mTolerateErrors;
00182 
00184 
00185         
00186         
00187         
00188 
00190 
00191 
00192    protected:
00193 
00199         std::string mDisplayName;
00200 
00206         ::Display * mDisplay;
00207 
00213         bool mInitialized;
00214 
00220         u32 mWidth;
00221 
00227         u32 mHeight;
00228 
00230 
00231         
00232         
00233         
00234 
00236 
00237 
00238    public:
00239 
00244         XDisplay(const std::string & displayName = "");
00245 
00249         virtual ~ XDisplay();
00250 
00252 
00253         
00254         
00255         
00256 
00258 
00259 
00260    public:
00261 
00267         const std::string & getDisplayName() const;
00268 
00274         ::Display * getDisplay() const;
00275 
00281         const bool & getInitialized() const;
00282 
00288         static const bool & getXMTInitialized();
00289 
00295         static const bool & getXMTSupported();
00296 
00302         const u32 & getWidth() const;
00303 
00309         const u32 & getHeight() const;
00310 
00316         static const Mutex & getErrorHandlerMutex();
00317 
00323         static const bool & getTolerateErrors();
00324 
00330         static void setTolerateErrors(const bool & tolerateerrors);
00331 
00333 
00334         
00335         
00336         
00337 
00339 
00340 
00341    protected:
00342 
00349         static int errorHandler(Display * display, XErrorEvent * errorEvent);
00350 
00352 
00353         
00354         
00355         
00356 
00358 
00359 
00360    public:
00361 
00365         virtual void initialize();
00366 
00370         virtual void finalize();
00371 
00376         virtual void synchronize(const bool & discard = false);
00377 
00386         virtual s32 findBestVisual(const s32 & screenNumber, const s32 & multiSample =
00387                                  XDisplay::IGNOREMULTISAMPLE);
00388 
00394         virtual void getVisualAttribs(XVisualInfo * vInfo, VisualAttribs & attribs);
00395 
00396    protected:
00397 
00404         virtual void initializeMT();
00405 
00407 
00408   };
00409 
00410   
00411   
00412   
00413 
00414 #  include "PCMXDisplay_impl.h"
00415 
00416 }
00417 
00418 #endif