aglPipe.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "aglPipe.h"
00020
00021 #include "global.h"
00022 #include "pipe.h"
00023
00024 #include <sstream>
00025
00026 using namespace std;
00027
00028 namespace eq
00029 {
00030
00031 AGLPipe::AGLPipe( Pipe* parent )
00032 : OSPipe( parent )
00033 , _cgDisplayID( 0 )
00034 {
00035 }
00036
00037 AGLPipe::~AGLPipe( )
00038 {
00039 }
00040
00041
00042
00043
00044 bool AGLPipe::configInit()
00045 {
00046 #ifdef AGL
00047 CGDirectDisplayID displayID = CGMainDisplayID();
00048 const uint32_t device = _pipe->getDevice();
00049
00050 if( device != EQ_UNDEFINED_UINT32 )
00051 {
00052 CGDirectDisplayID displayIDs[device+1];
00053 CGDisplayCount nDisplays;
00054
00055 if( CGGetOnlineDisplayList( device+1, displayIDs, &nDisplays ) !=
00056 kCGErrorSuccess )
00057 {
00058 ostringstream msg;
00059 msg << "Can't get display identifier for display " << device;
00060 setErrorMessage( msg.str( ));
00061 return false;
00062 }
00063
00064 if( nDisplays <= device )
00065 {
00066 ostringstream msg;
00067 msg << "Can't get display identifier for display " << device
00068 << ", not enough displays in this system";
00069 setErrorMessage( msg.str( ));
00070 return false;
00071 }
00072
00073 displayID = displayIDs[device];
00074 }
00075
00076 _setCGDisplayID( displayID );
00077 EQINFO << "Using CG displayID " << displayID << endl;
00078 return true;
00079 #else
00080 setErrorMessage( "Client library compiled without AGL support" );
00081 return false;
00082 #endif
00083 }
00084
00085
00086 void AGLPipe::_setCGDisplayID( CGDirectDisplayID id )
00087 {
00088 #ifdef AGL
00089 if( _cgDisplayID == id )
00090 return;
00091
00092 _cgDisplayID = id;
00093 PixelViewport pvp = _pipe->getPixelViewport();
00094
00095 if( pvp.isValid( ))
00096 return;
00097
00098 if( id )
00099 {
00100 const CGRect displayRect = CGDisplayBounds( id );
00101 pvp.x = (int32_t)displayRect.origin.x;
00102 pvp.y = (int32_t)displayRect.origin.y;
00103 pvp.w = (int32_t)displayRect.size.width;
00104 pvp.h = (int32_t)displayRect.size.height;
00105 }
00106 else
00107 pvp.invalidate();
00108
00109 _pipe->setPixelViewport( pvp );
00110 #endif
00111 }
00112
00113
00114 void AGLPipe::configExit()
00115 {
00116 #ifdef AGL
00117 _setCGDisplayID( 0 );
00118 EQINFO << "Reset CG displayID " << endl;
00119 #endif
00120 }
00121
00122 }
00123