OSGTileableBackground.cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *               Copyright (C) 2000-2006 by the OpenSG Forum                 *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038
00039 //---------------------------------------------------------------------------
00040 //  Includes
00041 //---------------------------------------------------------------------------
00042
00043 #include <cstdlib>
00044 #include <cstdio>
00045
00046 #include "OSGConfig.h"
00047
00048 #include "OSGTileableBackground.h"
00049 #include "OSGDrawEnv.h"
00050 #include "OSGRenderActionBase.h"
00051 #include "OSGTileCameraDecorator.h"
00052
00053 OSG_BEGIN_NAMESPACE
00054
00055 // Documentation for this class is emitted in the
00056 // OSGTileableBackgroundBase.cpp file.
00057 // To modify it, please change the .fcd file (OSGTileableBackground.fcd) and
00058 // regenerate the base file.
00059
00060 /***************************************************************************\
00061  *                           Class variables                               *
00062 \***************************************************************************/
00063
00064 /***************************************************************************\
00065  *                           Class methods                                 *
00066 \***************************************************************************/
00067
00068 void TileableBackground::initMethod(InitPhase ePhase)
00069 {
00070     Inherited::initMethod(ePhase);
00071
00072     if(ePhase == TypeObject::SystemPost)
00073     {
00074     }
00075 }
00076
00077
00078 /***************************************************************************\
00079  *                           Instance methods                              *
00080 \***************************************************************************/
00081
00082 /*-------------------------------------------------------------------------*\
00083  -  private                                                                 -
00084 \*-------------------------------------------------------------------------*/
00085
00086 /*----------------------- constructors & destructors ----------------------*/
00087
00088 TileableBackground::TileableBackground(void) :
00089     Inherited()
00090 {
00091 }
00092
00093 TileableBackground::TileableBackground(const TileableBackground &source) :
00094     Inherited(source)
00095 {
00096 }
00097
00098 TileableBackground::~TileableBackground(void)
00099 {
00100 }
00101
00102 /*----------------------------- class specific ----------------------------*/
00103
00104 void TileableBackground::changed(ConstFieldMaskArg whichField,
00105                             UInt32            origin,
00106                             BitVector         details)
00107 {
00108     Inherited::changed(whichField, origin, details);
00109 }
00110
00111 void TileableBackground::dump(      UInt32    ,
00112                          const BitVector ) const
00113 {
00114     SLOG << "Dump TileableBackground NI" << std::endl;
00115 }
00116
00130 void TileableBackground::beginOrthoRender(
00131     DrawEnv *pEnv,
00132     bool     normX,
00133     bool     normY,
00134     UInt32  &fullWidth,
00135     UInt32  &fullHeight)
00136 {
00137     glMatrixMode(GL_MODELVIEW);
00138     glPushMatrix();
00139     glLoadIdentity();
00140
00141     glMatrixMode(GL_TEXTURE);
00142     glPushMatrix();
00143     glLoadIdentity();
00144
00145     glMatrixMode(GL_PROJECTION);
00146     glPushMatrix();
00147     glLoadIdentity();
00148
00149     UInt32               width   = pEnv->getPixelWidth ();
00150     UInt32               height  = pEnv->getPixelHeight();
00151
00152     fullWidth  = pEnv->getTileFullSize()[0];
00153     fullHeight = pEnv->getTileFullSize()[1];
00154
00155     if(fullWidth == 0)
00156     {
00157         fullWidth  = width;
00158         fullHeight = height;
00159     }
00160     else
00161     {
00162         if(getTile() == false)
00163         {
00164             Matrix sm = pEnv->calcTileDecorationMatrix();
00165
00166             glLoadMatrixf(sm.getValues());
00167         }
00168     }
00169
00170     Real32 projWidth  = normX ? 1.0f : Real32(width );
00171     Real32 projHeight = normY ? 1.0f : Real32(height);
00172
00173     glOrtho(0, projWidth, 0, projHeight, -1.0f, 1.0f);
00174 }
00175
00178 void TileableBackground::endOrthoRender(DrawEnv *pEnv)
00179 {
00180     glMatrixMode(GL_PROJECTION);
00181     glPopMatrix();
00182
00183     glMatrixMode(GL_TEXTURE);
00184     glPopMatrix();
00185
00186     glMatrixMode(GL_MODELVIEW);
00187     glPopMatrix();
00188 }
00189
00190 OSG_END_NAMESPACE