windowSystem.h

00001 
00002 /* Copyright (c) 2006-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef EQ_WINDOWSYSTEM_H
00019 #define EQ_WINDOWSYSTEM_H
00020 
00021 #include <eq/base/base.h>
00022 
00023 #include <string>
00024 
00025 namespace eq
00026 {
00028     enum WindowSystem
00029     {
00030         WINDOW_SYSTEM_NONE = 0, // must be first
00031         WINDOW_SYSTEM_AGL,  
00032         WINDOW_SYSTEM_GLX,  
00033         WINDOW_SYSTEM_WGL,  
00034         WINDOW_SYSTEM_ALL      // must be last
00035     };
00036 
00037     EQ_EXPORT std::ostream& operator << ( std::ostream& os, 
00038                                           const WindowSystem ws );
00039 }
00040 
00041 // window system and OS-dependent includes and definitions below.
00042 #ifdef EQ_IGNORE_GLEW
00043 #  define GLEWContext void
00044 #  define WGLEWContext void
00045 #else
00046 #  include <GL/glew.h>
00047 #  ifdef WGL
00048 #    include <GL/wglew.h>
00049 #  endif
00050 #endif
00051 
00052 #define GL_GLEXT_PROTOTYPES
00053 
00054 #ifdef GLX
00055 #  include <X11/Xlib.h>
00056 #  include <GL/glx.h>
00057 #  ifndef GLX_SAMPLE_BUFFERS
00058 #    define GLX_SAMPLE_BUFFERS 100000
00059 #  endif
00060 #  ifndef GLX_SAMPLES
00061 #    define GLX_SAMPLES 100001
00062 #  endif
00063 #endif
00064 
00065 #ifdef AGL
00066 #  if defined(__i386__) // WAR compile error
00067 #    undef Status 
00068 #  endif
00069 #  define Cursor CGLCursor   // avoid name clash with X11 'Cursor'
00070 #  include <ApplicationServices/ApplicationServices.h>
00071 #  include <AGL/agl.h>
00072 #  include <Carbon/Carbon.h>
00073 #  define EQ_AGL_MENUBARHEIGHT 22
00074 #endif
00075 
00076 #ifdef WGL
00077 #  include <wingdi.h>
00078 #  include <GL/gl.h>
00079 
00080 #  ifndef WGL_NV_gpu_affinity
00081 #    define WGL_NV_gpu_affinity 1
00082 DECLARE_HANDLE(HGPUNV);
00083 typedef struct _GPU_DEVICE {
00084     DWORD  cb;
00085     CHAR   DeviceName[32];
00086     CHAR   DeviceString[128];
00087     DWORD  Flags;
00088     RECT   rcVirtualScreen;
00089 } GPU_DEVICE, *PGPU_DEVICE;
00090 
00091 #    ifdef WGL_WGLEXT_PROTOTYPES
00092 extern BOOL WINAPI wglEnumGpusNV (UINT iIndex, HGPUNV *hGpu);
00093 extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iIndex, PGPU_DEVICE pGpuDevice);
00094 extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *pGpuList);
00095 extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iIndex, HGPUNV *hGpu);
00096 extern BOOL WINAPI wglDeleteDCNV (HDC hAffinityDC);
00097 #    else
00098 typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iIndex, HGPUNV *hGpu);
00099 typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iIndex, PGPU_DEVICE pGpuDevice);
00100 typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *pGpuList);
00101 typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iIndex, HGPUNV *hGpu);
00102 typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hAffinityDC);
00103 #    endif // WGL_WGLEXT_PROTOTYPES
00104 #  endif // WGL_NV_gpu_affinity
00105 #endif
00106 
00107 #ifndef GLX
00108 typedef void Display;
00109 typedef void XErrorEvent;
00110 typedef unsigned long XID;
00111 typedef void* GLXContext;
00112 typedef void  XVisualInfo;
00113 #endif
00114 
00115 #ifndef AGL
00116 typedef int32_t CGDirectDisplayID;
00117 typedef void*   WindowRef;
00118 typedef void*   EventHandlerRef;
00119 typedef void*   AGLContext;
00120 typedef void*   AGLPixelFormat;
00121 typedef void*   AGLPbuffer;
00122 #endif
00123 
00124 #ifndef WGL
00125 typedef void* HDC;
00126 typedef void* HWND;
00127 typedef void* HPBUFFERARB;
00128 typedef void* HGLRC;
00129 typedef void* WGLEWContext;
00130 #  define PFNWGLDELETEDCNVPROC void*
00131 typedef bool  BOOL;
00132 #  define WINAPI
00133 #endif
00134 
00135 // Error-check macros
00136 #ifdef NDEBUG
00137 
00138 #  define EQ_GL_ERROR( when ) 
00139 #  define EQ_GL_CALL( code ) { code; }
00140 
00141 #else // NDEBUG
00142 
00143 namespace eq
00144 {
00146 EQ_EXPORT void debugGLError( const std::string& when, const GLenum error, 
00147                    const char* file, const int line );
00148 }
00149 
00150 #  define EQ_GL_ERROR( when )                                           \
00151     {                                                                   \
00152         const GLenum eqGlError = glGetError();                          \
00153         if( eqGlError )                                                 \
00154             eq::debugGLError( when, eqGlError, __FILE__, __LINE__ );    \
00155     }
00156 
00157 #  define EQ_GL_CALL( code )                              \
00158     {                                                     \
00159         EQ_GL_ERROR( std::string( "before " ) + #code );  \
00160         code;                                             \
00161         EQ_GL_ERROR( std::string( "after " ) + #code );   \
00162     }
00163 
00164 #endif // NDEBUG
00165 #endif // EQ_WINDOWSYSTEM_H
00166 
Generated on Mon Aug 10 18:58:41 2009 for Equalizer 0.9 by  doxygen 1.5.8