1
/**************************************************************************\
3
* This file is part of the Coin 3D visualization library.
4
* Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* ("GPL") version 2 as published by the Free Software Foundation.
9
* See the file LICENSE.GPL at the root directory of this source
10
* distribution for additional information about the GNU GPL.
12
* For using Coin with software that can not be combined with the GNU
13
* GPL, and for taking advantage of the additional benefits of our
14
* support services, please contact Systems in Motion about acquiring
15
* a Coin Professional Edition License.
17
* See http://www.coin3d.org/ for more information.
19
* Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
20
* http://www.sim.no/ sales@sim.no coin-support@coin3d.org
22
\**************************************************************************/
24
#include "SoGLCgShaderProgram.h"
29
#include "SoGLCgShaderObject.h"
31
// *************************************************************************
33
SoGLCgShaderProgram::SoGLCgShaderProgram(void)
35
this->fragmentShader = NULL;
36
this->vertexShader = NULL;
39
SoGLCgShaderProgram::~SoGLCgShaderProgram()
44
SoGLCgShaderProgram::addShaderObject(SoGLCgShaderObject * shaderObject)
46
if (shaderObject->getShaderType() == SoGLShaderObject::VERTEX) {
47
this->vertexShader = shaderObject;
50
assert(shaderObject->getShaderType() == SoGLShaderObject::FRAGMENT);
51
this->fragmentShader = shaderObject;
56
SoGLCgShaderProgram::removeShaderObjects(void)
58
this->vertexShader = NULL;
59
this->fragmentShader = NULL;
63
SoGLCgShaderProgram::enable(void)
65
if (this->fragmentShader) this->fragmentShader->enable();
66
if (this->vertexShader) this->vertexShader->enable();
70
SoGLCgShaderProgram::disable(void)
72
if (this->fragmentShader) this->fragmentShader->disable();
73
if (this->vertexShader) this->vertexShader->disable();
76
#if defined(SOURCE_HINT)
78
SoGLCgShaderProgram::getSourceHint(void) const
82
if (this->fragmentShader && this->fragmentShader->isActive()) {
83
SbString str = this->fragmentShader->sourceHint;
84
if (str.getLength() > 0) str += " ";
87
if (this->vertexShader && this->vertexShader->isActive()) {
88
SbString str = this->vertexShader->sourceHint;
89
if (str.getLength() > 0) str += " ";