1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
48 #include "OSGShaderProgramChunk.h"
49 #include "OSGWindow.h"
50 #include "OSGShaderProgram.h"
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 /***************************************************************************\
61 \***************************************************************************/
63 StateChunkClass
ShaderProgramChunk::_class("ShaderProgram", 1, 4);
64 volatile UInt16
ShaderProgramChunk::_uiChunkCounter
= 1;
66 UInt32
ShaderProgramChunk::_extSHL
= Window::invalidExtensionID
;
68 /***************************************************************************\
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 /***************************************************************************\
85 \***************************************************************************/
87 /*-------------------------------------------------------------------------*\
89 \*-------------------------------------------------------------------------*/
91 /*----------------------- constructors & destructors ----------------------*/
93 ShaderProgramChunk::ShaderProgramChunk(void) :
99 ShaderProgramChunk::ShaderProgramChunk(const ShaderProgramChunk
&source
) :
105 ShaderProgramChunk::~ShaderProgramChunk(void)
109 void ShaderProgramChunk::onCreate(const ShaderProgramChunk
*source
)
111 Inherited::onCreate(source
);
113 // ignore prototypes.
114 if(GlobalSystemState
== Startup
)
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
138 UInt16
ShaderProgramChunk::getChunkId(void)
143 /*----------------------------- class specific ----------------------------*/
145 void ShaderProgramChunk::changed(ConstFieldMaskArg whichField
,
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
)
162 SWARNING
<< "ShaderProgramChunk::addShader no shader given"
163 << " ignored" << std::endl
;
168 switch(value
->getShaderType())
170 case GL_VERTEX_SHADER
:
171 this->addVertexShader(value
);
174 case GL_TESS_CONTROL_SHADER
:
175 this->addTessControlShader(value
);
178 case GL_TESS_EVALUATION_SHADER
:
179 this->addTessEvaluationShader(value
);
182 case GL_GEOMETRY_SHADER_EXT
:
183 this->addGeometryShader(value
);
186 case GL_FRAGMENT_SHADER
:
187 this->addFragmentShader(value
);
191 SWARNING
<< "ShaderProgramChunk::addShader unknow shader type "
192 << value
->getShaderType()
193 << " ignored" << std::endl
;
199 void ShaderProgramChunk::activate (DrawEnv
*pEnv
,
202 SFATAL
<< "ShaderProgramChunk::activate" << std::endl
;
205 void ShaderProgramChunk::changeFrom(DrawEnv
*pEnv
,
209 SFATAL
<< "ShaderProgramChunk::changeFrom" << std::endl
;
212 void ShaderProgramChunk::deactivate(DrawEnv
*pEnv
,
215 SFATAL
<< "ShaderProgramChunk::deactivate" << std::endl
;