00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048 #include <OSGGL.h>
00049
00050 #include <OSGNodePtr.h>
00051 #include <OSGViewport.h>
00052 #include <OSGImage.h>
00053
00054 #include "OSGGrabForeground.h"
00055
00056 OSG_USING_NAMESPACE
00057
00058
00059
00060
00061
00062
00072
00073
00074 GrabForeground::GrabForeground(void) :
00075 Inherited()
00076 {
00077 Inherited::setActive(false);
00078 }
00079
00080 GrabForeground::GrabForeground(const GrabForeground &source) :
00081 Inherited(source)
00082 {
00083 }
00084
00085 GrabForeground::~GrabForeground(void)
00086 {
00087 }
00088
00089
00090
00091 void GrabForeground::initMethod (void)
00092 {
00093 }
00094
00095 void GrabForeground::changed(BitVector whichField, UInt32 origin)
00096 {
00097 Inherited::changed(whichField, origin);
00098 }
00099
00100 void GrabForeground::dump( UInt32 ,
00101 const BitVector ) const
00102 {
00103 SLOG << "Dump GrabForeground NI" << std::endl;
00104 }
00105
00106
00109 void GrabForeground::draw(DrawActionBase *, Viewport *port)
00110 {
00111 if(getActive() == false)
00112 return;
00113
00114 ImagePtr i = getImage();
00115
00116 if(i == NullFC)
00117 return;
00118
00119 UInt32 w = osgMax(2, port->getPixelWidth());
00120 UInt32 h = osgMax(2, port->getPixelHeight());
00121
00122
00123
00124
00125 if ( (i->getWidth() <= 1 || i->getHeight() <= 1) ||
00126 (getAutoResize() && (w != i->getWidth() || h != i->getHeight())) )
00127 {
00128 i->set(i->getPixelFormat(), w, h);
00129 }
00130
00131 bool storeChanged = false;
00132
00133 if ( !getAutoResize() )
00134 {
00135 w = osgMin(i->getWidth(), port->getPixelWidth());
00136 h = osgMin(i->getHeight(), port->getPixelHeight());
00137
00138 if (i->getWidth() != port->getPixelWidth())
00139 {
00140 glPixelStorei(GL_PACK_ROW_LENGTH, i->getWidth());
00141 storeChanged = true;
00142 }
00143 }
00144
00145 glReadPixels(port->getPixelLeft(), port->getPixelBottom(),
00146 w, h, i->getPixelFormat(),
00147 i->getDataType(), i->getData());
00148
00149 if(storeChanged)
00150 glPixelStorei(GL_PACK_ROW_LENGTH, 0);
00151 }
00152
00153
00154
00155
00156
00157 #ifdef __sgi
00158 #pragma set woff 1174
00159 #endif
00160
00161 #ifdef OSG_LINUX_ICC
00162 #pragma warning( disable : 177 )
00163 #endif
00164
00165 namespace
00166 {
00167 static char cvsid_cpp[] = "@(#)$Id: $";
00168 static char cvsid_hpp[] = OSGGRABFOREGROUND_HEADER_CVSID;
00169 static char cvsid_inl[] = OSGGRABFOREGROUND_INLINE_CVSID;
00170 }
00171