OSGVertexProgramChunk.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 <cstdlib>
00044 #include <cstdio>
00045 
00046 #include <boost/bind.hpp>
00047 
00048 #include <OSGConfig.h>
00049 
00050 #include <OSGGL.h>
00051 #include <OSGGLEXT.h>
00052 
00053 #include "OSGWindow.h"
00054 
00055 #include "OSGVertexProgramChunk.h"
00056 
00057 OSG_USING_NAMESPACE
00058 
00059 // Documentation for this class is emited in the
00060 // OSGVertexProgramChunkBase.cpp file.
00061 // To modify it, please change the .fcd file (OSGVertexProgramChunk.fcd) and
00062 // regenerate the base file.
00063 
00064 /***************************************************************************\
00065  *                           Class variables                               *
00066 \***************************************************************************/
00067 
00068 StateChunkClass VertexProgramChunk::_class("VertexProgram");
00069 
00070 UInt32 VertexProgramChunk::_arbVertexProgram = Window::invalidExtensionID;
00071 
00072 /***************************************************************************\
00073  *                           Class methods                                 *
00074 \***************************************************************************/
00075 
00076 void VertexProgramChunk::initMethod(InitPhase ePhase)
00077 {
00078     if(ePhase == TypeObject::SystemPost)
00079     {
00080         _arbVertexProgram = Window::registerExtension("GL_ARB_vertex_program");
00081     }
00082  }
00083 
00084 
00085 /***************************************************************************\
00086  *                           Instance methods                              *
00087 \***************************************************************************/
00088 
00089 /*-------------------------------------------------------------------------*\
00090  -  private                                                                 -
00091 \*-------------------------------------------------------------------------*/
00092 
00093 /*----------------------- constructors & destructors ----------------------*/
00094 
00095 VertexProgramChunk::VertexProgramChunk(void) :
00096     Inherited()
00097 {
00098 }
00099 
00100 VertexProgramChunk::VertexProgramChunk(const VertexProgramChunk &source) :
00101     Inherited(source)
00102 {
00103 }
00104 
00105 VertexProgramChunk::~VertexProgramChunk(void)
00106 {
00107 }
00108 
00109 /*----------------------------- onCreate --------------------------------*/
00110 
00111 void VertexProgramChunk::onCreate(const VertexProgramChunk *chunk)
00112 {
00113     Inherited::onCreate(chunk); 
00114 
00115     if(GlobalSystemState == Startup)
00116         return;
00117 
00118     setGLId(Window::registerGLObject(
00119                     boost::bind(&VertexProgramChunk::handleGL, this, 
00120                                     _1, _2, _3),
00121                     boost::bind(&VertexProgramChunk::handleDestroyGL, this, 
00122                                     _1, _2, _3)
00123            ));
00124 }
00125 
00126 
00127 /*------------------------- Chunk Class Access ---------------------------*/
00128 
00129 const StateChunkClass *VertexProgramChunk::getClass(void) const
00130 {
00131     return &_class;
00132 }
00133 
00134 /*----------------------------- class specific ----------------------------*/
00135 
00136 void VertexProgramChunk::changed(ConstFieldMaskArg whichField, 
00137                                  UInt32            origin,
00138                                  BitVector         details)
00139 {
00140     Inherited::changed(whichField, origin, details);
00141 }
00142 
00143 void VertexProgramChunk::dump(      UInt32    , 
00144                               const BitVector ) const
00145 {
00146     SLOG << "Dump VertexProgramChunk NI" << std::endl;
00147 }
00148 
00149 /*------------------------------ State ------------------------------------*/
00150 
00151 UInt32 VertexProgramChunk::getExtension(void) const
00152 {
00153     return _arbVertexProgram;
00154 }
00155 
00156 GLenum VertexProgramChunk::getTarget(void) const
00157 {
00158     return GL_VERTEX_PROGRAM_ARB;
00159 }
00160 
00161 const char *VertexProgramChunk::getTargetName(void) const
00162 {
00163     return "Vertex Program";
00164 }
00165 
00166 
00167 void VertexProgramChunk::handleGL(DrawEnv                 *pEnv, 
00168                                     UInt32                   osgid, 
00169                                     Window::GLObjectStatusE  mode)
00170 {
00171     Inherited::handleGL(pEnv, 
00172                         osgid,
00173                         mode, 
00174                         GL_VERTEX_PROGRAM_ARB, 
00175                         _arbVertexProgram);
00176 }
00177 
00178 void VertexProgramChunk::handleDestroyGL(DrawEnv                 *pEnv, 
00179                                     UInt32                   osgid, 
00180                                     Window::GLObjectStatusE  mode)
00181 {
00182     Inherited::handleDestroyGL(pEnv, 
00183                         osgid,
00184                         mode, 
00185                         GL_VERTEX_PROGRAM_ARB, 
00186                         _arbVertexProgram);
00187 }