Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGShaderChunk.cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *               Copyright (C) 2000-2002 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 <stdlib.h>
00044 #include <stdio.h>
00045 
00046 #include <OSGConfig.h>
00047 
00048 #include "OSGShaderChunk.h"
00049 
00050 OSG_USING_NAMESPACE
00051 
00052 /***************************************************************************\
00053  *                            Description                                  *
00054 \***************************************************************************/
00055 
00060 /***************************************************************************\
00061  *                           Class variables                               *
00062 \***************************************************************************/
00063 
00064 /***************************************************************************\
00065  *                           Class methods                                 *
00066 \***************************************************************************/
00067 
00068 void ShaderChunk::initMethod (void)
00069 {
00070 }
00071 
00072 
00073 /***************************************************************************\
00074  *                           Instance methods                              *
00075 \***************************************************************************/
00076 
00077 /*-------------------------------------------------------------------------*\
00078  -  private                                                                 -
00079 \*-------------------------------------------------------------------------*/
00080 
00081 /*----------------------- constructors & destructors ----------------------*/
00082 
00083 ShaderChunk::ShaderChunk(void) :
00084     Inherited()
00085 {
00086 }
00087 
00088 ShaderChunk::ShaderChunk(const ShaderChunk &source) :
00089     Inherited(source)
00090 {
00091 }
00092 
00093 ShaderChunk::~ShaderChunk(void)
00094 {
00095 }
00096 
00097 /*----------------------------- class specific ----------------------------*/
00098 
00099 void ShaderChunk::changed(BitVector whichField, UInt32 origin)
00100 {
00101     Inherited::changed(whichField, origin);
00102 }
00103 
00104 void ShaderChunk::dump(      UInt32    , 
00105                          const BitVector ) const
00106 {
00107     SLOG << "Dump ShaderChunk NI" << std::endl;
00108 }
00109 
00110 /*---------------------------------- Access -------------------------------*/
00111 
00114 bool ShaderChunk::readVertexProgram(const char *file)
00115 {
00116     std::ifstream s(file);
00117     
00118     if(s.good())
00119     {
00120         return readVertexProgram(s);
00121     }
00122     else
00123     {
00124         FWARNING(("ShaderChunk::readVertexProgram: couldn't open '%s' for reading!\n",
00125                   file));
00126         return false;
00127     }
00128 }
00129 
00132 bool ShaderChunk::readVertexProgram(std::istream &stream)
00133 {
00134 #define BUFSIZE 200
00135     
00136     getVertexProgram().erase();    
00137     char buf[BUFSIZE];
00138 
00139     if(!stream.good())
00140     {
00141         FWARNING(("SHLChunk::readVertexProgram: stream is not good!\n"));
00142         return false;
00143     }
00144     
00145     do
00146     {
00147         stream.read(buf, BUFSIZE);
00148         getVertexProgram().append(buf, stream.gcount());
00149     }
00150     while(!stream.eof());
00151     
00152     return true;
00153 }
00154 
00157 bool ShaderChunk::readFragmentProgram(const char *file)
00158 {
00159     std::ifstream s(file);
00160     
00161     if(s.good())
00162     {
00163         return readFragmentProgram(s);
00164     }
00165     else
00166     {
00167         FWARNING(("ShaderChunk::readFragmentProgram: couldn't open '%s' for reading!\n",
00168                   file));
00169         return false;
00170     }
00171 }
00172 
00175 bool ShaderChunk::readFragmentProgram(std::istream &stream)
00176 {
00177 #define BUFSIZE 200
00178     
00179     getFragmentProgram().erase();    
00180     char buf[BUFSIZE];
00181 
00182     if(!stream.good())
00183     {
00184         FWARNING(("SHLChunk::readFragmentProgram: stream is not good!\n"));
00185         return false;
00186     }
00187     
00188     do
00189     {
00190         stream.read(buf, BUFSIZE);
00191         getFragmentProgram().append(buf, stream.gcount());
00192     }
00193     while(!stream.eof());
00194     
00195     return true;
00196 }
00197 
00198 /*------------------------------------------------------------------------*/
00199 /*                              cvs id's                                  */
00200 
00201 #ifdef OSG_SGI_CC
00202 #pragma set woff 1174
00203 #endif
00204 
00205 #ifdef OSG_LINUX_ICC
00206 #pragma warning( disable : 177 )
00207 #endif
00208 
00209 namespace
00210 {
00211     static Char8 cvsid_cpp       [] = "@(#)$Id: OSGShaderChunk.cpp,v 1.4 2004/08/27 12:50:51 a-m-z Exp $";
00212     static Char8 cvsid_hpp       [] = OSGSHADERCHUNKBASE_HEADER_CVSID;
00213     static Char8 cvsid_inl       [] = OSGSHADERCHUNKBASE_INLINE_CVSID;
00214 
00215     static Char8 cvsid_fields_hpp[] = OSGSHADERCHUNKFIELDS_HEADER_CVSID;
00216 }
00217 
00218 #ifdef __sgi
00219 #pragma reset woff 1174
00220 #endif
00221 

Generated on Thu Aug 25 04:09:09 2005 for OpenSG by  doxygen 1.4.3