~ubuntu-branches/debian/sid/coin2/sid

« back to all changes in this revision

Viewing changes to src/shaders/SoGLCgShaderProgram.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-06-28 02:38:17 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080628023817-lgrh0u677j1gcqgf
Tags: 2.5.0-2
* debian/control: Change suggests from libopenal0 to libopenal0a.
  Closes: #488001.  Change ${Source-Version} to ${binary:Version}.
  Update to standards version 3.8.0.

* debian/rules: Do not ignore errors in clean rule.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************\
 
2
 *
 
3
 *  This file is part of the Coin 3D visualization library.
 
4
 *  Copyright (C) 1998-2007 by Systems in Motion.  All rights reserved.
 
5
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
17
 *  See http://www.coin3d.org/ for more information.
 
18
 *
 
19
 *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
 
20
 *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
 
21
 *
 
22
\**************************************************************************/
 
23
 
 
24
#include "SoGLCgShaderProgram.h"
 
25
 
 
26
#include <assert.h>
 
27
#include <stdlib.h>
 
28
 
 
29
#include "SoGLCgShaderObject.h"
 
30
 
 
31
// *************************************************************************
 
32
 
 
33
SoGLCgShaderProgram::SoGLCgShaderProgram(void)
 
34
{
 
35
  this->fragmentShader = NULL;
 
36
  this->vertexShader = NULL;
 
37
}
 
38
 
 
39
SoGLCgShaderProgram::~SoGLCgShaderProgram()
 
40
{
 
41
}
 
42
 
 
43
void
 
44
SoGLCgShaderProgram::addShaderObject(SoGLCgShaderObject * shaderObject)
 
45
{
 
46
  if (shaderObject->getShaderType() == SoGLShaderObject::VERTEX) {
 
47
    this->vertexShader = shaderObject;
 
48
  }
 
49
  else {
 
50
    assert(shaderObject->getShaderType() == SoGLShaderObject::FRAGMENT);
 
51
    this->fragmentShader = shaderObject;
 
52
  }
 
53
}
 
54
 
 
55
void
 
56
SoGLCgShaderProgram::removeShaderObjects(void)
 
57
{
 
58
  this->vertexShader = NULL;
 
59
  this->fragmentShader = NULL;
 
60
}
 
61
 
 
62
void
 
63
SoGLCgShaderProgram::enable(void)
 
64
{
 
65
  if (this->fragmentShader) this->fragmentShader->enable();
 
66
  if (this->vertexShader) this->vertexShader->enable();
 
67
}
 
68
 
 
69
void
 
70
SoGLCgShaderProgram::disable(void)
 
71
{
 
72
  if (this->fragmentShader) this->fragmentShader->disable();
 
73
  if (this->vertexShader) this->vertexShader->disable();
 
74
}
 
75
 
 
76
#if defined(SOURCE_HINT)
 
77
SbString
 
78
SoGLCgShaderProgram::getSourceHint(void) const
 
79
{
 
80
  SbString result;
 
81
 
 
82
  if (this->fragmentShader && this->fragmentShader->isActive()) {
 
83
    SbString str = this->fragmentShader->sourceHint;
 
84
    if (str.getLength() > 0) str += " ";
 
85
    result += str;
 
86
  }
 
87
  if (this->vertexShader && this->vertexShader->isActive()) {
 
88
    SbString str = this->vertexShader->sourceHint;
 
89
    if (str.getLength() > 0) str += " ";
 
90
    result += str;
 
91
  }
 
92
  return result;
 
93
}
 
94
#endif