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 <OSGFieldContainer.h>
00051 #include <OSGNode.h>
00052 #include <OSGAction.h>
00053 #include <OSGDrawAction.h>
00054 #include "OSGViewport.h"
00055 #include "OSGCamera.h"
00056 #include "OSGWindow.h"
00057 #include "OSGImage.h"
00058
00059 #include "OSGImageForeground.h"
00060
00061 OSG_USING_NAMESPACE
00062
00063
00064
00065
00066
00067
00079
00080
00081
00082
00083
00084
00085
00086
00087 void ImageForeground::initMethod(void)
00088 {
00089 }
00090
00091
00092
00093
00094
00095
00096
00097 ImageForeground::ImageForeground(void) :
00098 Inherited()
00099 {
00100 }
00101
00102 ImageForeground::ImageForeground(const ImageForeground &source) :
00103 Inherited(source)
00104 {
00105 }
00106
00107 ImageForeground::~ImageForeground(void)
00108 {
00109 }
00110
00111 void ImageForeground::changed(BitVector whichField, UInt32 origin)
00112 {
00113 Inherited::changed(whichField, origin);
00114 }
00115
00116
00117
00118 void ImageForeground::dump( UInt32 OSG_CHECK_ARG(uiIndent),
00119 const BitVector OSG_CHECK_ARG(bvFlags)) const
00120 {
00121 SLOG << "Dump ImageForeground NI" << std::endl;
00122 }
00123
00124
00125 void ImageForeground::draw(DrawActionBase *, Viewport *vp)
00126 {
00127 if(getActive() == false)
00128 return;
00129
00130 UInt16 i;
00131
00132 for(i = 0; i < getPositions().size(); i++)
00133 {
00134 if(getImages(i) != NullFC)
00135 break;
00136 }
00137
00138 if(i == getPositions().size())
00139 return;
00140
00141 glPushAttrib(GL_POLYGON_BIT | GL_DEPTH_BUFFER_BIT |
00142 GL_LIGHTING_BIT);
00143
00144 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00145
00146 glDisable(GL_DEPTH_TEST);
00147
00148 glDisable(GL_COLOR_MATERIAL);
00149
00150 glDisable(GL_TEXTURE_2D);
00151
00152 glMatrixMode(GL_MODELVIEW);
00153 glPushMatrix();
00154 glLoadIdentity();
00155
00156 glMatrixMode(GL_PROJECTION);
00157 glPushMatrix();
00158 glLoadIdentity();
00159 glOrtho(0, 1, 0, 1, 0, 1);
00160
00161 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00162 glEnable(GL_BLEND);
00163
00164 float vpWidth = 1.0, vpHeight = 1.0;
00165 if(vp)
00166 {
00167
00168 vpWidth = 1.0/vp->getPixelWidth();
00169 vpHeight = 1.0/vp->getPixelHeight();
00170 }
00171
00172 for(i = 0; i < getPositions().size(); i++)
00173 {
00174 ImagePtr img = getImages(i);
00175
00176 if(img == NullFC)
00177 continue;
00178
00179 Pnt2f p = getPositions(i);
00180 if( p[0] >= 1.0 || p[1] >= 1.0 )
00181 glRasterPos2f(p[0]*vpWidth, p[1]*vpHeight);
00182 else
00183 glRasterPos2f(p[0], p[1]);
00184
00185 glDrawPixels(img->getWidth(), img->getHeight(),
00186 img->getPixelFormat(), GL_UNSIGNED_BYTE,
00187 img->getData());
00188 }
00189 glDisable(GL_BLEND);
00190
00191
00192 glPopMatrix();
00193 glMatrixMode(GL_MODELVIEW);
00194 glPopMatrix();
00195
00196 glPopAttrib();
00197 }
00198
00199
00200
00201
00202 #ifdef __sgi
00203 #pragma set woff 1174
00204 #endif
00205
00206 #ifdef OSG_LINUX_ICC
00207 #pragma warning(disable : 177)
00208 #endif
00209
00210 namespace
00211 {
00212 static char cvsid_cpp[] = "@(#)$Id: $";
00213 static char cvsid_hpp[] = OSGIMAGEFOREGROUND_HEADER_CVSID;
00214 static char cvsid_inl[] = OSGIMAGEFOREGROUND_INLINE_CVSID;
00215 }
00216
00217