fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Shader / Chunks / OSGShaderProgramChunk.cpp
blobf756a5a02627d1c50b0a1958d1d04a6c2263dc53
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGShaderProgramChunk.h"
49 #include "OSGWindow.h"
50 #include "OSGShaderProgram.h"
52 OSG_BEGIN_NAMESPACE
54 // Documentation for this class is emitted in the
55 // OSGShaderProgramChunkBase.cpp file.
56 // To modify it, please change the .fcd file (OSGShaderProgramChunk.fcd) and
57 // regenerate the base file.
59 /***************************************************************************\
60 * Class variables *
61 \***************************************************************************/
63 StateChunkClass ShaderProgramChunk::_class("ShaderProgram", 1, 4);
64 volatile UInt16 ShaderProgramChunk::_uiChunkCounter = 1;
66 UInt32 ShaderProgramChunk::_extSHL = Window::invalidExtensionID;
68 /***************************************************************************\
69 * Class methods *
70 \***************************************************************************/
72 void ShaderProgramChunk::initMethod(InitPhase ePhase)
74 Inherited::initMethod(ePhase);
76 if(ePhase == TypeObject::SystemPost)
78 _extSHL = Window::registerExtension("GL_ARB_shading_language_100");
83 /***************************************************************************\
84 * Instance methods *
85 \***************************************************************************/
87 /*-------------------------------------------------------------------------*\
88 - private -
89 \*-------------------------------------------------------------------------*/
91 /*----------------------- constructors & destructors ----------------------*/
93 ShaderProgramChunk::ShaderProgramChunk(void) :
94 Inherited( ),
95 _uiChunkId(0)
99 ShaderProgramChunk::ShaderProgramChunk(const ShaderProgramChunk &source) :
100 Inherited(source),
101 _uiChunkId(0 )
105 ShaderProgramChunk::~ShaderProgramChunk(void)
109 void ShaderProgramChunk::onCreate(const ShaderProgramChunk *source)
111 Inherited::onCreate(source);
113 // ignore prototypes.
114 if(GlobalSystemState == Startup)
115 return;
117 _uiChunkId = _uiChunkCounter++;
120 void ShaderProgramChunk::onCreateAspect(const ShaderProgramChunk *createAspect,
121 const ShaderProgramChunk *source )
123 Inherited::onCreateAspect(createAspect, source);
125 _uiChunkId = createAspect->_uiChunkId;
128 void ShaderProgramChunk::onDestroy(UInt32 uiId)
130 Inherited::onDestroy(uiId);
133 const StateChunkClass *ShaderProgramChunk::getClass(void) const
135 return &_class;
138 UInt16 ShaderProgramChunk::getChunkId(void)
140 return _uiChunkId;
143 /*----------------------------- class specific ----------------------------*/
145 void ShaderProgramChunk::changed(ConstFieldMaskArg whichField,
146 UInt32 origin,
147 BitVector details)
149 Inherited::changed(whichField, origin, details);
152 void ShaderProgramChunk::dump( UInt32 ,
153 const BitVector ) const
155 SLOG << "Dump ShaderProgramChunk NI" << std::endl;
158 void ShaderProgramChunk::addShader(ShaderProgram * const value)
160 if(value == NULL)
162 SWARNING << "ShaderProgramChunk::addShader no shader given"
163 << " ignored" << std::endl;
165 return;
168 switch(value->getShaderType())
170 case GL_VERTEX_SHADER:
171 this->addVertexShader(value);
172 break;
174 case GL_TESS_CONTROL_SHADER:
175 this->addTessControlShader(value);
176 break;
178 case GL_TESS_EVALUATION_SHADER:
179 this->addTessEvaluationShader(value);
180 break;
182 case GL_GEOMETRY_SHADER_EXT:
183 this->addGeometryShader(value);
184 break;
186 case GL_FRAGMENT_SHADER:
187 this->addFragmentShader(value);
188 break;
190 default:
191 SWARNING << "ShaderProgramChunk::addShader unknow shader type "
192 << value->getShaderType()
193 << " ignored" << std::endl;
195 break;
199 void ShaderProgramChunk::activate (DrawEnv *pEnv,
200 UInt32 uiIdx)
202 SFATAL << "ShaderProgramChunk::activate" << std::endl;
205 void ShaderProgramChunk::changeFrom(DrawEnv *pEnv,
206 StateChunk *pOld,
207 UInt32 uiIdx)
209 SFATAL << "ShaderProgramChunk::changeFrom" << std::endl;
212 void ShaderProgramChunk::deactivate(DrawEnv *pEnv,
213 UInt32 uiIdx)
215 SFATAL << "ShaderProgramChunk::deactivate" << std::endl;
218 OSG_END_NAMESPACE